1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
4
|
|
|
|
5
|
|
|
use App\Http\Requests\SettingsRequest; |
6
|
|
|
use App\Services\VersionInfoService; |
7
|
|
|
use Auth; |
8
|
|
|
use Tremby\LaravelGitVersion\GitVersionHelper; |
9
|
|
|
|
10
|
|
|
class SettingsController extends Controller |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @var VersionInfoService |
14
|
|
|
*/ |
15
|
|
|
private $versionInfoService; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* SettingController constructor. |
19
|
|
|
* |
20
|
|
|
* @param VersionInfoService $versionInfoService |
21
|
|
|
*/ |
22
|
|
|
public function __construct(VersionInfoService $versionInfoService) |
23
|
|
|
{ |
24
|
|
|
$this->versionInfoService = $versionInfoService; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
29
|
|
|
*/ |
30
|
|
|
public function index() |
31
|
|
|
{ |
32
|
|
|
$packages = $this->versionInfoService->packageInfo(); |
33
|
|
|
$version = GitVersionHelper::getVersion(); |
34
|
|
|
$apiVersion = \App\Services\Mmex\MmexConstants::$api_version; |
35
|
|
|
$user = Auth::user(); |
36
|
|
|
$authGuid = $user->mmex_guid ?? mmex_guid(); |
37
|
|
|
$userLocale = $user->locale; |
38
|
|
|
$disableStatus = $user->disable_status; |
39
|
|
|
$useDatepicker = $user->use_datepicker; |
40
|
|
|
|
41
|
|
|
return view('setting.index', compact('packages', 'version', 'userLocale', 'apiVersion', 'authGuid', 'disableStatus', 'useDatepicker')); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @param SettingsRequest $request |
46
|
|
|
* |
47
|
|
|
* @return \Illuminate\Http\RedirectResponse |
48
|
|
|
*/ |
49
|
|
|
public function update(SettingsRequest $request) |
50
|
|
|
{ |
51
|
|
|
$user = Auth::user(); |
52
|
|
|
|
53
|
|
|
$user->locale = $request->user_locale; |
|
|
|
|
54
|
|
|
$user->mmex_guid = $request->mmex_guid; |
|
|
|
|
55
|
|
|
$user->disable_status = $request->disable_status == 'true' ?? false; |
|
|
|
|
56
|
|
|
$user->use_datepicker = $request->use_datepicker == 'true' ?? false; |
|
|
|
|
57
|
|
|
|
58
|
|
|
$user->save(); |
59
|
|
|
|
60
|
|
|
return back()->with('status', __('mmex.updated')); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.