Total Complexity | 6 |
Total Lines | 55 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | class Language extends Model |
||
14 | { |
||
15 | /** |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $table = 'languages'; |
||
19 | |||
20 | /** |
||
21 | * @var array |
||
22 | */ |
||
23 | protected $fillable = ['locale', 'short_name', 'name', 'default']; |
||
24 | |||
25 | /** |
||
26 | * List of available languages in short name format. |
||
27 | * @return array |
||
28 | */ |
||
29 | public static function shortLanguageList(): array |
||
30 | { |
||
31 | return static::pluck('short_name')->toArray(); |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * List of available languages. |
||
36 | * @return mixed |
||
37 | */ |
||
38 | public static function languageList() |
||
39 | { |
||
40 | return static::get(); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * Get a default language entry. |
||
45 | * @return Language|null |
||
46 | */ |
||
47 | public static function defaultLanguage() |
||
48 | { |
||
49 | return static::firstWhere('default', 1); |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Set default = 1 just for one entry. |
||
54 | * @return void |
||
55 | */ |
||
56 | protected static function booted() |
||
68 | } |
||
69 | } |
||
70 | }); |
||
71 | } |
||
73 |