@@ -18,15 +18,15 @@ |
||
| 18 | 18 | try { |
| 19 | 19 | |
| 20 | 20 | cb()->validation([ |
| 21 | - 'userfile' => 'required|mimes:' . implode(",",config('crudbooster.UPLOAD_IMAGE_EXTENSION_ALLOWED')) |
|
| 21 | + 'userfile' => 'required|mimes:'.implode(",", config('crudbooster.UPLOAD_IMAGE_EXTENSION_ALLOWED')) |
|
| 22 | 22 | ]); |
| 23 | 23 | |
| 24 | - $file = cb()->uploadFile('userfile', request("encrypt")?true:false, request("resize_width"), request("resize_height")); |
|
| 24 | + $file = cb()->uploadFile('userfile', request("encrypt") ?true:false, request("resize_width"), request("resize_height")); |
|
| 25 | 25 | |
| 26 | 26 | } catch (CBValidationException $e) { |
| 27 | - return response()->json(['status'=>false,'message'=>$e->getMessage()]); |
|
| 27 | + return response()->json(['status'=>false, 'message'=>$e->getMessage()]); |
|
| 28 | 28 | } catch (\Exception $e) { |
| 29 | - return response()->json(['status'=>false,'message'=>$e->getMessage()]); |
|
| 29 | + return response()->json(['status'=>false, 'message'=>$e->getMessage()]); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | return response()->json([ |
@@ -1,9 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -cb()->routeGroupBackend(function () { |
|
| 4 | - cb()->routePost("upload-image",'\crocodicstudio\crudbooster\types\image\ImageController@postUploadImage'); |
|
| 3 | +cb()->routeGroupBackend(function() { |
|
| 4 | + cb()->routePost("upload-image", '\crocodicstudio\crudbooster\types\image\ImageController@postUploadImage'); |
|
| 5 | 5 | }); |
| 6 | 6 | |
| 7 | -cb()->routeGroupDeveloper(function () { |
|
| 8 | - cb()->routePost("upload-image",'\crocodicstudio\crudbooster\types\image\ImageController@postUploadImage'); |
|
| 7 | +cb()->routeGroupDeveloper(function() { |
|
| 8 | + cb()->routePost("upload-image", '\crocodicstudio\crudbooster\types\image\ImageController@postUploadImage'); |
|
| 9 | 9 | }); |
@@ -24,21 +24,21 @@ |
||
| 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() |
| 31 | 31 | { |
| 32 | - foreach(request()->except("_token") as $key=>$val) { |
|
| 33 | - putSetting( $key, $val); |
|
| 32 | + foreach (request()->except("_token") as $key=>$val) { |
|
| 33 | + putSetting($key, $val); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - if(request("login_background_cover")) { |
|
| 36 | + if (request("login_background_cover")) { |
|
| 37 | 37 | putSetting("login_background_cover", "on"); |
| 38 | 38 | } else { |
| 39 | 39 | putSetting("login_background_cover", ""); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - return cb()->redirectBack("Appearance has been updated!","success"); |
|
| 42 | + return cb()->redirectBack("Appearance has been updated!", "success"); |
|
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | \ No newline at end of file |
@@ -29,25 +29,25 @@ discard block |
||
| 29 | 29 | "captcha"=>"required|integer" |
| 30 | 30 | ]); |
| 31 | 31 | |
| 32 | - if(Session::get("captcha_result") != request("captcha")) { |
|
| 32 | + if (Session::get("captcha_result") != request("captcha")) { |
|
| 33 | 33 | return cb()->redirectBack("The captcha that you input is wrong!"); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - if($user = cb()->find("users",["email"=>request("email")])) { |
|
| 36 | + if ($user = cb()->find("users", ["email"=>request("email")])) { |
|
| 37 | 37 | return cb()->redirectBack("The email you input has already exists!"); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - if(getSetting("register_mail_verification")) { |
|
| 41 | - Cache::put("register_".$token,[ |
|
| 40 | + if (getSetting("register_mail_verification")) { |
|
| 41 | + Cache::put("register_".$token, [ |
|
| 42 | 42 | "name"=>request("name"), |
| 43 | 43 | "email"=>request("email"), |
| 44 | 44 | "password"=>request("password") |
| 45 | - ],now()->addHours(24)); |
|
| 45 | + ], now()->addHours(24)); |
|
| 46 | 46 | |
| 47 | 47 | $mail = new MailHelper(); |
| 48 | 48 | $mail->to(request("email")); |
| 49 | - $mail->sender(getSetting("register_mail_verification_sender","noreply@".$_SERVER['SERVER_NAME']),cb()->getAppName()); |
|
| 50 | - $mail->content("Verify Your Registration"," |
|
| 49 | + $mail->sender(getSetting("register_mail_verification_sender", "noreply@".$_SERVER['SERVER_NAME']), cb()->getAppName()); |
|
| 50 | + $mail->content("Verify Your Registration", " |
|
| 51 | 51 | Hi ".request("name")."<br/> |
| 52 | 52 | Thank you for register at ".cb()->getAppName()." to continue your registration, please click on the following link: <br/> |
| 53 | 53 | <p>$linkToken</p> |
@@ -66,18 +66,18 @@ discard block |
||
| 66 | 66 | "cb_roles_id"=> getSetting("register_as_role") |
| 67 | 67 | ]); |
| 68 | 68 | |
| 69 | - return cb()->redirect(cb()->getAdminUrl("login"),"Thank you for register. Now you can login to start your session :)","success"); |
|
| 69 | + return cb()->redirect(cb()->getAdminUrl("login"), "Thank you for register. Now you can login to start your session :)", "success"); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - }catch (CBValidationException $e) { |
|
| 72 | + } catch (CBValidationException $e) { |
|
| 73 | 73 | return cb()->redirectBack($e->getMessage()); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - return cb()->redirectBack("We've sent you an confirmation email. Please click the link inside the email","success"); |
|
| 76 | + return cb()->redirectBack("We've sent you an confirmation email. Please click the link inside the email", "success"); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | public function postContinueRegister($token) { |
| 80 | - if($token = Cache::get("register_".$token)) { |
|
| 80 | + if ($token = Cache::get("register_".$token)) { |
|
| 81 | 81 | DB::table("users") |
| 82 | 82 | ->insert([ |
| 83 | 83 | "created_at"=>date("Y-m-d H:i:s"), |
@@ -87,9 +87,9 @@ discard block |
||
| 87 | 87 | "cb_roles_id"=> getSetting("register_as_role") |
| 88 | 88 | ]); |
| 89 | 89 | |
| 90 | - return cb()->redirect(cb()->getAdminUrl("login"),"Thank you for register. Now you can login to start your session :)","success"); |
|
| 90 | + return cb()->redirect(cb()->getAdminUrl("login"), "Thank you for register. Now you can login to start your session :)", "success"); |
|
| 91 | 91 | } else { |
| 92 | - return cb()->redirect(cb()->getAdminUrl("login"),"It looks like the URL has been expired!"); |
|
| 92 | + return cb()->redirect(cb()->getAdminUrl("login"), "It looks like the URL has been expired!"); |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
@@ -69,7 +69,7 @@ |
||
| 69 | 69 | return cb()->redirect(cb()->getAdminUrl("login"),"Thank you for register. Now you can login to start your session :)","success"); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - }catch (CBValidationException $e) { |
|
| 72 | + } catch (CBValidationException $e) { |
|
| 73 | 73 | return cb()->redirectBack($e->getMessage()); |
| 74 | 74 | } |
| 75 | 75 | |
@@ -28,11 +28,11 @@ |
||
| 28 | 28 | { |
| 29 | 29 | $key = md5(request()->ip().request()->userAgent()); |
| 30 | 30 | |
| 31 | - if(Cache::has("loginSuspended".$key)) { |
|
| 31 | + if (Cache::has("loginSuspended".$key)) { |
|
| 32 | 32 | return true; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - if(getSetting("AUTO_SUSPEND_LOGIN") && Cache::get("loginFailed".$key) >= getSetting("AUTO_SUSPEND_LOGIN")) { |
|
| 35 | + if (getSetting("AUTO_SUSPEND_LOGIN") && Cache::get("loginFailed".$key) >= getSetting("AUTO_SUSPEND_LOGIN")) { |
|
| 36 | 36 | Cache::put("loginSuspended".$key, true, 30); |
| 37 | 37 | $this->clearSuspendAttempt(); |
| 38 | 38 | return true; |
@@ -24,19 +24,19 @@ |
||
| 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() |
| 31 | 31 | { |
| 32 | - foreach(request()->except("_token") as $key=>$val) { |
|
| 33 | - putSetting( $key, $val); |
|
| 32 | + foreach (request()->except("_token") as $key=>$val) { |
|
| 33 | + putSetting($key, $val); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - putSetting("enable_register",request("enable_register")); |
|
| 36 | + putSetting("enable_register", request("enable_register")); |
|
| 37 | 37 | putSetting("enable_forget", request("enable_forget")); |
| 38 | 38 | putSetting("register_mail_verification", request("register_mail_verification")); |
| 39 | 39 | |
| 40 | - return cb()->redirectBack("Setting has been updated!","success"); |
|
| 40 | + return cb()->redirectBack("Setting has been updated!", "success"); |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | \ No newline at end of file |
@@ -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() |
@@ -39,15 +39,15 @@ discard block |
||
| 39 | 39 | putSetting("AUTO_REDIRECT_TO_LOGIN", request("AUTO_REDIRECT_TO_LOGIN")); |
| 40 | 40 | putSetting("LOGIN_NOTIFICATION", request("LOGIN_NOTIFICATION")); |
| 41 | 41 | |
| 42 | - if(request("htaccess_ServerSignature")) { |
|
| 42 | + if (request("htaccess_ServerSignature")) { |
|
| 43 | 43 | putHtaccess("ServerSignature Off"); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - if(request("htaccess_IndexIgnore")) { |
|
| 46 | + if (request("htaccess_IndexIgnore")) { |
|
| 47 | 47 | putHtaccess("IndexIgnore *"); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if(request("htaccess_dotAccess")) { |
|
| 50 | + if (request("htaccess_dotAccess")) { |
|
| 51 | 51 | putHtaccess(" |
| 52 | 52 | <FilesMatch \"^\.\"> |
| 53 | 53 | Order allow,deny |
@@ -55,11 +55,11 @@ discard block |
||
| 55 | 55 | </FilesMatch>"); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - if(request("htaccess_preventVendor")) { |
|
| 58 | + if (request("htaccess_preventVendor")) { |
|
| 59 | 59 | putHtaccess("RewriteRule ^(.*)/vendor/.*\.(php|rb|py)$ - [F,L,NC]"); |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | |
| 63 | - return cb()->redirectBack("Security has been updated!","success"); |
|
| 63 | + return cb()->redirectBack("Security has been updated!", "success"); |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | \ No newline at end of file |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | try { |
| 25 | 25 | cb()->validation(['email'=>'required|email']); |
| 26 | 26 | |
| 27 | - if($user = cb()->find("users",["email"=>request("email")])) { |
|
| 27 | + if ($user = cb()->find("users", ["email"=>request("email")])) { |
|
| 28 | 28 | $token = Str::random(6); |
| 29 | 29 | $linkToken = cb()->getAdminUrl("continue-reset/".$token); |
| 30 | 30 | Cache::put("forget_".$token, $user->id, now()->addHours(12)); |
@@ -37,8 +37,8 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | $mail = new MailHelper(); |
| 39 | 39 | $mail->to($user->email); |
| 40 | - $mail->sender(getSetting("forget_email_sender","noreply@".$_SERVER['SERVER_NAME']),cb()->getAppName()); |
|
| 41 | - $mail->content("Please Confirm Your Forgot Password"," |
|
| 40 | + $mail->sender(getSetting("forget_email_sender", "noreply@".$_SERVER['SERVER_NAME']), cb()->getAppName()); |
|
| 41 | + $mail->content("Please Confirm Your Forgot Password", " |
|
| 42 | 42 | Hi $user->name,<br/><br> |
| 43 | 43 | Someone with the detail bellow: <br/> |
| 44 | 44 | Time = ".now()->format("Y-m-d H:i:s")."<br/> |
@@ -58,28 +58,28 @@ discard block |
||
| 58 | 58 | return cb()->redirectBack("Your email is not registered"); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - }catch (CBValidationException $e) { |
|
| 61 | + } catch (CBValidationException $e) { |
|
| 62 | 62 | return cb()->redirectBack($e->getMessage()); |
| 63 | 63 | } catch (\Exception $e) { |
| 64 | 64 | Log::error($e); |
| 65 | 65 | return cb()->redirectBack(cbLang("something_went_wrong")); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - return cb()->redirectBack("We've sent you an email instruction. Please follow the instruction inside the email","success"); |
|
| 68 | + return cb()->redirectBack("We've sent you an email instruction. Please follow the instruction inside the email", "success"); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | public function getContinueReset($token) { |
| 72 | - if(Cache::has("forget_".$token)) { |
|
| 72 | + if (Cache::has("forget_".$token)) { |
|
| 73 | 73 | $id = Cache::get("forget_".$token); |
| 74 | 74 | $newPassword = Str::random(6); |
| 75 | 75 | cb()->update("users", $id, ["password"=>Hash::make($newPassword)]); |
| 76 | 76 | |
| 77 | - $user = cb()->find("users",$id); |
|
| 77 | + $user = cb()->find("users", $id); |
|
| 78 | 78 | |
| 79 | 79 | $mail = new MailHelper(); |
| 80 | 80 | $mail->to($user->email); |
| 81 | - $mail->sender(getSetting("forget_email_sender","noreply@".$_SERVER['SERVER_NAME']),cb()->getAppName()); |
|
| 82 | - $mail->content("This Is Your New Password"," |
|
| 81 | + $mail->sender(getSetting("forget_email_sender", "noreply@".$_SERVER['SERVER_NAME']), cb()->getAppName()); |
|
| 82 | + $mail->content("This Is Your New Password", " |
|
| 83 | 83 | Hi $user->name,<br/><br> |
| 84 | 84 | Thank you for confirming the request new password. Here is your new password: <br> |
| 85 | 85 | <h2>$newPassword</h2> |
@@ -90,9 +90,9 @@ discard block |
||
| 90 | 90 | "); |
| 91 | 91 | $mail->send(); |
| 92 | 92 | |
| 93 | - return cb()->redirect(cb()->getAdminUrl("login"),"We've sent you new password email. Please check at your mail inbox or spambox","success"); |
|
| 93 | + return cb()->redirect(cb()->getAdminUrl("login"), "We've sent you new password email. Please check at your mail inbox or spambox", "success"); |
|
| 94 | 94 | } else { |
| 95 | - return cb()->redirect(cb()->getAdminUrl("login"),"It looks like the url has been expired!"); |
|
| 95 | + return cb()->redirect(cb()->getAdminUrl("login"), "It looks like the url has been expired!"); |
|
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | |
@@ -58,7 +58,7 @@ |
||
| 58 | 58 | return cb()->redirectBack("Your email is not registered"); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - }catch (CBValidationException $e) { |
|
| 61 | + } catch (CBValidationException $e) { |
|
| 62 | 62 | return cb()->redirectBack($e->getMessage()); |
| 63 | 63 | } catch (\Exception $e) { |
| 64 | 64 | Log::error($e); |
@@ -27,14 +27,14 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | public function __call($method, $parameters) |
| 29 | 29 | { |
| 30 | - if($method == "getData") { |
|
| 30 | + if ($method == "getData") { |
|
| 31 | 31 | $key = $parameters[0]; |
| 32 | - if(isset($this->data[$key])) { |
|
| 32 | + if (isset($this->data[$key])) { |
|
| 33 | 33 | return $this->data[$key]; |
| 34 | - }else{ |
|
| 34 | + } else { |
|
| 35 | 35 | return null; |
| 36 | 36 | } |
| 37 | - }else{ |
|
| 37 | + } else { |
|
| 38 | 38 | return null; |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -48,13 +48,13 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | $query->addSelect($this->data['table'].'.'.cb()->pk($this->data['table']).' as primary_key'); |
| 50 | 50 | |
| 51 | - $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true; |
|
| 52 | - if($softDelete === true && Schema::hasColumn($this->data['table'],'deleted_at')) { |
|
| 51 | + $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true; |
|
| 52 | + if ($softDelete === true && Schema::hasColumn($this->data['table'], 'deleted_at')) { |
|
| 53 | 53 | $query->whereNull($this->data['table'].'.deleted_at'); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - if(isset($joins)) { |
|
| 57 | - foreach($joins as $join) |
|
| 56 | + if (isset($joins)) { |
|
| 57 | + foreach ($joins as $join) |
|
| 58 | 58 | { |
| 59 | 59 | $query->join($join['target_table'], |
| 60 | 60 | $join['target_table_primary'], |
@@ -64,14 +64,14 @@ discard block |
||
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - foreach($columns as $column) { |
|
| 67 | + foreach ($columns as $column) { |
|
| 68 | 68 | /** @var ColumnModel $column */ |
| 69 | - if($column->getType() != "custom") { |
|
| 70 | - if(strpos($column->getField(),".") === false) { |
|
| 71 | - if(Schema::hasColumn($this->data['table'], $column->getField())) { |
|
| 69 | + if ($column->getType() != "custom") { |
|
| 70 | + if (strpos($column->getField(), ".") === false) { |
|
| 71 | + if (Schema::hasColumn($this->data['table'], $column->getField())) { |
|
| 72 | 72 | $query->addSelect($this->data['table'].'.'.$column->getField()); |
| 73 | 73 | } |
| 74 | - }else{ |
|
| 74 | + } else { |
|
| 75 | 75 | $query->addSelect($column->getField()); |
| 76 | 76 | } |
| 77 | 77 | } |
@@ -79,20 +79,20 @@ discard block |
||
| 79 | 79 | $query = getTypeHook($column->getType())->query($query, $column); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if(request()->has('q')) |
|
| 82 | + if (request()->has('q')) |
|
| 83 | 83 | { |
| 84 | - if(isset($this->data['hook_search_query'])) { |
|
| 84 | + if (isset($this->data['hook_search_query'])) { |
|
| 85 | 85 | $query = call_user_func($this->data['hook_search_query'], $query); |
| 86 | - }else{ |
|
| 87 | - $query->where(function ($where) use ($columns) { |
|
| 86 | + } else { |
|
| 87 | + $query->where(function($where) use ($columns) { |
|
| 88 | 88 | /** |
| 89 | 89 | * @var $where Builder |
| 90 | 90 | */ |
| 91 | - foreach($columns as $column) |
|
| 91 | + foreach ($columns as $column) |
|
| 92 | 92 | { |
| 93 | - if(strpos($column->getField(),".") === false) { |
|
| 93 | + if (strpos($column->getField(), ".") === false) { |
|
| 94 | 94 | $field = $this->data['table'].'.'.$column->getField(); |
| 95 | - }else{ |
|
| 95 | + } else { |
|
| 96 | 96 | $field = $column->getField(); |
| 97 | 97 | } |
| 98 | 98 | $where->orWhere($field, 'like', '%'.request('q').'%'); |
@@ -103,21 +103,21 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | |
| 105 | 105 | // Callback From this Method |
| 106 | - if(isset($callback) && is_callable($callback)) { |
|
| 106 | + if (isset($callback) && is_callable($callback)) { |
|
| 107 | 107 | $query = call_user_func($callback, $query); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if(isset($this->data['hook_index_query']) && is_callable($this->data['hook_index_query'])) { |
|
| 110 | + if (isset($this->data['hook_index_query']) && is_callable($this->data['hook_index_query'])) { |
|
| 111 | 111 | $query = call_user_func($this->data['hook_index_query'], $query); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | |
| 115 | - if(request()->has(['order_by','order_sort'])) |
|
| 115 | + if (request()->has(['order_by', 'order_sort'])) |
|
| 116 | 116 | { |
| 117 | - if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) { |
|
| 117 | + if (in_array(request('order_by'), columnSingleton()->getColumnNameOnly())) { |
|
| 118 | 118 | $query->orderBy(request('order_by'), request('order_sort')); |
| 119 | 119 | } |
| 120 | - }else{ |
|
| 120 | + } else { |
|
| 121 | 121 | $query->orderBy($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), "desc"); |
| 122 | 122 | } |
| 123 | 123 | |
@@ -126,29 +126,29 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | public function getIndex() |
| 128 | 128 | { |
| 129 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 129 | + if (!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
| 130 | 130 | |
| 131 | 131 | $query = $this->repository(); |
| 132 | - $result = $query->paginate( request("limit")?:cbConfig("LIMIT_TABLE_DATA") ); |
|
| 132 | + $result = $query->paginate(request("limit") ?: cbConfig("LIMIT_TABLE_DATA")); |
|
| 133 | 133 | $data['result'] = $result; |
| 134 | 134 | |
| 135 | 135 | return view("crudbooster::module.index.index", array_merge($data, $this->data)); |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | public function getFilterBy($field, $value, $parentPath) { |
| 139 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 139 | + if (!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
| 140 | 140 | |
| 141 | - if(!verifyReferalUrl()) return cb()->redirect(cb()->getAdminUrl($parentPath),"The url you are trying visit is incorrect"); |
|
| 141 | + if (!verifyReferalUrl()) return cb()->redirect(cb()->getAdminUrl($parentPath), "The url you are trying visit is incorrect"); |
|
| 142 | 142 | |
| 143 | 143 | $query = $this->repository(); |
| 144 | 144 | |
| 145 | 145 | $query->where($field, $value); |
| 146 | 146 | |
| 147 | - $result = $query->paginate( request("limit")?:cbConfig("LIMIT_TABLE_DATA") ); |
|
| 147 | + $result = $query->paginate(request("limit") ?: cbConfig("LIMIT_TABLE_DATA")); |
|
| 148 | 148 | $data['result'] = $result; |
| 149 | 149 | |
| 150 | 150 | $additionalView = getReferalUrl("additional"); |
| 151 | - if($additionalView) { |
|
| 151 | + if ($additionalView) { |
|
| 152 | 152 | $data['additionalView'] = $additionalView; |
| 153 | 153 | } |
| 154 | 154 | |
@@ -161,29 +161,29 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | private function validation() |
| 163 | 163 | { |
| 164 | - if(isset($this->data['validation'])) { |
|
| 164 | + if (isset($this->data['validation'])) { |
|
| 165 | 165 | $validator = Validator::make(request()->all(), @$this->data['validation'], @$this->data['validation_messages']); |
| 166 | 166 | if ($validator->fails()) { |
| 167 | 167 | $message = $validator->messages(); |
| 168 | 168 | $message_all = $message->all(); |
| 169 | - throw new CBValidationException(implode(', ',$message_all)); |
|
| 169 | + throw new CBValidationException(implode(', ', $message_all)); |
|
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | public function getAdd() |
| 175 | 175 | { |
| 176 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 176 | + if (!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
| 177 | 177 | |
| 178 | 178 | $data = []; |
| 179 | 179 | $data['page_title'] = $this->data['page_title'].' : '.cbLang('add'); |
| 180 | 180 | $data['action_url'] = module()->addSaveURL(); |
| 181 | - return view('crudbooster::module.form.form',array_merge($data, $this->data)); |
|
| 181 | + return view('crudbooster::module.form.form', array_merge($data, $this->data)); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | public function postAddSave() |
| 185 | 185 | { |
| 186 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 186 | + if (!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
| 187 | 187 | |
| 188 | 188 | try { |
| 189 | 189 | $this->validation(); |
@@ -191,38 +191,38 @@ discard block |
||
| 191 | 191 | $data = columnSingleton()->getAssignmentData(); |
| 192 | 192 | |
| 193 | 193 | //Clear data from Primary Key |
| 194 | - unset($data[ cb()->pk($this->data['table']) ]); |
|
| 194 | + unset($data[cb()->pk($this->data['table'])]); |
|
| 195 | 195 | |
| 196 | - if(Schema::hasColumn($this->data['table'], 'created_at')) { |
|
| 196 | + if (Schema::hasColumn($this->data['table'], 'created_at')) { |
|
| 197 | 197 | $data['created_at'] = date('Y-m-d H:i:s'); |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - if(Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
| 200 | + if (Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
| 201 | 201 | $data['updated_at'] = date('Y-m-d H:i:s'); |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - if(isset($this->data['hook_before_insert']) && is_callable($this->data['hook_before_insert'])) { |
|
| 204 | + if (isset($this->data['hook_before_insert']) && is_callable($this->data['hook_before_insert'])) { |
|
| 205 | 205 | $data = call_user_func($this->data['hook_before_insert'], $data); |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | $id = DB::table($this->data['table'])->insertGetId($data); |
| 209 | 209 | |
| 210 | - if(isset($this->data['hook_after_insert']) && is_callable($this->data['hook_after_insert'])) { |
|
| 210 | + if (isset($this->data['hook_after_insert']) && is_callable($this->data['hook_after_insert'])) { |
|
| 211 | 211 | call_user_func($this->data['hook_after_insert'], $id); |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | } catch (CBValidationException $e) { |
| 215 | 215 | Log::debug($e); |
| 216 | - return cb()->redirectBack($e->getMessage(),'info'); |
|
| 216 | + return cb()->redirectBack($e->getMessage(), 'info'); |
|
| 217 | 217 | } catch (\Exception $e) { |
| 218 | 218 | Log::error($e); |
| 219 | - return cb()->redirectBack(cbLang("something_went_wrong"),'warning'); |
|
| 219 | + return cb()->redirectBack(cbLang("something_went_wrong"), 'warning'); |
|
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - if (Str::contains(request("submit"),cbLang("more"))) { |
|
| 222 | + if (Str::contains(request("submit"), cbLang("more"))) { |
|
| 223 | 223 | return cb()->redirect(module()->addURL(), cbLang("the_data_has_been_added"), 'success'); |
| 224 | 224 | } else { |
| 225 | - if(verifyReferalUrl()) { |
|
| 225 | + if (verifyReferalUrl()) { |
|
| 226 | 226 | return cb()->redirect(getReferalUrl("url"), cbLang("the_data_has_been_added"), 'success'); |
| 227 | 227 | } else { |
| 228 | 228 | return cb()->redirect(module()->url(), cbLang("the_data_has_been_added"), 'success'); |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | |
| 233 | 233 | public function getEdit($id) |
| 234 | 234 | { |
| 235 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 235 | + if (!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
| 236 | 236 | |
| 237 | 237 | $data = []; |
| 238 | 238 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | |
| 244 | 244 | public function postEditSave($id) |
| 245 | 245 | { |
| 246 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 246 | + if (!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
| 247 | 247 | |
| 248 | 248 | try { |
| 249 | 249 | $this->validation(); |
@@ -251,40 +251,40 @@ discard block |
||
| 251 | 251 | $data = columnSingleton()->getAssignmentData(); |
| 252 | 252 | |
| 253 | 253 | // Make sure the Primary Key is not included |
| 254 | - unset($data[ cb()->pk($this->data['table']) ]); |
|
| 254 | + unset($data[cb()->pk($this->data['table'])]); |
|
| 255 | 255 | |
| 256 | - if(Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
| 256 | + if (Schema::hasColumn($this->data['table'], 'updated_at')) { |
|
| 257 | 257 | $data['updated_at'] = date('Y-m-d H:i:s'); |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | unset($data['created_at']); |
| 261 | 261 | |
| 262 | - if(isset($this->data['hook_before_update']) && is_callable($this->data['hook_before_update'])) { |
|
| 262 | + if (isset($this->data['hook_before_update']) && is_callable($this->data['hook_before_update'])) { |
|
| 263 | 263 | $data = call_user_func($this->data['hook_before_update'], $id, $data); |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | cb()->update($this->data['table'], $id, $data); |
| 267 | 267 | |
| 268 | - if(isset($this->data['hook_after_update']) && is_callable($this->data['hook_after_update'])) { |
|
| 268 | + if (isset($this->data['hook_after_update']) && is_callable($this->data['hook_after_update'])) { |
|
| 269 | 269 | call_user_func($this->data['hook_after_update'], $id); |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | } catch (CBValidationException $e) { |
| 273 | 273 | Log::debug($e); |
| 274 | - return cb()->redirectBack($e->getMessage(),'info'); |
|
| 274 | + return cb()->redirectBack($e->getMessage(), 'info'); |
|
| 275 | 275 | } catch (\Exception $e) { |
| 276 | 276 | Log::error($e); |
| 277 | - return cb()->redirectBack(cbLang("something_went_wrong"),'warning'); |
|
| 277 | + return cb()->redirectBack(cbLang("something_went_wrong"), 'warning'); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | |
| 281 | 281 | if (Str::contains(request("submit"), cbLang("more"))) { |
| 282 | - return cb()->redirectBack( cbLang("the_data_has_been_updated"), 'success'); |
|
| 282 | + return cb()->redirectBack(cbLang("the_data_has_been_updated"), 'success'); |
|
| 283 | 283 | } else { |
| 284 | - if(verifyReferalUrl()) { |
|
| 285 | - return cb()->redirect(getReferalUrl("url"), cbLang("the_data_has_been_updated"), 'success'); |
|
| 284 | + if (verifyReferalUrl()) { |
|
| 285 | + return cb()->redirect(getReferalUrl("url"), cbLang("the_data_has_been_updated"), 'success'); |
|
| 286 | 286 | } else { |
| 287 | - return cb()->redirect(module()->url(), cbLang("the_data_has_been_updated"), 'success'); |
|
| 287 | + return cb()->redirect(module()->url(), cbLang("the_data_has_been_updated"), 'success'); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | } |
@@ -292,15 +292,15 @@ discard block |
||
| 292 | 292 | |
| 293 | 293 | public function getDelete($id) |
| 294 | 294 | { |
| 295 | - if(!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 295 | + if (!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
| 296 | 296 | |
| 297 | - if(isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
|
| 297 | + if (isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
|
| 298 | 298 | call_user_func($this->data['hook_before_delete'], $id); |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - $softDelete = isset($this->data['disable_soft_delete'])?$this->data['disable_soft_delete']:true; |
|
| 301 | + $softDelete = isset($this->data['disable_soft_delete']) ? $this->data['disable_soft_delete'] : true; |
|
| 302 | 302 | |
| 303 | - if ($softDelete === true && Schema::hasColumn($this->data['table'],'deleted_at')) { |
|
| 303 | + if ($softDelete === true && Schema::hasColumn($this->data['table'], 'deleted_at')) { |
|
| 304 | 304 | DB::table($this->data['table']) |
| 305 | 305 | ->where(getPrimaryKey($this->data['table']), $id) |
| 306 | 306 | ->update(['deleted_at' => date('Y-m-d H:i:s')]); |
@@ -310,16 +310,16 @@ discard block |
||
| 310 | 310 | ->delete(); |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | - if(isset($this->data['hook_after_delete']) && is_callable($this->data['hook_after_delete'])) { |
|
| 313 | + if (isset($this->data['hook_after_delete']) && is_callable($this->data['hook_after_delete'])) { |
|
| 314 | 314 | call_user_func($this->data['hook_after_delete'], $id); |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - return cb()->redirectBack( cbLang("the_data_has_been_deleted"), 'success'); |
|
| 317 | + return cb()->redirectBack(cbLang("the_data_has_been_deleted"), 'success'); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | public function getDetail($id) |
| 321 | 321 | { |
| 322 | - if(!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 322 | + if (!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(), cbLang("you_dont_have_privilege_to_this_area")); |
|
| 323 | 323 | |
| 324 | 324 | $data = []; |
| 325 | 325 | $data['row'] = $this->repository()->where($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), $id)->first(); |
@@ -31,10 +31,10 @@ discard block |
||
| 31 | 31 | $key = $parameters[0]; |
| 32 | 32 | if(isset($this->data[$key])) { |
| 33 | 33 | return $this->data[$key]; |
| 34 | - }else{ |
|
| 34 | + } else{ |
|
| 35 | 35 | return null; |
| 36 | 36 | } |
| 37 | - }else{ |
|
| 37 | + } else{ |
|
| 38 | 38 | return null; |
| 39 | 39 | } |
| 40 | 40 | } |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | if(Schema::hasColumn($this->data['table'], $column->getField())) { |
| 72 | 72 | $query->addSelect($this->data['table'].'.'.$column->getField()); |
| 73 | 73 | } |
| 74 | - }else{ |
|
| 74 | + } else{ |
|
| 75 | 75 | $query->addSelect($column->getField()); |
| 76 | 76 | } |
| 77 | 77 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | { |
| 84 | 84 | if(isset($this->data['hook_search_query'])) { |
| 85 | 85 | $query = call_user_func($this->data['hook_search_query'], $query); |
| 86 | - }else{ |
|
| 86 | + } else{ |
|
| 87 | 87 | $query->where(function ($where) use ($columns) { |
| 88 | 88 | /** |
| 89 | 89 | * @var $where Builder |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | { |
| 93 | 93 | if(strpos($column->getField(),".") === false) { |
| 94 | 94 | $field = $this->data['table'].'.'.$column->getField(); |
| 95 | - }else{ |
|
| 95 | + } else{ |
|
| 96 | 96 | $field = $column->getField(); |
| 97 | 97 | } |
| 98 | 98 | $where->orWhere($field, 'like', '%'.request('q').'%'); |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | if(in_array(request('order_by'),columnSingleton()->getColumnNameOnly())) { |
| 118 | 118 | $query->orderBy(request('order_by'), request('order_sort')); |
| 119 | 119 | } |
| 120 | - }else{ |
|
| 120 | + } else{ |
|
| 121 | 121 | $query->orderBy($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), "desc"); |
| 122 | 122 | } |
| 123 | 123 | |
@@ -126,7 +126,9 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | public function getIndex() |
| 128 | 128 | { |
| 129 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 129 | + if(!module()->canBrowse()) { |
|
| 130 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 131 | + } |
|
| 130 | 132 | |
| 131 | 133 | $query = $this->repository(); |
| 132 | 134 | $result = $query->paginate( request("limit")?:cbConfig("LIMIT_TABLE_DATA") ); |
@@ -136,9 +138,13 @@ discard block |
||
| 136 | 138 | } |
| 137 | 139 | |
| 138 | 140 | public function getFilterBy($field, $value, $parentPath) { |
| 139 | - if(!module()->canBrowse()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 141 | + if(!module()->canBrowse()) { |
|
| 142 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 143 | + } |
|
| 140 | 144 | |
| 141 | - if(!verifyReferalUrl()) return cb()->redirect(cb()->getAdminUrl($parentPath),"The url you are trying visit is incorrect"); |
|
| 145 | + if(!verifyReferalUrl()) { |
|
| 146 | + return cb()->redirect(cb()->getAdminUrl($parentPath),"The url you are trying visit is incorrect"); |
|
| 147 | + } |
|
| 142 | 148 | |
| 143 | 149 | $query = $this->repository(); |
| 144 | 150 | |
@@ -173,7 +179,9 @@ discard block |
||
| 173 | 179 | |
| 174 | 180 | public function getAdd() |
| 175 | 181 | { |
| 176 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 182 | + if(!module()->canCreate()) { |
|
| 183 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 184 | + } |
|
| 177 | 185 | |
| 178 | 186 | $data = []; |
| 179 | 187 | $data['page_title'] = $this->data['page_title'].' : '.cbLang('add'); |
@@ -183,7 +191,9 @@ discard block |
||
| 183 | 191 | |
| 184 | 192 | public function postAddSave() |
| 185 | 193 | { |
| 186 | - if(!module()->canCreate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 194 | + if(!module()->canCreate()) { |
|
| 195 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 196 | + } |
|
| 187 | 197 | |
| 188 | 198 | try { |
| 189 | 199 | $this->validation(); |
@@ -232,7 +242,9 @@ discard block |
||
| 232 | 242 | |
| 233 | 243 | public function getEdit($id) |
| 234 | 244 | { |
| 235 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 245 | + if(!module()->canUpdate()) { |
|
| 246 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 247 | + } |
|
| 236 | 248 | |
| 237 | 249 | $data = []; |
| 238 | 250 | $data['row'] = $this->repository()->where($this->data['table'].'.'.getPrimaryKey($this->data['table']), $id)->first(); |
@@ -243,7 +255,9 @@ discard block |
||
| 243 | 255 | |
| 244 | 256 | public function postEditSave($id) |
| 245 | 257 | { |
| 246 | - if(!module()->canUpdate()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 258 | + if(!module()->canUpdate()) { |
|
| 259 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 260 | + } |
|
| 247 | 261 | |
| 248 | 262 | try { |
| 249 | 263 | $this->validation(); |
@@ -292,7 +306,9 @@ discard block |
||
| 292 | 306 | |
| 293 | 307 | public function getDelete($id) |
| 294 | 308 | { |
| 295 | - if(!module()->canDelete()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 309 | + if(!module()->canDelete()) { |
|
| 310 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 311 | + } |
|
| 296 | 312 | |
| 297 | 313 | if(isset($this->data['hook_before_delete']) && is_callable($this->data['hook_before_delete'])) { |
| 298 | 314 | call_user_func($this->data['hook_before_delete'], $id); |
@@ -319,7 +335,9 @@ discard block |
||
| 319 | 335 | |
| 320 | 336 | public function getDetail($id) |
| 321 | 337 | { |
| 322 | - if(!module()->canRead()) return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 338 | + if(!module()->canRead()) { |
|
| 339 | + return cb()->redirect(cb()->getAdminUrl(),cbLang("you_dont_have_privilege_to_this_area")); |
|
| 340 | + } |
|
| 323 | 341 | |
| 324 | 342 | $data = []; |
| 325 | 343 | $data['row'] = $this->repository()->where($this->data['table'].'.'.cb()->findPrimaryKey($this->data['table']), $id)->first(); |