mirror of
https://code.castopod.org/adaures/castopod.git
synced 2024-09-03 09:27:24 +02:00
- adapt wireframes with responsive design - refactor models methods to cache requests for faster queries - update public controllers to cache pages while retaining analytics hits - add platform links to podcast page - add previous / next episodes in episode page - update npm packages to latest versions closes #30, #13
45 lines
1.0 KiB
PHP
45 lines
1.0 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @copyright 2020 Podlibre
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
* @link https://castopod.org/
|
|
*/
|
|
|
|
namespace App\Models;
|
|
|
|
use CodeIgniter\Model;
|
|
|
|
class LanguageModel extends Model
|
|
{
|
|
protected $table = 'languages';
|
|
protected $primaryKey = 'id';
|
|
|
|
protected $allowedFields = ['code', 'native_name'];
|
|
|
|
protected $returnType = \App\Entities\Language::class;
|
|
protected $useSoftDeletes = false;
|
|
|
|
protected $useTimestamps = false;
|
|
|
|
public function getLanguageOptions()
|
|
{
|
|
if (!($options = cache('language_options'))) {
|
|
$languages = $this->findAll();
|
|
|
|
$options = array_reduce(
|
|
$languages,
|
|
function ($result, $language) {
|
|
$result[$language->code] = $language->native_name;
|
|
return $result;
|
|
},
|
|
[]
|
|
);
|
|
|
|
cache()->save('language_options', $options, DECADE);
|
|
}
|
|
|
|
return $options;
|
|
}
|
|
}
|