@@ -18,8 +18,8 @@ |
||
18 | 18 | public function handle($request, Closure $next) |
19 | 19 | { |
20 | 20 | |
21 | - if(session()->get("developer") != getSetting('developer_username')) { |
|
22 | - return cb()->redirect(cb()->getDeveloperUrl("login"),"Please login for first"); |
|
21 | + if (session()->get("developer") != getSetting('developer_username')) { |
|
22 | + return cb()->redirect(cb()->getDeveloperUrl("login"), "Please login for first"); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | return $next($request); |
@@ -25,15 +25,15 @@ |
||
25 | 25 | { |
26 | 26 | |
27 | 27 | try { |
28 | - if(@$this->command->option("password") == "AUTO" || !@$this->command->option("password")) { |
|
28 | + if (@$this->command->option("password") == "AUTO" || !@$this->command->option("password")) { |
|
29 | 29 | $password = Str::random(16); |
30 | - }else{ |
|
30 | + } else { |
|
31 | 31 | $password = $this->command->option("password"); |
32 | 32 | } |
33 | 33 | |
34 | - if(@$this->command->option("username") == "AUTO" || !@$this->command->option("username")) { |
|
34 | + if (@$this->command->option("username") == "AUTO" || !@$this->command->option("username")) { |
|
35 | 35 | $username = Str::random(5); |
36 | - }else{ |
|
36 | + } else { |
|
37 | 37 | $username = $this->command->option("username"); |
38 | 38 | } |
39 | 39 | } catch (\Exception $e) { |
@@ -27,13 +27,13 @@ |
||
27 | 27 | try { |
28 | 28 | if(@$this->command->option("password") == "AUTO" || !@$this->command->option("password")) { |
29 | 29 | $password = Str::random(16); |
30 | - }else{ |
|
30 | + } else{ |
|
31 | 31 | $password = $this->command->option("password"); |
32 | 32 | } |
33 | 33 | |
34 | 34 | if(@$this->command->option("username") == "AUTO" || !@$this->command->option("username")) { |
35 | 35 | $username = Str::random(5); |
36 | - }else{ |
|
36 | + } else{ |
|
37 | 37 | $username = $this->command->option("username"); |
38 | 38 | } |
39 | 39 | } catch (\Exception $e) { |
@@ -25,13 +25,13 @@ discard block |
||
25 | 25 | // Register views |
26 | 26 | $this->loadViewsFrom(__DIR__.'/views', 'crudbooster'); |
27 | 27 | $this->loadViewsFrom(__DIR__.'/types', 'types'); |
28 | - $this->loadTranslationsFrom(__DIR__."/localization","cb"); |
|
28 | + $this->loadTranslationsFrom(__DIR__."/localization", "cb"); |
|
29 | 29 | |
30 | 30 | // Publish the files |
31 | - $this->publishes([__DIR__.'/configs/crudbooster.php' => config_path('crudbooster.php')],'cb_config'); |
|
32 | - $this->publishes([__DIR__.'/database' => base_path('database')],'cb_migration'); |
|
33 | - $this->publishes([__DIR__.'/templates/CBHook.stub'=> app_path('Http/CBHook.php')],'cb_hook'); |
|
34 | - $this->publishes([__DIR__ . '/assets' =>public_path('cb_asset')],'cb_asset'); |
|
31 | + $this->publishes([__DIR__.'/configs/crudbooster.php' => config_path('crudbooster.php')], 'cb_config'); |
|
32 | + $this->publishes([__DIR__.'/database' => base_path('database')], 'cb_migration'); |
|
33 | + $this->publishes([__DIR__.'/templates/CBHook.stub'=> app_path('Http/CBHook.php')], 'cb_hook'); |
|
34 | + $this->publishes([__DIR__.'/assets' =>public_path('cb_asset')], 'cb_asset'); |
|
35 | 35 | |
36 | 36 | // Override Local FileSystem |
37 | 37 | Config::set("filesystems.disks.local.root", cbConfig("LOCAL_FILESYSTEM_PATH", public_path("storage"))); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | require __DIR__.'/helpers/Helper.php'; |
54 | 54 | |
55 | 55 | // Singletons |
56 | - $this->app->singleton('crudbooster', function () |
|
56 | + $this->app->singleton('crudbooster', function() |
|
57 | 57 | { |
58 | 58 | return true; |
59 | 59 | }); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | } |
72 | 72 | |
73 | 73 | // Merging configuration |
74 | - $this->mergeConfigFrom(__DIR__.'/configs/crudbooster.php','crudbooster'); |
|
74 | + $this->mergeConfigFrom(__DIR__.'/configs/crudbooster.php', 'crudbooster'); |
|
75 | 75 | |
76 | 76 | // Register additional library |
77 | 77 | $this->app->register('Intervention\Image\ImageServiceProvider'); |
@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | private function registerPlugin() |
84 | 84 | { |
85 | 85 | $views = scandir(app_path("CBPlugins")); |
86 | - foreach($views as $view) { |
|
87 | - if($view != "." && $view != "..") { |
|
86 | + foreach ($views as $view) { |
|
87 | + if ($view != "." && $view != "..") { |
|
88 | 88 | $basename = basename($view); |
89 | 89 | // register view |
90 | - $this->loadViewsFrom(app_path("CBPlugins".DIRECTORY_SEPARATOR.$basename.DIRECTORY_SEPARATOR."Views"),$basename); |
|
90 | + $this->loadViewsFrom(app_path("CBPlugins".DIRECTORY_SEPARATOR.$basename.DIRECTORY_SEPARATOR."Views"), $basename); |
|
91 | 91 | // register route |
92 | 92 | require app_path("CBPlugins".DIRECTORY_SEPARATOR.$basename.DIRECTORY_SEPARATOR."Routes".DIRECTORY_SEPARATOR."Route.php"); |
93 | 93 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | |
97 | 97 | private function registerTypeRoutes() { |
98 | 98 | $routes = rglob(__DIR__.DIRECTORY_SEPARATOR."types".DIRECTORY_SEPARATOR."Route.php"); |
99 | - foreach($routes as $route) { |
|
99 | + foreach ($routes as $route) { |
|
100 | 100 | require $route; |
101 | 101 | } |
102 | 102 | } |
@@ -15,26 +15,26 @@ discard block |
||
15 | 15 | |
16 | 16 | public static function has($key) |
17 | 17 | { |
18 | - if(file_exists(app_path("CBPlugins/".$key))) return true; |
|
18 | + if (file_exists(app_path("CBPlugins/".$key))) return true; |
|
19 | 19 | else return false; |
20 | 20 | } |
21 | 21 | |
22 | 22 | public static function isNeedUpgrade($pluginKey, $versionToCompare) |
23 | 23 | { |
24 | 24 | $pluginJson = json_decode(file_get_contents(app_path("CBPlugins/".$pluginKey."/plugin.json")), true); |
25 | - if($pluginJson) { |
|
26 | - return version_compare($pluginJson['version'], $versionToCompare,"!="); |
|
27 | - }else{ |
|
25 | + if ($pluginJson) { |
|
26 | + return version_compare($pluginJson['version'], $versionToCompare, "!="); |
|
27 | + } else { |
|
28 | 28 | return false; |
29 | 29 | } |
30 | 30 | } |
31 | 31 | |
32 | 32 | public static function registerDefaultRoute($dir) |
33 | 33 | { |
34 | - Route::group(['middleware' => ['web',\crocodicstudio\crudbooster\middlewares\CBDeveloper::class], |
|
34 | + Route::group(['middleware' => ['web', \crocodicstudio\crudbooster\middlewares\CBDeveloper::class], |
|
35 | 35 | 'prefix'=>"developer/".getSetting('developer_path'), |
36 | - 'namespace' => 'App\CBPlugins\\'.basename(dirname("./../".$dir)).'\Controllers'], function () use ($dir) { |
|
37 | - cb()->routeController("plugins/".basename(dirname("./../".$dir)),"\App\CBPlugins\\".basename(dirname("./../".$dir))."\Controllers\\".basename(dirname("./../".$dir))."Controller"); |
|
36 | + 'namespace' => 'App\CBPlugins\\'.basename(dirname("./../".$dir)).'\Controllers'], function() use ($dir) { |
|
37 | + cb()->routeController("plugins/".basename(dirname("./../".$dir)), "\App\CBPlugins\\".basename(dirname("./../".$dir))."\Controllers\\".basename(dirname("./../".$dir))."Controller"); |
|
38 | 38 | }); |
39 | 39 | } |
40 | 40 | |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | $plugins = scandir(app_path("CBPlugins")); |
44 | 44 | |
45 | 45 | $result = []; |
46 | - foreach($plugins as $plugin) { |
|
47 | - if($plugin != "." && $plugin != "..") { |
|
46 | + foreach ($plugins as $plugin) { |
|
47 | + if ($plugin != "." && $plugin != "..") { |
|
48 | 48 | $basename = basename($plugin); |
49 | 49 | $row = json_decode(file_get_contents(app_path("CBPlugins".DIRECTORY_SEPARATOR.$plugin.DIRECTORY_SEPARATOR."plugin.json")), true); |
50 | - if($row) { |
|
50 | + if ($row) { |
|
51 | 51 | $result[] = [ |
52 | 52 | "name"=>$row['name'], |
53 | 53 | "version"=>$row['version'], |
@@ -15,8 +15,11 @@ discard block |
||
15 | 15 | |
16 | 16 | public static function has($key) |
17 | 17 | { |
18 | - if(file_exists(app_path("CBPlugins/".$key))) return true; |
|
19 | - else return false; |
|
18 | + if(file_exists(app_path("CBPlugins/".$key))) { |
|
19 | + return true; |
|
20 | + } else { |
|
21 | + return false; |
|
22 | + } |
|
20 | 23 | } |
21 | 24 | |
22 | 25 | public static function isNeedUpgrade($pluginKey, $versionToCompare) |
@@ -24,7 +27,7 @@ discard block |
||
24 | 27 | $pluginJson = json_decode(file_get_contents(app_path("CBPlugins/".$pluginKey."/plugin.json")), true); |
25 | 28 | if($pluginJson) { |
26 | 29 | return version_compare($pluginJson['version'], $versionToCompare,"!="); |
27 | - }else{ |
|
30 | + } else{ |
|
28 | 31 | return false; |
29 | 32 | } |
30 | 33 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | public function getIndex() { |
19 | 19 | $data = []; |
20 | 20 | $data['page_title'] = "Dashboard"; |
21 | - return view('crudbooster::dev_layouts.modules.dashboard',$data); |
|
21 | + return view('crudbooster::dev_layouts.modules.dashboard', $data); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | public function postSkipTutorial() |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | public function getIndex() { |
26 | 26 | $data = []; |
27 | - return view($this->view.".index",$data); |
|
27 | + return view($this->view.".index", $data); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | public function postSave() |
@@ -38,6 +38,6 @@ discard block |
||
38 | 38 | "MAIL_ENCRYPTION"=>request("MAIL_ENCRYPTION") |
39 | 39 | ]); |
40 | 40 | |
41 | - return cb()->redirectBack("Mail configuration has been updated!","success"); |
|
41 | + return cb()->redirectBack("Mail configuration has been updated!", "success"); |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | \ No newline at end of file |
@@ -11,11 +11,11 @@ discard block |
||
11 | 11 | public function getIndex() { |
12 | 12 | $data = []; |
13 | 13 | $data['page_title'] = cbLang("profile"); |
14 | - return view('crudbooster::profile',$data); |
|
14 | + return view('crudbooster::profile', $data); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | public function postUpdate() { |
18 | - validator(request()->all(),[ |
|
18 | + validator(request()->all(), [ |
|
19 | 19 | 'name'=>'required|max:255|min:3', |
20 | 20 | 'email'=>'required|email', |
21 | 21 | 'photo'=>'image', |
@@ -26,20 +26,20 @@ discard block |
||
26 | 26 | $data = []; |
27 | 27 | $data['name'] = request('name'); |
28 | 28 | $data['email'] = request('email'); |
29 | - if(request('password')) { |
|
29 | + if (request('password')) { |
|
30 | 30 | $data['password'] = Hash::make(request('password')); |
31 | 31 | } |
32 | - if(request()->hasFile('photo')) { |
|
32 | + if (request()->hasFile('photo')) { |
|
33 | 33 | $data['photo'] = cb()->uploadFile('photo', true, 200, 200); |
34 | 34 | } |
35 | 35 | |
36 | 36 | DB::table("users")->where("id", auth()->id())->update($data); |
37 | - }catch (\Exception $e) { |
|
37 | + } catch (\Exception $e) { |
|
38 | 38 | Log::error($e); |
39 | - return cb()->redirectBack(cbLang("something_went_wrong"),"warning"); |
|
39 | + return cb()->redirectBack(cbLang("something_went_wrong"), "warning"); |
|
40 | 40 | } |
41 | 41 | |
42 | - return cb()->redirectBack("The profile data has been updated!","success"); |
|
42 | + return cb()->redirectBack("The profile data has been updated!", "success"); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | DB::table("users")->where("id", auth()->id())->update($data); |
37 | - }catch (\Exception $e) { |
|
37 | + } catch (\Exception $e) { |
|
38 | 38 | Log::error($e); |
39 | 39 | return cb()->redirectBack(cbLang("something_went_wrong"),"warning"); |
40 | 40 | } |
@@ -19,25 +19,25 @@ |
||
19 | 19 | } |
20 | 20 | |
21 | 21 | public function postLoginDeveloper() { |
22 | - try{ |
|
22 | + try { |
|
23 | 23 | cb()->validation([ |
24 | 24 | 'username'=>'required', |
25 | 25 | 'password'=>'required' |
26 | 26 | ]); |
27 | 27 | |
28 | - if(request('username') == getSetting('developer_username') |
|
28 | + if (request('username') == getSetting('developer_username') |
|
29 | 29 | && request('password') == getSetting("developer_password")) { |
30 | 30 | |
31 | 31 | session(['developer'=>getSetting('developer_username')]); |
32 | 32 | |
33 | 33 | return redirect(cb()->getDeveloperUrl()); |
34 | 34 | |
35 | - }else{ |
|
36 | - return cb()->redirectBack( cbLang("password_and_username_is_wrong")); |
|
35 | + } else { |
|
36 | + return cb()->redirectBack(cbLang("password_and_username_is_wrong")); |
|
37 | 37 | } |
38 | 38 | |
39 | - }catch (CBValidationException $e) { |
|
40 | - return cb()->redirect(cb()->getLoginUrl(),$e->getMessage(),'warning'); |
|
39 | + } catch (CBValidationException $e) { |
|
40 | + return cb()->redirect(cb()->getLoginUrl(), $e->getMessage(), 'warning'); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 |
@@ -32,11 +32,11 @@ |
||
32 | 32 | |
33 | 33 | return redirect(cb()->getDeveloperUrl()); |
34 | 34 | |
35 | - }else{ |
|
35 | + } else{ |
|
36 | 36 | return cb()->redirectBack( cbLang("password_and_username_is_wrong")); |
37 | 37 | } |
38 | 38 | |
39 | - }catch (CBValidationException $e) { |
|
39 | + } catch (CBValidationException $e) { |
|
40 | 40 | return cb()->redirect(cb()->getLoginUrl(),$e->getMessage(),'warning'); |
41 | 41 | } |
42 | 42 | } |
@@ -33,7 +33,9 @@ discard block |
||
33 | 33 | |
34 | 34 | public function getLogin() |
35 | 35 | { |
36 | - if(!auth()->guest()) return redirect(cb()->getAdminUrl()); |
|
36 | + if(!auth()->guest()) { |
|
37 | + return redirect(cb()->getAdminUrl()); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | cbHook()->hookGetLogin(); |
39 | 41 | |
@@ -43,7 +45,9 @@ discard block |
||
43 | 45 | public function postLogin() |
44 | 46 | { |
45 | 47 | try{ |
46 | - if($this->isSuspendedLogin()) throw new CBValidationException(cbLang("you_have_been_suspended")); |
|
48 | + if($this->isSuspendedLogin()) { |
|
49 | + throw new CBValidationException(cbLang("you_have_been_suspended")); |
|
50 | + } |
|
47 | 51 | |
48 | 52 | cb()->validation([ |
49 | 53 | 'email'=>'required|email', |
@@ -58,7 +62,7 @@ discard block |
||
58 | 62 | $this->incrementFailedLogin(); |
59 | 63 | return redirect(cb()->getLoginUrl())->with(['message'=>cbLang('password_and_username_is_wrong'),'message_type'=>'warning']); |
60 | 64 | } |
61 | - }catch (CBValidationException $e) { |
|
65 | + } catch (CBValidationException $e) { |
|
62 | 66 | return cb()->redirect(cb()->getAdminUrl("login"),$e->getMessage(),'warning'); |
63 | 67 | } |
64 | 68 | } |
@@ -20,29 +20,29 @@ discard block |
||
20 | 20 | |
21 | 21 | public function getLogin() |
22 | 22 | { |
23 | - if(!auth()->guest()) return redirect(cb()->getAdminUrl()); |
|
23 | + if (!auth()->guest()) return redirect(cb()->getAdminUrl()); |
|
24 | 24 | |
25 | 25 | cbHook()->hookGetLogin(); |
26 | 26 | |
27 | 27 | $data = []; |
28 | - $data['no1'] = rand(1,10); |
|
29 | - $data['no2'] = rand(1,10); |
|
30 | - Session::put("captcha_result", $data['no1']+$data['no2']); |
|
28 | + $data['no1'] = rand(1, 10); |
|
29 | + $data['no2'] = rand(1, 10); |
|
30 | + Session::put("captcha_result", $data['no1'] + $data['no2']); |
|
31 | 31 | |
32 | - return view( str_replace(".blade.php", "", getSetting('login_page_view','crudbooster::login')), $data ); |
|
32 | + return view(str_replace(".blade.php", "", getSetting('login_page_view', 'crudbooster::login')), $data); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public function postLogin() |
36 | 36 | { |
37 | - try{ |
|
38 | - if($this->isSuspendedLogin()) throw new CBValidationException(cbLang("you_have_been_suspended")); |
|
37 | + try { |
|
38 | + if ($this->isSuspendedLogin()) throw new CBValidationException(cbLang("you_have_been_suspended")); |
|
39 | 39 | |
40 | 40 | cb()->validation([ |
41 | 41 | 'email'=>'required|email', |
42 | 42 | 'password'=>'required' |
43 | 43 | ]); |
44 | 44 | |
45 | - $credential = request()->only(['email','password']); |
|
45 | + $credential = request()->only(['email', 'password']); |
|
46 | 46 | if (auth()->attempt($credential)) { |
47 | 47 | |
48 | 48 | // When login user success, clear suspend attempt |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | return redirect(cb()->getAdminUrl()); |
54 | 54 | } else { |
55 | 55 | $this->incrementFailedLogin(); |
56 | - return redirect(cb()->getLoginUrl())->with(['message'=>cbLang('password_and_username_is_wrong'),'message_type'=>'warning']); |
|
56 | + return redirect(cb()->getLoginUrl())->with(['message'=>cbLang('password_and_username_is_wrong'), 'message_type'=>'warning']); |
|
57 | 57 | } |
58 | - }catch (CBValidationException $e) { |
|
59 | - return cb()->redirect(cb()->getAdminUrl("login"),$e->getMessage(),'warning'); |
|
58 | + } catch (CBValidationException $e) { |
|
59 | + return cb()->redirect(cb()->getAdminUrl("login"), $e->getMessage(), 'warning'); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 |