Skip to content

Commit d1a0163

Browse files
fix config locale input (#20)
1 parent 5262262 commit d1a0163

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

packages/felipemateus/laravel-iptv-core/src/Controllers/ConfigController.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@ class ConfigController extends CoreController
1515
*
1616
* @return view -> IPTV::config
1717
*/
18-
public function config(){
19-
18+
public function config()
19+
{
2020
$data["config_list"] = IPTVConfig::getAllBoleanSettings();
2121
$data['locales'] = Locale::getList();
22-
$data["current_locate"] = IPTVConfig::get('CURRENT_LOCALE','br');
22+
$data["current_locate"] = IPTVConfig::get('CURRENT_LOCALE', 'br');
2323
$data["inputs"] = IPTVConfig::getAllStringSettings();
24-
25-
return view("IPTV::config", $data);
26-
}
24+
return view("IPTV::config", $data);
25+
}
2726

2827
/**
2928
* Update config .
@@ -32,11 +31,19 @@ public function config(){
3231
*/
3332
public function configSave(Request $request ){
3433
$configs = IPTVConfig::getAllBoleanSettings();
35-
foreach($configs as $config){
36-
IPTVConfig::set($config['name'], $request->boolean($config['name']),'bool');
34+
foreach ($configs as $config) {
35+
IPTVConfig::set(
36+
$config['name'],
37+
$request->boolean($config['name']),
38+
'bool'
39+
);
3740
}
3841

39-
IPTVConfig::set('CURRENT_LOCALE',$request->input('CURRENT_LOCALE'));
42+
IPTVConfig::set(
43+
'CURRENT_LOCALE',
44+
$request->input('CURRENT_LOCALE'),
45+
'locale'
46+
);
4047
return redirect()->route('config');
4148
}
4249
}

packages/felipemateus/laravel-iptv-core/src/Model/IPTVConfig.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,18 @@ public static function get($key, $default = null)
6868
* @param string $type
6969
* @return bool
7070
*/
71-
public static function set($key, $val, $type = 'string'){
71+
public static function set($key, $val, $type = 'string')
72+
{
7273

73-
if ( $setting = self::all()->where('name', $key)->first() ) {
74+
if ($setting = self::all()->where('name', $key)->first() ) {
7475

75-
return $setting->update([
76+
return $setting->update(
77+
[
7678
'name' => $key,
7779
'val' => $val,
78-
'type' => $type]) ? $val : false;
80+
'type' => $type
81+
]
82+
) ? $val : false;
7983
}
8084

8185
return self::add($key, $val, $type);

0 commit comments

Comments
 (0)