We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| @@ -4,30 +4,30 @@ | ||
| 4 | 4 | |
| 5 | 5 |  class CrudRequest extends FormRequest { | 
| 6 | 6 | |
| 7 | - /** | |
| 8 | - * Determine if the user is authorized to make this request. | |
| 9 | - * | |
| 10 | - * @return bool | |
| 11 | - */ | |
| 12 | - public function authorize() | |
| 13 | -	{ | |
| 14 | - // only allow creates if the user is logged in | |
| 15 | - return \Auth::check(); | |
| 16 | - } | |
| 7 | + /** | |
| 8 | + * Determine if the user is authorized to make this request. | |
| 9 | + * | |
| 10 | + * @return bool | |
| 11 | + */ | |
| 12 | + public function authorize() | |
| 13 | +    { | |
| 14 | + // only allow creates if the user is logged in | |
| 15 | + return \Auth::check(); | |
| 16 | + } | |
| 17 | 17 | |
| 18 | - /** | |
| 19 | - * Get the validation rules that apply to the request. | |
| 20 | - * | |
| 21 | - * @return array | |
| 22 | - */ | |
| 23 | - public function rules() | |
| 24 | -	{ | |
| 25 | - return [ | |
| 26 | - // 'name' => 'required|min:3|max:255' | |
| 27 | - ]; | |
| 28 | - } | |
| 18 | + /** | |
| 19 | + * Get the validation rules that apply to the request. | |
| 20 | + * | |
| 21 | + * @return array | |
| 22 | + */ | |
| 23 | + public function rules() | |
| 24 | +    { | |
| 25 | + return [ | |
| 26 | + // 'name' => 'required|min:3|max:255' | |
| 27 | + ]; | |
| 28 | + } | |
| 29 | 29 | |
| 30 | - // OPTIONAL OVERRIDE | |
| 30 | + // OPTIONAL OVERRIDE | |
| 31 | 31 | // public function forbiddenResponse() | 
| 32 | 32 |      // { | 
| 33 | 33 | // Optionally, send a custom response on authorize failure | 
| @@ -2,7 +2,7 @@ discard block | ||
| 2 | 2 | |
| 3 | 3 | return [ | 
| 4 | 4 | |
| 5 | - /* | |
| 5 | + /* | |
| 6 | 6 | |-------------------------------------------------------------------------- | 
| 7 | 7 | | Dick Crud Language Lines | 
| 8 | 8 | |-------------------------------------------------------------------------- | 
| @@ -13,77 +13,77 @@ discard block | ||
| 13 | 13 | | | 
| 14 | 14 | */ | 
| 15 | 15 | |
| 16 | - // Create form | |
| 17 | - 'add' => 'Add', | |
| 18 | - 'back_to_all' => 'Back to all ', | |
| 19 | - 'cancel' => 'Cancel', | |
| 20 | - 'add_a_new' => 'Add a new ', | |
| 16 | + // Create form | |
| 17 | + 'add' => 'Add', | |
| 18 | + 'back_to_all' => 'Back to all ', | |
| 19 | + 'cancel' => 'Cancel', | |
| 20 | + 'add_a_new' => 'Add a new ', | |
| 21 | 21 | |
| 22 | - // Create form - advanced options | |
| 23 | - 'after_saving' => "After saving", | |
| 24 | - 'go_to_the_table_view' => "go to the table view", | |
| 25 | - 'let_me_add_another_item' => "let me add another item", | |
| 26 | - 'edit_the_new_item' => "edit the new item", | |
| 22 | + // Create form - advanced options | |
| 23 | + 'after_saving' => "After saving", | |
| 24 | + 'go_to_the_table_view' => "go to the table view", | |
| 25 | + 'let_me_add_another_item' => "let me add another item", | |
| 26 | + 'edit_the_new_item' => "edit the new item", | |
| 27 | 27 | |
| 28 | - // Edit form | |
| 29 | - 'edit' => 'Edit', | |
| 30 | - 'save' => 'Save', | |
| 28 | + // Edit form | |
| 29 | + 'edit' => 'Edit', | |
| 30 | + 'save' => 'Save', | |
| 31 | 31 | |
| 32 | - // CRUD table view | |
| 33 | - 'all' => 'All ', | |
| 34 | - 'in_the_database' => 'in the database', | |
| 35 | - 'list' => 'List', | |
| 36 | - 'actions' => 'Actions', | |
| 37 | - 'preview' => 'Preview', | |
| 38 | - 'delete' => 'Delete', | |
| 32 | + // CRUD table view | |
| 33 | + 'all' => 'All ', | |
| 34 | + 'in_the_database' => 'in the database', | |
| 35 | + 'list' => 'List', | |
| 36 | + 'actions' => 'Actions', | |
| 37 | + 'preview' => 'Preview', | |
| 38 | + 'delete' => 'Delete', | |
| 39 | 39 | |
| 40 | - // Confirmation messages and bubbles | |
| 41 | - 'delete_confirm' => 'Are you sure you want to delete this item?', | |
| 42 | - 'delete_confirmation_title' => 'Item Deleted', | |
| 43 | - 'delete_confirmation_message' => 'The item has been deleted successfully.', | |
| 44 | - 'delete_confirmation_not_title' => 'NOT deleted', | |
| 45 | - 'delete_confirmation_not_message' => "There's been an error. Your item might not have been deleted.", | |
| 46 | - 'delete_confirmation_not_deleted_title' => 'Not deleted', | |
| 47 | - 'delete_confirmation_not_deleted_message' => 'Nothing happened. Your item is safe.', | |
| 40 | + // Confirmation messages and bubbles | |
| 41 | + 'delete_confirm' => 'Are you sure you want to delete this item?', | |
| 42 | + 'delete_confirmation_title' => 'Item Deleted', | |
| 43 | + 'delete_confirmation_message' => 'The item has been deleted successfully.', | |
| 44 | + 'delete_confirmation_not_title' => 'NOT deleted', | |
| 45 | + 'delete_confirmation_not_message' => "There's been an error. Your item might not have been deleted.", | |
| 46 | + 'delete_confirmation_not_deleted_title' => 'Not deleted', | |
| 47 | + 'delete_confirmation_not_deleted_message' => 'Nothing happened. Your item is safe.', | |
| 48 | 48 | |
| 49 | - // DataTables translation | |
| 50 | - "emptyTable" => "No data available in table", | |
| 51 | - "info" => "Showing _START_ to _END_ of _TOTAL_ entries", | |
| 52 | - "infoEmpty" => "Showing 0 to 0 of 0 entries", | |
| 53 | - "infoFiltered" => "(filtered from _MAX_ total entries)", | |
| 54 | - "infoPostFix" => "", | |
| 55 | - "thousands" => ",", | |
| 56 | - "lengthMenu" => "_MENU_ records per page", | |
| 57 | - "loadingRecords" => "Loading...", | |
| 58 | - "processing" => "Processing...", | |
| 59 | - "search" => "Search: ", | |
| 60 | - "zeroRecords" => "No matching records found", | |
| 61 | - "paginate" => [ | |
| 62 | - "first" => "First", | |
| 63 | - "last" => "Last", | |
| 64 | - "next" => "Next", | |
| 65 | - "previous" => "Previous" | |
| 66 | - ], | |
| 67 | - "aria" => [ | |
| 68 | - "sortAscending" => ": activate to sort column ascending", | |
| 69 | - "sortDescending" => ": activate to sort column descending" | |
| 70 | - ], | |
| 49 | + // DataTables translation | |
| 50 | + "emptyTable" => "No data available in table", | |
| 51 | + "info" => "Showing _START_ to _END_ of _TOTAL_ entries", | |
| 52 | + "infoEmpty" => "Showing 0 to 0 of 0 entries", | |
| 53 | + "infoFiltered" => "(filtered from _MAX_ total entries)", | |
| 54 | + "infoPostFix" => "", | |
| 55 | + "thousands" => ",", | |
| 56 | + "lengthMenu" => "_MENU_ records per page", | |
| 57 | + "loadingRecords" => "Loading...", | |
| 58 | + "processing" => "Processing...", | |
| 59 | + "search" => "Search: ", | |
| 60 | + "zeroRecords" => "No matching records found", | |
| 61 | + "paginate" => [ | |
| 62 | + "first" => "First", | |
| 63 | + "last" => "Last", | |
| 64 | + "next" => "Next", | |
| 65 | + "previous" => "Previous" | |
| 66 | + ], | |
| 67 | + "aria" => [ | |
| 68 | + "sortAscending" => ": activate to sort column ascending", | |
| 69 | + "sortDescending" => ": activate to sort column descending" | |
| 70 | + ], | |
| 71 | 71 | |
| 72 | - // global crud - errors | |
| 73 | - "unauthorized_access" => "Unauthorized access - you do not have the necessary permissions to see this page.", | |
| 72 | + // global crud - errors | |
| 73 | + "unauthorized_access" => "Unauthorized access - you do not have the necessary permissions to see this page.", | |
| 74 | 74 | |
| 75 | - // global crud - success / error notification bubbles | |
| 76 | - "insert_success" => "The item has been added successfully.", | |
| 77 | - "update_success" => "The item has been modified successfully.", | |
| 75 | + // global crud - success / error notification bubbles | |
| 76 | + "insert_success" => "The item has been added successfully.", | |
| 77 | + "update_success" => "The item has been modified successfully.", | |
| 78 | 78 | |
| 79 | - // CRUD reorder view | |
| 80 | - 'reorder' => 'Reorder', | |
| 81 | - 'reorder_text' => 'Use drag&drop to reorder.', | |
| 82 | - 'reorder_success_title' => 'Done', | |
| 83 | - 'reorder_success_message' => 'Your order has been saved.', | |
| 84 | - 'reorder_error_title' => 'Error', | |
| 85 | - 'reorder_error_message' => 'Your order has not been saved.', | |
| 79 | + // CRUD reorder view | |
| 80 | + 'reorder' => 'Reorder', | |
| 81 | + 'reorder_text' => 'Use drag&drop to reorder.', | |
| 82 | + 'reorder_success_title' => 'Done', | |
| 83 | + 'reorder_success_message' => 'Your order has been saved.', | |
| 84 | + 'reorder_error_title' => 'Error', | |
| 85 | + 'reorder_error_message' => 'Your order has not been saved.', | |
| 86 | 86 | |
| 87 | - 'rules_text' => "<strong>Notice: </strong> Do not translate words prefixed with colon (ex: ':number_of_items'). Those will be replaced automatically with a proper value. If translated, that stops working.", | |
| 87 | + 'rules_text' => "<strong>Notice: </strong> Do not translate words prefixed with colon (ex: ':number_of_items'). Those will be replaced automatically with a proper value. If translated, that stops working.", | |
| 88 | 88 | |
| 89 | 89 | ]; | 
| @@ -2,7 +2,7 @@ discard block | ||
| 2 | 2 | |
| 3 | 3 | return [ | 
| 4 | 4 | |
| 5 | - /* | |
| 5 | + /* | |
| 6 | 6 | |-------------------------------------------------------------------------- | 
| 7 | 7 | | Dick Crud Language Lines | 
| 8 | 8 | |-------------------------------------------------------------------------- | 
| @@ -13,66 +13,66 @@ discard block | ||
| 13 | 13 | | | 
| 14 | 14 | */ | 
| 15 | 15 | |
| 16 | - // Create form | |
| 17 | - 'add' => 'Adaugă', | |
| 18 | - 'back_to_all' => 'Înapoi la toate ', | |
| 19 | - 'cancel' => 'Anulează', | |
| 20 | - 'add_a_new' => 'Adaugă un nou ', | |
| 16 | + // Create form | |
| 17 | + 'add' => 'Adaugă', | |
| 18 | + 'back_to_all' => 'Înapoi la toate ', | |
| 19 | + 'cancel' => 'Anulează', | |
| 20 | + 'add_a_new' => 'Adaugă un nou ', | |
| 21 | 21 | |
| 22 | - // Create form - advanced options | |
| 23 | - 'after_saving' => "După salvare", | |
| 24 | - 'go_to_the_table_view' => "du-mă la toate intrările", | |
| 25 | - 'let_me_add_another_item' => "vreu să adaug o altă intrare", | |
| 26 | - 'edit_the_new_item' => "vreau să editez intrarea", | |
| 22 | + // Create form - advanced options | |
| 23 | + 'after_saving' => "După salvare", | |
| 24 | + 'go_to_the_table_view' => "du-mă la toate intrările", | |
| 25 | + 'let_me_add_another_item' => "vreu să adaug o altă intrare", | |
| 26 | + 'edit_the_new_item' => "vreau să editez intrarea", | |
| 27 | 27 | |
| 28 | - // Edit form | |
| 29 | - 'edit' => 'Editează', | |
| 30 | - 'save' => 'Salvează', | |
| 28 | + // Edit form | |
| 29 | + 'edit' => 'Editează', | |
| 30 | + 'save' => 'Salvează', | |
| 31 | 31 | |
| 32 | - // CRUD table view | |
| 33 | - 'all' => 'Toate ', | |
| 34 | - 'in_the_database' => 'din baza de date', | |
| 35 | - 'list' => 'Listă', | |
| 36 | - 'actions' => 'Operațiuni', | |
| 37 | - 'preview' => 'Previzualizează', | |
| 38 | - 'delete' => 'Șterge', | |
| 32 | + // CRUD table view | |
| 33 | + 'all' => 'Toate ', | |
| 34 | + 'in_the_database' => 'din baza de date', | |
| 35 | + 'list' => 'Listă', | |
| 36 | + 'actions' => 'Operațiuni', | |
| 37 | + 'preview' => 'Previzualizează', | |
| 38 | + 'delete' => 'Șterge', | |
| 39 | 39 | |
| 40 | - // Confirmation messages and bubbles | |
| 41 | - 'delete_confirm' => 'Ești sigur că vrei să ștergi această intrare?', | |
| 42 | - 'delete_confirmation_title' => 'Intrare ștearsă', | |
| 43 | - 'delete_confirmation_message' => 'Intrarea a fost ștearsă cu succes.', | |
| 44 | - 'delete_confirmation_not_title' => 'Eroare', | |
| 45 | - 'delete_confirmation_not_message' => "A avut loc o eroare. E posibil ca intrarea să nu fi fost ștearsă.", | |
| 46 | - 'delete_confirmation_not_deleted_title' => 'Intrarea nu a fost ștearsă', | |
| 47 | - 'delete_confirmation_not_deleted_message' => 'Nu am șters intrarea din baza de date.', | |
| 40 | + // Confirmation messages and bubbles | |
| 41 | + 'delete_confirm' => 'Ești sigur că vrei să ștergi această intrare?', | |
| 42 | + 'delete_confirmation_title' => 'Intrare ștearsă', | |
| 43 | + 'delete_confirmation_message' => 'Intrarea a fost ștearsă cu succes.', | |
| 44 | + 'delete_confirmation_not_title' => 'Eroare', | |
| 45 | + 'delete_confirmation_not_message' => "A avut loc o eroare. E posibil ca intrarea să nu fi fost ștearsă.", | |
| 46 | + 'delete_confirmation_not_deleted_title' => 'Intrarea nu a fost ștearsă', | |
| 47 | + 'delete_confirmation_not_deleted_message' => 'Nu am șters intrarea din baza de date.', | |
| 48 | 48 | |
| 49 | - // DataTables translation | |
| 50 | - "emptyTable" => "Nu există intrări în baza de date", | |
| 51 | - "info" => "Sunt afișate intrările _START_-_END_ din _TOTAL_", | |
| 52 | - "infoEmpty" => "Sunt afișate toate intrarile. Adică niciuna.", | |
| 53 | - "infoFiltered" => "(filtrate din _MAX_ intrări în total)", | |
| 54 | - "infoPostFix" => "", | |
| 55 | - "thousands" => ",", | |
| 56 | - "lengthMenu" => "_MENU_ intrări pe pagină", | |
| 57 | - "loadingRecords" => "Se încarcă...", | |
| 58 | - "processing" => "Se procesează...", | |
| 59 | - "search" => "Caută: ", | |
| 60 | - "zeroRecords" => "Nu au fost găsite intrări care să se potrivească", | |
| 61 | - "paginate" => [ | |
| 62 | - "first" => "Prima pagină", | |
| 63 | - "last" => "Ultima pagină", | |
| 64 | - "next" => "Pagina următoare", | |
| 65 | - "previous" => "Pagina anterioară" | |
| 66 | - ], | |
| 67 | - "aria" => [ | |
| 68 | - "sortAscending" => ": activează pentru a ordona ascendent coloana", | |
| 69 | - "sortDescending" => ": activează petnru a ordona descendent coloana" | |
| 70 | - ], | |
| 49 | + // DataTables translation | |
| 50 | + "emptyTable" => "Nu există intrări în baza de date", | |
| 51 | + "info" => "Sunt afișate intrările _START_-_END_ din _TOTAL_", | |
| 52 | + "infoEmpty" => "Sunt afișate toate intrarile. Adică niciuna.", | |
| 53 | + "infoFiltered" => "(filtrate din _MAX_ intrări în total)", | |
| 54 | + "infoPostFix" => "", | |
| 55 | + "thousands" => ",", | |
| 56 | + "lengthMenu" => "_MENU_ intrări pe pagină", | |
| 57 | + "loadingRecords" => "Se încarcă...", | |
| 58 | + "processing" => "Se procesează...", | |
| 59 | + "search" => "Caută: ", | |
| 60 | + "zeroRecords" => "Nu au fost găsite intrări care să se potrivească", | |
| 61 | + "paginate" => [ | |
| 62 | + "first" => "Prima pagină", | |
| 63 | + "last" => "Ultima pagină", | |
| 64 | + "next" => "Pagina următoare", | |
| 65 | + "previous" => "Pagina anterioară" | |
| 66 | + ], | |
| 67 | + "aria" => [ | |
| 68 | + "sortAscending" => ": activează pentru a ordona ascendent coloana", | |
| 69 | + "sortDescending" => ": activează petnru a ordona descendent coloana" | |
| 70 | + ], | |
| 71 | 71 | |
| 72 | - // global crud - errors | |
| 73 | - "unauthorized_access" => "Acces neautorizat - Nu ai permisiunea necesară pentru a accesa pagina.", | |
| 72 | + // global crud - errors | |
| 73 | + "unauthorized_access" => "Acces neautorizat - Nu ai permisiunea necesară pentru a accesa pagina.", | |
| 74 | 74 | |
| 75 | - // global crud - success / error notification bubbles | |
| 76 | - "insert_success" => "Intrarea a fost adăugată cu succes.", | |
| 77 | - "update_success" => "Intrarea a fost modificată cu succes.", | |
| 75 | + // global crud - success / error notification bubbles | |
| 76 | + "insert_success" => "Intrarea a fost adăugată cu succes.", | |
| 77 | + "update_success" => "Intrarea a fost modificată cu succes.", | |
| 78 | 78 | ]; | 
| @@ -71,8 +71,7 @@ | ||
| 71 | 71 |                              if ($results && $results->count()) { | 
| 72 | 72 | $results_array = $results->lists($column['attribute'], 'id'); | 
| 73 | 73 |                                  echo implode(', ', $results_array->toArray()); | 
| 74 | - } | |
| 75 | - else | |
| 74 | + } else | |
| 76 | 75 |                                  { | 
| 77 | 76 | echo '-'; | 
| 78 | 77 | } | 
| @@ -17,232 +17,232 @@ | ||
| 17 | 17 | |
| 18 | 18 |  class CrudController extends BaseController { | 
| 19 | 19 | |
| 20 | - use DispatchesJobs, ValidatesRequests; | |
| 21 | - | |
| 22 | - public $data = []; | |
| 23 | - public $crud; | |
| 24 | - | |
| 25 | - public function __construct() | |
| 26 | -	{ | |
| 27 | - $this->crud = new Crud(); | |
| 28 | - } | |
| 29 | - | |
| 30 | - /** | |
| 31 | - * Display all rows in the database for this entity. | |
| 32 | - * | |
| 33 | - * @return Response | |
| 34 | - */ | |
| 35 | - public function index() | |
| 36 | -	{ | |
| 37 | -		$this->crud->hasAccessOrFail('list'); | |
| 38 | - | |
| 39 | - $this->data['entries'] = $this->crud->getEntries(); | |
| 40 | - $this->data['crud'] = $this->crud; | |
| 41 | - $this->data['title'] = ucfirst($this->crud->entity_name_plural); | |
| 42 | - | |
| 43 | - // load the view from /resources/views/vendor/backpack/crud/ if it exists, otherwise load the one in the package | |
| 44 | -		return view('crud::list', $this->data); | |
| 45 | - } | |
| 46 | - | |
| 47 | - | |
| 48 | - /** | |
| 49 | - * Show the form for creating inserting a new row. | |
| 50 | - * | |
| 51 | - * @return Response | |
| 52 | - */ | |
| 53 | - public function create() | |
| 54 | -	{ | |
| 55 | -		$this->crud->hasAccessOrFail('create'); | |
| 56 | - | |
| 57 | - // prepare the fields you need to show | |
| 58 | - $this->data['crud'] = $this->crud; | |
| 59 | - $this->data['fields'] = $this->crud->getCreateFields(); | |
| 60 | -		$this->data['title'] = trans('backpack::crud.add').' '.$this->crud->entity_name; | |
| 61 | - | |
| 62 | - // load the view from /resources/views/vendor/backpack/crud/ if it exists, otherwise load the one in the package | |
| 63 | -		return view('crud::create', $this->data); | |
| 64 | - } | |
| 65 | - | |
| 66 | - | |
| 67 | - /** | |
| 68 | - * Store a newly created resource in the database. | |
| 69 | - * | |
| 70 | - * @param StoreRequest $request - type injection used for validation using Requests | |
| 71 | - * @return \Illuminate\Http\RedirectResponse | |
| 72 | - */ | |
| 73 | - public function storeCrud(StoreRequest $request = null) | |
| 74 | -	{ | |
| 75 | -		$this->crud->hasAccessOrFail('create'); | |
| 20 | + use DispatchesJobs, ValidatesRequests; | |
| 21 | + | |
| 22 | + public $data = []; | |
| 23 | + public $crud; | |
| 24 | + | |
| 25 | + public function __construct() | |
| 26 | +    { | |
| 27 | + $this->crud = new Crud(); | |
| 28 | + } | |
| 29 | + | |
| 30 | + /** | |
| 31 | + * Display all rows in the database for this entity. | |
| 32 | + * | |
| 33 | + * @return Response | |
| 34 | + */ | |
| 35 | + public function index() | |
| 36 | +    { | |
| 37 | +        $this->crud->hasAccessOrFail('list'); | |
| 38 | + | |
| 39 | + $this->data['entries'] = $this->crud->getEntries(); | |
| 40 | + $this->data['crud'] = $this->crud; | |
| 41 | + $this->data['title'] = ucfirst($this->crud->entity_name_plural); | |
| 42 | + | |
| 43 | + // load the view from /resources/views/vendor/backpack/crud/ if it exists, otherwise load the one in the package | |
| 44 | +        return view('crud::list', $this->data); | |
| 45 | + } | |
| 46 | + | |
| 47 | + | |
| 48 | + /** | |
| 49 | + * Show the form for creating inserting a new row. | |
| 50 | + * | |
| 51 | + * @return Response | |
| 52 | + */ | |
| 53 | + public function create() | |
| 54 | +    { | |
| 55 | +        $this->crud->hasAccessOrFail('create'); | |
| 56 | + | |
| 57 | + // prepare the fields you need to show | |
| 58 | + $this->data['crud'] = $this->crud; | |
| 59 | + $this->data['fields'] = $this->crud->getCreateFields(); | |
| 60 | +        $this->data['title'] = trans('backpack::crud.add').' '.$this->crud->entity_name; | |
| 61 | + | |
| 62 | + // load the view from /resources/views/vendor/backpack/crud/ if it exists, otherwise load the one in the package | |
| 63 | +        return view('crud::create', $this->data); | |
| 64 | + } | |
| 65 | + | |
| 66 | + | |
| 67 | + /** | |
| 68 | + * Store a newly created resource in the database. | |
| 69 | + * | |
| 70 | + * @param StoreRequest $request - type injection used for validation using Requests | |
| 71 | + * @return \Illuminate\Http\RedirectResponse | |
| 72 | + */ | |
| 73 | + public function storeCrud(StoreRequest $request = null) | |
| 74 | +    { | |
| 75 | +        $this->crud->hasAccessOrFail('create'); | |
| 76 | 76 | |
| 77 | 77 | |
| 78 | - // insert item in the db | |
| 79 | - $item = $this->crud->create(\Request::except(['redirect_after_save', 'password'])); | |
| 80 | - | |
| 81 | - | |
| 82 | - // show a success message | |
| 83 | -		\Alert::success(trans('backpack::crud.insert_success'))->flash(); | |
| 84 | - | |
| 85 | - // redirect the user where he chose to be redirected | |
| 86 | -		switch (\Request::input('redirect_after_save')) { | |
| 87 | - case 'current_item_edit': | |
| 88 | - return \Redirect::to($this->crud->route.'/'.$item->id.'/edit'); | |
| 89 | - | |
| 90 | - default: | |
| 91 | -				return \Redirect::to(\Request::input('redirect_after_save')); | |
| 92 | - } | |
| 93 | - } | |
| 94 | - | |
| 95 | - | |
| 96 | - /** | |
| 97 | - * Show the form for editing the specified resource. | |
| 98 | - * | |
| 99 | - * @param int $id | |
| 100 | - * @return Response | |
| 101 | - */ | |
| 102 | - public function edit($id) | |
| 103 | -	{ | |
| 104 | -		$this->crud->hasAccessOrFail('update'); | |
| 105 | - | |
| 106 | - // get the info for that entry | |
| 107 | - $this->data['entry'] = $this->crud->getEntry($id); | |
| 108 | - $this->data['crud'] = $this->crud; | |
| 109 | - $this->data['fields'] = $this->crud->getUpdateFields($id); | |
| 110 | -		$this->data['title'] = trans('backpack::crud.edit').' '.$this->crud->entity_name; | |
| 111 | - | |
| 112 | - $this->data['id'] = $id; | |
| 113 | - | |
| 114 | - // load the view from /resources/views/vendor/backpack/crud/ if it exists, otherwise load the one in the package | |
| 115 | -		return view('crud::edit', $this->data); | |
| 116 | - } | |
| 117 | - | |
| 118 | - | |
| 119 | - /** | |
| 120 | - * Update the specified resource in the database. | |
| 121 | - * | |
| 122 | - * @param UpdateRequest $request - type injection used for validation using Requests | |
| 123 | - * @return \Illuminate\Http\RedirectResponse | |
| 124 | - */ | |
| 125 | - public function updateCrud(UpdateRequest $request = null) | |
| 126 | -	{ | |
| 127 | -		$this->crud->hasAccessOrFail('update'); | |
| 128 | - | |
| 129 | - // update the row in the db | |
| 130 | - | |
| 131 | -		$this->crud->update(\Request::get('id'), \Request::except('redirect_after_save')); | |
| 132 | - | |
| 133 | - // show a success message | |
| 134 | -		\Alert::success(trans('backpack::crud.update_success'))->flash(); | |
| 135 | - | |
| 136 | - return \Redirect::to($this->crud->route); | |
| 137 | - } | |
| 138 | - | |
| 139 | - | |
| 140 | - /** | |
| 141 | - * Display the specified resource. | |
| 142 | - * | |
| 143 | - * @param int $id | |
| 144 | - * @return Response | |
| 145 | - */ | |
| 146 | - public function show($id) | |
| 147 | -	{ | |
| 148 | -		$this->crud->hasAccessOrFail('show'); | |
| 149 | - | |
| 150 | - // get the info for that entry | |
| 151 | - $this->data['entry'] = $this->crud->getEntry($id); | |
| 152 | - $this->data['crud'] = $this->crud; | |
| 153 | -		$this->data['title'] = trans('backpack::crud.preview').' '.$this->crud->entity_name; | |
| 154 | - | |
| 155 | - // load the view from /resources/views/vendor/backpack/crud/ if it exists, otherwise load the one in the package | |
| 156 | -		return view('crud::show', $this->data); | |
| 157 | - } | |
| 158 | - | |
| 159 | - | |
| 160 | - /** | |
| 161 | - * Remove the specified resource from storage. | |
| 162 | - * | |
| 163 | - * @param int $id | |
| 164 | - * @return string | |
| 165 | - */ | |
| 166 | - public function destroy($id) | |
| 167 | -	{ | |
| 168 | -		$this->crud->hasAccessOrFail('delete'); | |
| 169 | - return $this->crud->delete($id); | |
| 170 | - } | |
| 171 | - | |
| 172 | - | |
| 173 | - /** | |
| 174 | - * Reorder the items in the database using the Nested Set pattern. | |
| 175 | - * | |
| 176 | - * Database columns needed: id, parent_id, lft, rgt, depth, name/title | |
| 177 | - * | |
| 178 | - * @return Response | |
| 179 | - */ | |
| 180 | - public function reorder($lang = false) | |
| 181 | -	{ | |
| 182 | -		$this->crud->hasAccessOrFail('reorder'); | |
| 183 | - | |
| 184 | -		if (!$this->crud->isReorderEnabled()) { | |
| 185 | - abort(403, 'Reorder is disabled.'); | |
| 186 | - } | |
| 187 | - | |
| 188 | - if ($lang == false) | |
| 189 | -		{ | |
| 190 | - $lang = \Lang::locale(); | |
| 191 | - } | |
| 192 | - | |
| 193 | - // get all results for that entity | |
| 194 | - $this->data['entries'] = $this->crud->getEntries(); | |
| 195 | - $this->data['crud'] = $this->crud; | |
| 196 | -		$this->data['title'] = trans('backpack::crud.reorder').' '.$this->crud->entity_name; | |
| 197 | - | |
| 198 | - // load the view from /resources/views/vendor/backpack/crud/ if it exists, otherwise load the one in the package | |
| 199 | -		return view('crud::reorder', $this->data); | |
| 200 | - } | |
| 201 | - | |
| 202 | - | |
| 203 | - /** | |
| 204 | - * Save the new order, using the Nested Set pattern. | |
| 205 | - * | |
| 206 | - * Database columns needed: id, parent_id, lft, rgt, depth, name/title | |
| 207 | - * | |
| 208 | - * @return | |
| 209 | - */ | |
| 210 | - public function saveReorder() | |
| 211 | -	{ | |
| 212 | -		$this->crud->hasAccessOrFail('reorder'); | |
| 213 | - | |
| 214 | -		$all_entries = \Request::input('tree'); | |
| 215 | - | |
| 216 | -		if (count($all_entries)) { | |
| 217 | - $count = $this->crud->updateTreeOrder($all_entries); | |
| 218 | - } else | |
| 219 | -		{ | |
| 220 | - return false; | |
| 221 | - } | |
| 222 | - | |
| 223 | - return 'success for '.$count." items"; | |
| 224 | - } | |
| 225 | - | |
| 226 | - | |
| 227 | - /** | |
| 228 | - * Used with AJAX in the list view (datatables) to show extra information about that row that didn't fit in the table. | |
| 229 | - * It defaults to showing some dummy text. | |
| 230 | - * | |
| 231 | - * It's enabled by: | |
| 232 | - * - setting: $crud->details_row = true; | |
| 233 | -	 * - adding the details route for the entity; ex: Route::get('page/{id}/details', 'PageCrudController@showDetailsRow'); | |
| 234 | - * - adding a view with the following name to change what the row actually contains: app/resources/views/vendor/backpack/crud/details_row.blade.php | |
| 235 | - */ | |
| 236 | - public function showDetailsRow($id) | |
| 237 | -	{ | |
| 238 | -		$this->crud->hasAccessOrFail('details_row'); | |
| 239 | - | |
| 240 | - $this->data['entry'] = $this->crud->getEntry($id); | |
| 241 | - $this->data['crud'] = $this->crud; | |
| 242 | - | |
| 243 | - // load the view from /resources/views/vendor/backpack/crud/ if it exists, otherwise load the one in the package | |
| 244 | -		return view('crud::details_row', $this->data); | |
| 245 | - } | |
| 78 | + // insert item in the db | |
| 79 | + $item = $this->crud->create(\Request::except(['redirect_after_save', 'password'])); | |
| 80 | + | |
| 81 | + | |
| 82 | + // show a success message | |
| 83 | +        \Alert::success(trans('backpack::crud.insert_success'))->flash(); | |
| 84 | + | |
| 85 | + // redirect the user where he chose to be redirected | |
| 86 | +        switch (\Request::input('redirect_after_save')) { | |
| 87 | + case 'current_item_edit': | |
| 88 | + return \Redirect::to($this->crud->route.'/'.$item->id.'/edit'); | |
| 89 | + | |
| 90 | + default: | |
| 91 | +                return \Redirect::to(\Request::input('redirect_after_save')); | |
| 92 | + } | |
| 93 | + } | |
| 94 | + | |
| 95 | + | |
| 96 | + /** | |
| 97 | + * Show the form for editing the specified resource. | |
| 98 | + * | |
| 99 | + * @param int $id | |
| 100 | + * @return Response | |
| 101 | + */ | |
| 102 | + public function edit($id) | |
| 103 | +    { | |
| 104 | +        $this->crud->hasAccessOrFail('update'); | |
| 105 | + | |
| 106 | + // get the info for that entry | |
| 107 | + $this->data['entry'] = $this->crud->getEntry($id); | |
| 108 | + $this->data['crud'] = $this->crud; | |
| 109 | + $this->data['fields'] = $this->crud->getUpdateFields($id); | |
| 110 | +        $this->data['title'] = trans('backpack::crud.edit').' '.$this->crud->entity_name; | |
| 111 | + | |
| 112 | + $this->data['id'] = $id; | |
| 113 | + | |
| 114 | + // load the view from /resources/views/vendor/backpack/crud/ if it exists, otherwise load the one in the package | |
| 115 | +        return view('crud::edit', $this->data); | |
| 116 | + } | |
| 117 | + | |
| 118 | + | |
| 119 | + /** | |
| 120 | + * Update the specified resource in the database. | |
| 121 | + * | |
| 122 | + * @param UpdateRequest $request - type injection used for validation using Requests | |
| 123 | + * @return \Illuminate\Http\RedirectResponse | |
| 124 | + */ | |
| 125 | + public function updateCrud(UpdateRequest $request = null) | |
| 126 | +    { | |
| 127 | +        $this->crud->hasAccessOrFail('update'); | |
| 128 | + | |
| 129 | + // update the row in the db | |
| 130 | + | |
| 131 | +        $this->crud->update(\Request::get('id'), \Request::except('redirect_after_save')); | |
| 132 | + | |
| 133 | + // show a success message | |
| 134 | +        \Alert::success(trans('backpack::crud.update_success'))->flash(); | |
| 135 | + | |
| 136 | + return \Redirect::to($this->crud->route); | |
| 137 | + } | |
| 138 | + | |
| 139 | + | |
| 140 | + /** | |
| 141 | + * Display the specified resource. | |
| 142 | + * | |
| 143 | + * @param int $id | |
| 144 | + * @return Response | |
| 145 | + */ | |
| 146 | + public function show($id) | |
| 147 | +    { | |
| 148 | +        $this->crud->hasAccessOrFail('show'); | |
| 149 | + | |
| 150 | + // get the info for that entry | |
| 151 | + $this->data['entry'] = $this->crud->getEntry($id); | |
| 152 | + $this->data['crud'] = $this->crud; | |
| 153 | +        $this->data['title'] = trans('backpack::crud.preview').' '.$this->crud->entity_name; | |
| 154 | + | |
| 155 | + // load the view from /resources/views/vendor/backpack/crud/ if it exists, otherwise load the one in the package | |
| 156 | +        return view('crud::show', $this->data); | |
| 157 | + } | |
| 158 | + | |
| 159 | + | |
| 160 | + /** | |
| 161 | + * Remove the specified resource from storage. | |
| 162 | + * | |
| 163 | + * @param int $id | |
| 164 | + * @return string | |
| 165 | + */ | |
| 166 | + public function destroy($id) | |
| 167 | +    { | |
| 168 | +        $this->crud->hasAccessOrFail('delete'); | |
| 169 | + return $this->crud->delete($id); | |
| 170 | + } | |
| 171 | + | |
| 172 | + | |
| 173 | + /** | |
| 174 | + * Reorder the items in the database using the Nested Set pattern. | |
| 175 | + * | |
| 176 | + * Database columns needed: id, parent_id, lft, rgt, depth, name/title | |
| 177 | + * | |
| 178 | + * @return Response | |
| 179 | + */ | |
| 180 | + public function reorder($lang = false) | |
| 181 | +    { | |
| 182 | +        $this->crud->hasAccessOrFail('reorder'); | |
| 183 | + | |
| 184 | +        if (!$this->crud->isReorderEnabled()) { | |
| 185 | + abort(403, 'Reorder is disabled.'); | |
| 186 | + } | |
| 187 | + | |
| 188 | + if ($lang == false) | |
| 189 | +        { | |
| 190 | + $lang = \Lang::locale(); | |
| 191 | + } | |
| 192 | + | |
| 193 | + // get all results for that entity | |
| 194 | + $this->data['entries'] = $this->crud->getEntries(); | |
| 195 | + $this->data['crud'] = $this->crud; | |
| 196 | +        $this->data['title'] = trans('backpack::crud.reorder').' '.$this->crud->entity_name; | |
| 197 | + | |
| 198 | + // load the view from /resources/views/vendor/backpack/crud/ if it exists, otherwise load the one in the package | |
| 199 | +        return view('crud::reorder', $this->data); | |
| 200 | + } | |
| 201 | + | |
| 202 | + | |
| 203 | + /** | |
| 204 | + * Save the new order, using the Nested Set pattern. | |
| 205 | + * | |
| 206 | + * Database columns needed: id, parent_id, lft, rgt, depth, name/title | |
| 207 | + * | |
| 208 | + * @return | |
| 209 | + */ | |
| 210 | + public function saveReorder() | |
| 211 | +    { | |
| 212 | +        $this->crud->hasAccessOrFail('reorder'); | |
| 213 | + | |
| 214 | +        $all_entries = \Request::input('tree'); | |
| 215 | + | |
| 216 | +        if (count($all_entries)) { | |
| 217 | + $count = $this->crud->updateTreeOrder($all_entries); | |
| 218 | + } else | |
| 219 | +        { | |
| 220 | + return false; | |
| 221 | + } | |
| 222 | + | |
| 223 | + return 'success for '.$count." items"; | |
| 224 | + } | |
| 225 | + | |
| 226 | + | |
| 227 | + /** | |
| 228 | + * Used with AJAX in the list view (datatables) to show extra information about that row that didn't fit in the table. | |
| 229 | + * It defaults to showing some dummy text. | |
| 230 | + * | |
| 231 | + * It's enabled by: | |
| 232 | + * - setting: $crud->details_row = true; | |
| 233 | +     * - adding the details route for the entity; ex: Route::get('page/{id}/details', 'PageCrudController@showDetailsRow'); | |
| 234 | + * - adding a view with the following name to change what the row actually contains: app/resources/views/vendor/backpack/crud/details_row.blade.php | |
| 235 | + */ | |
| 236 | + public function showDetailsRow($id) | |
| 237 | +    { | |
| 238 | +        $this->crud->hasAccessOrFail('details_row'); | |
| 239 | + | |
| 240 | + $this->data['entry'] = $this->crud->getEntry($id); | |
| 241 | + $this->data['crud'] = $this->crud; | |
| 242 | + | |
| 243 | + // load the view from /resources/views/vendor/backpack/crud/ if it exists, otherwise load the one in the package | |
| 244 | +        return view('crud::details_row', $this->data); | |
| 245 | + } | |
| 246 | 246 | |
| 247 | 247 | |
| 248 | 248 | |
| @@ -11,17 +11,17 @@ discard block | ||
| 11 | 11 | |
| 12 | 12 |  class ExampleCrudController extends CrudController { | 
| 13 | 13 | |
| 14 | -	public function __construct() { | |
| 14 | +    public function __construct() { | |
| 15 | 15 | parent::__construct(); | 
| 16 | 16 | |
| 17 | - /* | |
| 17 | + /* | |
| 18 | 18 | |-------------------------------------------------------------------------- | 
| 19 | 19 | | API | 
| 20 | 20 | |-------------------------------------------------------------------------- | 
| 21 | 21 | */ | 
| 22 | 22 | |
| 23 | 23 | |
| 24 | - // USAGE LEVEL 1 - ALWAYS ================================================== LEVEL 1 | |
| 24 | + // USAGE LEVEL 1 - ALWAYS ================================================== LEVEL 1 | |
| 25 | 25 |          $this->crud->setModel("App\Models\Example"); | 
| 26 | 26 |          $this->crud->setRoute("admin/example"); | 
| 27 | 27 |          // $this->crud->setRouteName("admin.example"); | 
| @@ -33,45 +33,45 @@ discard block | ||
| 33 | 33 | |
| 34 | 34 | |
| 35 | 35 | |
| 36 | - // USAGE LEVEL 2 - OFTEN ================================================== LEVEL 2 | |
| 36 | + // USAGE LEVEL 2 - OFTEN ================================================== LEVEL 2 | |
| 37 | 37 | |
| 38 | 38 | |
| 39 | 39 | // ------ FIELDS (the last parameter is always the form - create/update/both) | 
| 40 | -	    // TODO: $this->crud->addField('name', $options, 'update/create/both'); | |
| 41 | - // TODO: $this->crud->addFields($array_of_arrays, 'update/create/both'); | |
| 42 | -	    // TODO: $this->crud->removeField('name', 'update/create/both'); | |
| 43 | - // TODO: $this->crud->removeFields($array_of_names, 'update/create/both'); | |
| 44 | -	    // TODO: $this->crud->replaceField('name', 'update/create/both'); | |
| 40 | +        // TODO: $this->crud->addField('name', $options, 'update/create/both'); | |
| 41 | + // TODO: $this->crud->addFields($array_of_arrays, 'update/create/both'); | |
| 42 | +        // TODO: $this->crud->removeField('name', 'update/create/both'); | |
| 43 | + // TODO: $this->crud->removeFields($array_of_names, 'update/create/both'); | |
| 44 | +        // TODO: $this->crud->replaceField('name', 'update/create/both'); | |
| 45 | 45 | |
| 46 | - // TODO: $this->crud->setRequiredFields(['field_1', 'field_2'], 'update/create/both'); | |
| 47 | -	    // TODO: $this->crud->setRequiredField('field_1', 'update/create/both'); | |
| 48 | - // TODO: $this->crud->getRequiredFields(); | |
| 46 | + // TODO: $this->crud->setRequiredFields(['field_1', 'field_2'], 'update/create/both'); | |
| 47 | +        // TODO: $this->crud->setRequiredField('field_1', 'update/create/both'); | |
| 48 | + // TODO: $this->crud->getRequiredFields(); | |
| 49 | 49 | |
| 50 | - // TODO: $this->crud->setFieldOrder(['field_1', 'field_2', 'field_3'], 'update/create/both'); | |
| 50 | + // TODO: $this->crud->setFieldOrder(['field_1', 'field_2', 'field_3'], 'update/create/both'); | |
| 51 | 51 | |
| 52 | 52 | |
| 53 | 53 | // ------ COLUMNS | 
| 54 | - // $this->crud->addColumn(); // add a single column, at the end of the stack | |
| 55 | - // $this->crud->addColumns(); // add multiple columns, at the end of the stack | |
| 56 | -	    // $this->crud->removeColumn('column_name'); // remove a column from the stack | |
| 57 | - // $this->crud->removeColumns(['column_name_1', 'column_name_2']); // remove an array of columns from the stack | |
| 58 | -	    // $this->crud->setColumnDetails('column_name', ['attribute' => 'value']); | |
| 59 | - // $this->crud->setColumnsDetails(['column_1', 'column_2'], ['attribute' => 'value']); | |
| 60 | - // TODO: $this->crud->setColumnOrder(['column_1', 'column_2', 'column_3']); | |
| 54 | + // $this->crud->addColumn(); // add a single column, at the end of the stack | |
| 55 | + // $this->crud->addColumns(); // add multiple columns, at the end of the stack | |
| 56 | +        // $this->crud->removeColumn('column_name'); // remove a column from the stack | |
| 57 | + // $this->crud->removeColumns(['column_name_1', 'column_name_2']); // remove an array of columns from the stack | |
| 58 | +        // $this->crud->setColumnDetails('column_name', ['attribute' => 'value']); | |
| 59 | + // $this->crud->setColumnsDetails(['column_1', 'column_2'], ['attribute' => 'value']); | |
| 60 | + // TODO: $this->crud->setColumnOrder(['column_1', 'column_2', 'column_3']); | |
| 61 | 61 | |
| 62 | 62 | |
| 63 | - // ------ FIELDS AND COLUMNS | |
| 64 | -	    // TODO: $this->crud->setLabel('column_name/field_name', 'New Label'); // changes label for columns, create&update fields | |
| 63 | + // ------ FIELDS AND COLUMNS | |
| 64 | +        // TODO: $this->crud->setLabel('column_name/field_name', 'New Label'); // changes label for columns, create&update fields | |
| 65 | 65 | |
| 66 | 66 | |
| 67 | 67 | // ------ ACCESS | 
| 68 | -	    // $this->crud->allowAccess('list'); | |
| 69 | - // $this->crud->allowAccess(['list', 'create', 'delete']); | |
| 70 | -	    // $this->crud->denyAccess('list'); | |
| 71 | - // $this->crud->denyAccess(['list', 'create', 'delete']); | |
| 68 | +        // $this->crud->allowAccess('list'); | |
| 69 | + // $this->crud->allowAccess(['list', 'create', 'delete']); | |
| 70 | +        // $this->crud->denyAccess('list'); | |
| 71 | + // $this->crud->denyAccess(['list', 'create', 'delete']); | |
| 72 | 72 | |
| 73 | -	    // $this->crud->hasAccess('add'); // returns true/false | |
| 74 | -	    // $this->crud->hasAccessOrFail('add'); // throws 403 error | |
| 73 | +        // $this->crud->hasAccess('add'); // returns true/false | |
| 74 | +        // $this->crud->hasAccessOrFail('add'); // throws 403 error | |
| 75 | 75 | |
| 76 | 76 | |
| 77 | 77 | // ------ REORDER | 
| @@ -83,7 +83,7 @@ discard block | ||
| 83 | 83 | |
| 84 | 84 | |
| 85 | 85 | // ------ DETAILS ROW | 
| 86 | - // $this->crud->enableDetailsRow(); | |
| 86 | + // $this->crud->enableDetailsRow(); | |
| 87 | 87 |          // NOTE: you also need to do allow access to the right users: $this->crud->allowAccess('details_row'); | 
| 88 | 88 | // NOTE: you also need to do overwrite the showDetailsRow($id) method in your EntityCrudController to show whatever you'd like in the details row OR overwrite the views/backpack/crud/details_row.blade.php | 
| 89 | 89 | |
| @@ -92,101 +92,101 @@ discard block | ||
| 92 | 92 | |
| 93 | 93 | // ------ ADVANCED QUERIES | 
| 94 | 94 |          // $this->crud->addClause('active'); | 
| 95 | -	    // $this->crud->addClause('type', 'car'); | |
| 96 | -	    // $this->crud->addClause('where', 'name', '==', 'car'); | |
| 97 | -	    // $this->crud->addClause('whereName', 'car'); | |
| 98 | -	    // $this->crud->addClause('whereHas', 'posts', function($query) { | |
| 99 | - // $query->activePosts(); | |
| 100 | - // }); | |
| 95 | +        // $this->crud->addClause('type', 'car'); | |
| 96 | +        // $this->crud->addClause('where', 'name', '==', 'car'); | |
| 97 | +        // $this->crud->addClause('whereName', 'car'); | |
| 98 | +        // $this->crud->addClause('whereHas', 'posts', function($query) { | |
| 99 | + // $query->activePosts(); | |
| 100 | + // }); | |
| 101 | 101 | // $this->crud->orderBy(); | 
| 102 | 102 | // $this->crud->groupBy(); | 
| 103 | 103 | // $this->crud->limit(); | 
| 104 | 104 | |
| 105 | 105 | |
| 106 | 106 | |
| 107 | - // USAGE LEVEL 3 - SOMETIMES ============================================== LEVEL 3 | |
| 107 | + // USAGE LEVEL 3 - SOMETIMES ============================================== LEVEL 3 | |
| 108 | 108 | |
| 109 | 109 | // TODO: $this->crud->setButtons(); // default includes edit and delete, with their name, icon, permission, link and class (btn-default) | 
| 110 | - // TODO: $this->crud->addButton(); | |
| 111 | - // TODO: $this->crud->removeButton(); | |
| 112 | - // TODO: $this->crud->replaceButton(); | |
| 110 | + // TODO: $this->crud->addButton(); | |
| 111 | + // TODO: $this->crud->removeButton(); | |
| 112 | + // TODO: $this->crud->replaceButton(); | |
| 113 | 113 | |
| 114 | 114 | |
| 115 | 115 | |
| 116 | - // USAGE LEVEL 4 - RARELY ================================================== LEVEL 4 | |
| 116 | + // USAGE LEVEL 4 - RARELY ================================================== LEVEL 4 | |
| 117 | 117 | |
| 118 | - // $this->crud->getEntry($entry_id); | |
| 119 | - // $this->crud->getEntries(); | |
| 118 | + // $this->crud->getEntry($entry_id); | |
| 119 | + // $this->crud->getEntries(); | |
| 120 | 120 | |
| 121 | -		// $this->crud->getFields('create/update/both'); | |
| 121 | +        // $this->crud->getFields('create/update/both'); | |
| 122 | 122 | |
| 123 | - // $this->crud->create($entry_request); | |
| 124 | - // $this->crud->update($entry_id, $entry_request); | |
| 125 | - // $this->crud->delete($entry_id); | |
| 123 | + // $this->crud->create($entry_request); | |
| 124 | + // $this->crud->update($entry_id, $entry_request); | |
| 125 | + // $this->crud->delete($entry_id); | |
| 126 | 126 | |
| 127 | 127 | |
| 128 | - // USAGE LEVEL 5 - ALMOST NEVER ============================================== LEVEL 5 | |
| 128 | + // USAGE LEVEL 5 - ALMOST NEVER ============================================== LEVEL 5 | |
| 129 | 129 | |
| 130 | - // $this->crud->updateTreeOrder($all_entries); | |
| 130 | + // $this->crud->updateTreeOrder($all_entries); | |
| 131 | 131 | |
| 132 | 132 | |
| 133 | 133 | |
| 134 | 134 | |
| 135 | 135 | // ------------------------ | 
| 136 | - // MEANWHILE THIS WILL WORK | |
| 137 | - // ------------------------ | |
| 136 | + // MEANWHILE THIS WILL WORK | |
| 137 | + // ------------------------ | |
| 138 | 138 | |
| 139 | 139 | |
| 140 | 140 | $this->crud->reorder = true; | 
| 141 | - $this->crud->reorder_label = "name"; | |
| 142 | - $this->crud->reorder_max_level = 3; | |
| 143 | - $this->crud->details_row = true; | |
| 144 | - // $this->crud->permissions = ['add', 'list', 'edit', 'delete', 'show']; | |
| 141 | + $this->crud->reorder_label = "name"; | |
| 142 | + $this->crud->reorder_max_level = 3; | |
| 143 | + $this->crud->details_row = true; | |
| 144 | + // $this->crud->permissions = ['add', 'list', 'edit', 'delete', 'show']; | |
| 145 | 145 | |
| 146 | 146 | $this->crud->columns = [ | 
| 147 | - [ | |
| 148 | - 'name' => 'name', | |
| 149 | - 'label' => "Example item text" | |
| 150 | - ], | |
| 151 | - [ | |
| 152 | - 'label' => "Parent", | |
| 153 | - 'type' => 'select', | |
| 154 | - 'name' => 'parent_id', | |
| 155 | - 'entity' => 'parent', | |
| 156 | - 'attribute' => 'name', | |
| 157 | - 'model' => "App\Models\Example" | |
| 158 | - ], | |
| 159 | - ]; | |
| 160 | - $this->crud->fields = [ | |
| 161 | - [ | |
| 162 | - 'name' => 'name', | |
| 163 | - 'label' => "Example item text" | |
| 164 | - ], | |
| 165 | - [ | |
| 166 | - 'label' => "Parent", | |
| 167 | - 'type' => 'select', | |
| 168 | - 'name' => 'parent_id', | |
| 169 | - 'entity' => 'parent', | |
| 170 | - 'attribute' => 'name', | |
| 171 | - 'model' => "App\Models\Example" | |
| 172 | - ], | |
| 173 | - [ | |
| 174 | - 'name' => 'type', | |
| 175 | - 'label' => "Type", | |
| 176 | - 'type' => 'page_or_link' | |
| 177 | - ], | |
| 178 | - ]; | |
| 147 | + [ | |
| 148 | + 'name' => 'name', | |
| 149 | + 'label' => "Example item text" | |
| 150 | + ], | |
| 151 | + [ | |
| 152 | + 'label' => "Parent", | |
| 153 | + 'type' => 'select', | |
| 154 | + 'name' => 'parent_id', | |
| 155 | + 'entity' => 'parent', | |
| 156 | + 'attribute' => 'name', | |
| 157 | + 'model' => "App\Models\Example" | |
| 158 | + ], | |
| 159 | + ]; | |
| 160 | + $this->crud->fields = [ | |
| 161 | + [ | |
| 162 | + 'name' => 'name', | |
| 163 | + 'label' => "Example item text" | |
| 164 | + ], | |
| 165 | + [ | |
| 166 | + 'label' => "Parent", | |
| 167 | + 'type' => 'select', | |
| 168 | + 'name' => 'parent_id', | |
| 169 | + 'entity' => 'parent', | |
| 170 | + 'attribute' => 'name', | |
| 171 | + 'model' => "App\Models\Example" | |
| 172 | + ], | |
| 173 | + [ | |
| 174 | + 'name' => 'type', | |
| 175 | + 'label' => "Type", | |
| 176 | + 'type' => 'page_or_link' | |
| 177 | + ], | |
| 178 | + ]; | |
| 179 | 179 | |
| 180 | 180 | } | 
| 181 | 181 | |
| 182 | - public function store(StoreRequest $request) | |
| 183 | -	{ | |
| 184 | - return parent::storeCrud(); | |
| 185 | - } | |
| 182 | + public function store(StoreRequest $request) | |
| 183 | +    { | |
| 184 | + return parent::storeCrud(); | |
| 185 | + } | |
| 186 | 186 | |
| 187 | - public function update(UpdateRequest $request) | |
| 188 | -	{ | |
| 189 | - return parent::updateCrud(); | |
| 190 | - } | |
| 187 | + public function update(UpdateRequest $request) | |
| 188 | +    { | |
| 189 | + return parent::updateCrud(); | |
| 190 | + } | |
| 191 | 191 | |
| 192 | 192 | } | 
| @@ -20,42 +20,42 @@ discard block | ||
| 20 | 20 | |
| 21 | 21 |  @section('content') | 
| 22 | 22 | <?php | 
| 23 | - function tree_element($entry, $key, $all_entries, $crud) | |
| 24 | -  { | |
| 23 | + function tree_element($entry, $key, $all_entries, $crud) | |
| 24 | +    { | |
| 25 | 25 |      if (!isset($entry->tree_element_shown)) { | 
| 26 | - // mark the element as shown | |
| 27 | - $all_entries[$key]->tree_element_shown = true; | |
| 28 | - $entry->tree_element_shown = true; | |
| 26 | + // mark the element as shown | |
| 27 | + $all_entries[$key]->tree_element_shown = true; | |
| 28 | + $entry->tree_element_shown = true; | |
| 29 | 29 | |
| 30 | - // show the tree element | |
| 31 | - echo '<li id="list_'.$entry->id.'">'; | |
| 32 | -      echo '<div><span class="disclose"><span></span></span>'.$entry->{$crud->reorder_label}.'</div>'; | |
| 30 | + // show the tree element | |
| 31 | + echo '<li id="list_'.$entry->id.'">'; | |
| 32 | +        echo '<div><span class="disclose"><span></span></span>'.$entry->{$crud->reorder_label}.'</div>'; | |
| 33 | 33 | |
| 34 | - // see if this element has any children | |
| 35 | - $children = []; | |
| 36 | -      foreach ($all_entries as $key => $subentry) { | |
| 34 | + // see if this element has any children | |
| 35 | + $children = []; | |
| 36 | +        foreach ($all_entries as $key => $subentry) { | |
| 37 | 37 |          if ($subentry->parent_id == $entry->id) { | 
| 38 | - $children[] = $subentry; | |
| 38 | + $children[] = $subentry; | |
| 39 | + } | |
| 39 | 40 | } | 
| 40 | - } | |
| 41 | 41 | |
| 42 | -      $children = collect($children)->sortBy('lft'); | |
| 42 | +        $children = collect($children)->sortBy('lft'); | |
| 43 | 43 | |
| 44 | - // if it does have children, show them | |
| 45 | -      if (count($children)) { | |
| 44 | + // if it does have children, show them | |
| 45 | +        if (count($children)) { | |
| 46 | 46 | echo '<ol>'; | 
| 47 | 47 |          foreach ($children as $key => $child) { | 
| 48 | - $children[$key] = tree_element($child, $child->id, $all_entries, $crud); | |
| 48 | + $children[$key] = tree_element($child, $child->id, $all_entries, $crud); | |
| 49 | 49 | } | 
| 50 | 50 | echo '</ol>'; | 
| 51 | - } | |
| 52 | - echo '</li>'; | |
| 51 | + } | |
| 52 | + echo '</li>'; | |
| 53 | 53 | } | 
| 54 | 54 | |
| 55 | 55 | return $entry; | 
| 56 | - } | |
| 56 | + } | |
| 57 | 57 | |
| 58 | - ?> | |
| 58 | + ?> | |
| 59 | 59 | <div class="row"> | 
| 60 | 60 | <div class="col-md-8 col-md-offset-2"> | 
| 61 | 61 |      @if ($crud->hasAccess('list')) | 
| @@ -87,15 +87,15 @@ discard block | ||
| 87 | 87 | |
| 88 | 88 | <ol class="sortable"> | 
| 89 | 89 | <?php | 
| 90 | -              $all_entries = collect($entries->all())->sortBy('lft')->keyBy('id'); | |
| 91 | -              $root_entries = $all_entries->filter(function($item) { | |
| 90 | +                $all_entries = collect($entries->all())->sortBy('lft')->keyBy('id'); | |
| 91 | +                $root_entries = $all_entries->filter(function($item) { | |
| 92 | 92 | return $item->parent_id == 0; | 
| 93 | - }); | |
| 94 | - ?> | |
| 93 | + }); | |
| 94 | + ?> | |
| 95 | 95 | @foreach ($root_entries as $key => $entry) | 
| 96 | 96 | <?php | 
| 97 | 97 | $root_entries[$key] = tree_element($entry, $key, $all_entries, $crud); | 
| 98 | - ?> | |
| 98 | + ?> | |
| 99 | 99 | @endforeach | 
| 100 | 100 | </ol> | 
| 101 | 101 | |
| @@ -45,7 +45,7 @@ | ||
| 45 | 45 | $secondary_ids[$second_item] = $second_item; | 
| 46 | 46 | } | 
| 47 | 47 | } | 
| 48 | -        }else{ //create dependecies from relation if not from validate error | |
| 48 | +        } else{ //create dependecies from relation if not from validate error | |
| 49 | 49 |            foreach( $primary_array as $primary_item ){ | 
| 50 | 50 |              foreach($primary_item[$secondary_dependency['entity']] as $second_item ){ | 
| 51 | 51 | $secondary_ids[$second_item['id']] = $second_item['id']; | 
| @@ -2,34 +2,34 @@ discard block | ||
| 2 | 2 |    <div class="form-group checklist_dependency"  data-entity ="{{ $field['field_unique_name'] }}"> | 
| 3 | 3 |      <label>{{ $field['label'] }}</label> | 
| 4 | 4 | <?php | 
| 5 | - $entity_model = $crud->getModel(); | |
| 5 | + $entity_model = $crud->getModel(); | |
| 6 | 6 | |
| 7 | - //short name for dependency fields | |
| 8 | - $primary_dependency = $field['subfields']['primary']; | |
| 9 | - $secondary_dependency = $field['subfields']['secondary']; | |
| 7 | + //short name for dependency fields | |
| 8 | + $primary_dependency = $field['subfields']['primary']; | |
| 9 | + $secondary_dependency = $field['subfields']['secondary']; | |
| 10 | 10 | |
| 11 | 11 | |
| 12 | - //all items with relation | |
| 13 | - $dependencies = $primary_dependency['model']::with($primary_dependency['entity_secondary'])->get(); | |
| 12 | + //all items with relation | |
| 13 | + $dependencies = $primary_dependency['model']::with($primary_dependency['entity_secondary'])->get(); | |
| 14 | 14 | |
| 15 | - $dependencyArray = []; | |
| 15 | + $dependencyArray = []; | |
| 16 | 16 | |
| 17 | - //convert dependency array to simple matrix ( prymary id as key and array with secondaries id ) | |
| 18 | -      foreach($dependencies as $primary){ | |
| 19 | - $dependencyArray[$primary->id] = []; | |
| 17 | + //convert dependency array to simple matrix ( prymary id as key and array with secondaries id ) | |
| 18 | +        foreach($dependencies as $primary){ | |
| 19 | + $dependencyArray[$primary->id] = []; | |
| 20 | 20 |          foreach($primary->{$primary_dependency['entity_secondary']} as $secondary){ | 
| 21 | 21 | $dependencyArray[$primary->id][] = $secondary->id; | 
| 22 | 22 | } | 
| 23 | - } | |
| 23 | + } | |
| 24 | 24 | |
| 25 | - //for update form, get initial state of the entity | |
| 26 | -      if( isset($id) && $id ){ | |
| 25 | + //for update form, get initial state of the entity | |
| 26 | +        if( isset($id) && $id ){ | |
| 27 | 27 | |
| 28 | 28 | //get entity with relations for primary dependency | 
| 29 | 29 | $entity_dependencies = $entity_model->with($primary_dependency['entity']) | 
| 30 | - ->with($primary_dependency['entity'].'.'.$primary_dependency['entity_secondary']) | |
| 31 | -          ->where('id', $id) | |
| 32 | - ->first(); | |
| 30 | + ->with($primary_dependency['entity'].'.'.$primary_dependency['entity_secondary']) | |
| 31 | +            ->where('id', $id) | |
| 32 | + ->first(); | |
| 33 | 33 | |
| 34 | 34 | $secondaries_from_primary = []; | 
| 35 | 35 | |
| @@ -40,23 +40,23 @@ discard block | ||
| 40 | 40 | |
| 41 | 41 | //create secondary dependency from primary relation, used to check what chekbox must be check from second checklist | 
| 42 | 42 |          if( old($primary_dependency['name']) ) { | 
| 43 | -          foreach( old($primary_dependency['name']) as $primary_item ){ | |
| 43 | +            foreach( old($primary_dependency['name']) as $primary_item ){ | |
| 44 | 44 |              foreach($dependencyArray[$primary_item] as $second_item ){ | 
| 45 | 45 | $secondary_ids[$second_item] = $second_item; | 
| 46 | 46 | } | 
| 47 | - } | |
| 47 | + } | |
| 48 | 48 |          }else{ //create dependecies from relation if not from validate error | 
| 49 | -          foreach( $primary_array as $primary_item ){ | |
| 49 | +            foreach( $primary_array as $primary_item ){ | |
| 50 | 50 |              foreach($primary_item[$secondary_dependency['entity']] as $second_item ){ | 
| 51 | 51 | $secondary_ids[$second_item['id']] = $second_item['id']; | 
| 52 | 52 | } | 
| 53 | - } | |
| 53 | + } | |
| 54 | 54 | } | 
| 55 | 55 | |
| 56 | - } | |
| 56 | + } | |
| 57 | 57 | |
| 58 | - //json encode of dependency matrix | |
| 59 | - $dependencyJson = json_encode($dependencyArray); | |
| 58 | + //json encode of dependency matrix | |
| 59 | + $dependencyJson = json_encode($dependencyArray); | |
| 60 | 60 | ?> | 
| 61 | 61 | <script> | 
| 62 | 62 |       var  {{ $field['field_unique_name'] }} = {!! $dependencyJson !!}; | 
| @@ -136,9 +136,9 @@ discard block | ||
| 136 | 136 | |
| 137 | 137 |                  if( isset($field['pivotFields']) ){ | 
| 138 | 138 |                      foreach($field['pivotFields'] as $pivotField){ | 
| 139 | -                       foreach($data[$pivotField] as $pivot_id =>  $field){ | |
| 140 | -                         $model->{$field['name']}()->updateExistingPivot($pivot_id, [$pivotField => $field]); | |
| 141 | - } | |
| 139 | +                        foreach($data[$pivotField] as $pivot_id =>  $field){ | |
| 140 | +                            $model->{$field['name']}()->updateExistingPivot($pivot_id, [$pivotField => $field]); | |
| 141 | + } | |
| 142 | 142 | } | 
| 143 | 143 | } | 
| 144 | 144 | } | 
| @@ -180,7 +180,7 @@ discard block | ||
| 180 | 180 | } | 
| 181 | 181 | |
| 182 | 182 | |
| 183 | - /* | |
| 183 | + /* | |
| 184 | 184 | |-------------------------------------------------------------------------- | 
| 185 | 185 | | READ | 
| 186 | 186 | |-------------------------------------------------------------------------- | 
| @@ -262,7 +262,7 @@ discard block | ||
| 262 | 262 | |
| 263 | 263 | |
| 264 | 264 | |
| 265 | - /* | |
| 265 | + /* | |
| 266 | 266 | |-------------------------------------------------------------------------- | 
| 267 | 267 | | UPDATE | 
| 268 | 268 | |-------------------------------------------------------------------------- | 
| @@ -327,7 +327,7 @@ discard block | ||
| 327 | 327 | |
| 328 | 328 | |
| 329 | 329 | |
| 330 | - /* | |
| 330 | + /* | |
| 331 | 331 | |-------------------------------------------------------------------------- | 
| 332 | 332 | | DELETE | 
| 333 | 333 | |-------------------------------------------------------------------------- | 
| @@ -418,7 +418,7 @@ discard block | ||
| 418 | 418 | |
| 419 | 419 | |
| 420 | 420 | |
| 421 | - /* | |
| 421 | + /* | |
| 422 | 422 | |-------------------------------------------------------------------------- | 
| 423 | 423 | | CRUD ACCESS | 
| 424 | 424 | |-------------------------------------------------------------------------- | 
| @@ -963,7 +963,7 @@ discard block | ||
| 963 | 963 | |
| 964 | 964 | if (!in_array($field, $this->model->getHidden())) | 
| 965 | 965 |              { | 
| 966 | - $this->columns[] = [ | |
| 966 | + $this->columns[] = [ | |
| 967 | 967 | 'name' => $field, | 
| 968 | 968 | 'label' => ucfirst($field), | 
| 969 | 969 | 'type' => $this->getFieldTypeFromDbColumnType($field) | 
| @@ -1340,10 +1340,10 @@ discard block | ||
| 1340 | 1340 | |
| 1341 | 1341 | public function addCreateField($field) | 
| 1342 | 1342 |      { | 
| 1343 | -       return $this->add('create_fields', $field); | |
| 1343 | +        return $this->add('create_fields', $field); | |
| 1344 | 1344 | } | 
| 1345 | 1345 | |
| 1346 | - public function setUpdateFields($fields) | |
| 1346 | + public function setUpdateFields($fields) | |
| 1347 | 1347 |      { | 
| 1348 | 1348 |          $this->addMultiple('update_fields', $fields); | 
| 1349 | 1349 | } | 
| @@ -93,8 +93,7 @@ discard block | ||
| 93 | 93 | if ($form == 'create') | 
| 94 | 94 |          { | 
| 95 | 95 | $fields = $this->create_fields; | 
| 96 | - } | |
| 97 | - else | |
| 96 | + } else | |
| 98 | 97 |          { | 
| 99 | 98 | $fields = $this->update_fields; | 
| 100 | 99 | } | 
| @@ -308,7 +307,7 @@ discard block | ||
| 308 | 307 |                          $fields[$k]['value'][] = $entry->{$subfield['name']}; | 
| 309 | 308 | } | 
| 310 | 309 | |
| 311 | -                }else{ | |
| 310 | +                } else{ | |
| 312 | 311 |                      $fields[$k]['value'] = $entry->{$field['name']}; | 
| 313 | 312 | } | 
| 314 | 313 | } | 
| @@ -487,7 +486,9 @@ discard block | ||
| 487 | 486 | */ | 
| 488 | 487 | public function setModel($model_namespace) | 
| 489 | 488 |      { | 
| 490 | -        if (!class_exists($model_namespace)) throw new \Exception('This model does not exist.', 404); | |
| 489 | +        if (!class_exists($model_namespace)) { | |
| 490 | +            throw new \Exception('This model does not exist.', 404); | |
| 491 | + } | |
| 491 | 492 | |
| 492 | 493 | $this->model = new $model_namespace(); | 
| 493 | 494 |          $this->query = $this->model->select('*'); | 
| @@ -529,7 +530,9 @@ discard block | ||
| 529 | 530 |      { | 
| 530 | 531 | $complete_route = $route.'.index'; | 
| 531 | 532 | |
| 532 | -        if (!\Route::has($complete_route)) throw new \Exception('There are no routes for this route name.', 404); | |
| 533 | +        if (!\Route::has($complete_route)) { | |
| 534 | +            throw new \Exception('There are no routes for this route name.', 404); | |
| 535 | + } | |
| 533 | 536 | |
| 534 | 537 | $this->route = route($complete_route, $parameters); | 
| 535 | 538 | $this->initButtons(); | 
| @@ -585,8 +588,7 @@ discard block | ||
| 585 | 588 | // if label and other details have been defined in the array | 
| 586 | 589 |                  if (is_array($columns[0])) { | 
| 587 | 590 | $this->addColumn($column); | 
| 588 | - } | |
| 589 | - else | |
| 591 | + } else | |
| 590 | 592 |                  { | 
| 591 | 593 | $this->addColumn([ | 
| 592 | 594 | 'name' => $column, | 
| @@ -745,19 +747,20 @@ discard block | ||
| 745 | 747 | if (is_string($field)) | 
| 746 | 748 |          { | 
| 747 | 749 | $complete_field_array['name'] = $field; | 
| 748 | - } | |
| 749 | - else | |
| 750 | + } else | |
| 750 | 751 |          { | 
| 751 | 752 | $complete_field_array = $field; | 
| 752 | 753 | } | 
| 753 | 754 | |
| 754 | 755 | // if the label is missing, we should set it | 
| 755 | - if (!isset($complete_field_array['label'])) | |
| 756 | - $complete_field_array['label'] = ucfirst($complete_field_array['name']); | |
| 756 | +        if (!isset($complete_field_array['label'])) { | |
| 757 | + $complete_field_array['label'] = ucfirst($complete_field_array['name']); | |
| 758 | + } | |
| 757 | 759 | |
| 758 | 760 | // if the field type is missing, we should set it | 
| 759 | - if (!isset($complete_field_array['type'])) | |
| 760 | - $complete_field_array['type'] = $this->getFieldTypeFromDbColumnType($complete_field_array['name']); | |
| 761 | +        if (!isset($complete_field_array['type'])) { | |
| 762 | + $complete_field_array['type'] = $this->getFieldTypeFromDbColumnType($complete_field_array['name']); | |
| 763 | + } | |
| 761 | 764 | |
| 762 | 765 | // store the field information into the correct variable on the CRUD object | 
| 763 | 766 |          switch (strtolower($form)) { | 
| @@ -840,8 +843,9 @@ discard block | ||
| 840 | 843 | * @return bool true/false | 
| 841 | 844 | */ | 
| 842 | 845 |      public function checkIfFieldIsFirstOfItsType($field, $fields_array) { | 
| 843 | - if ($field['name'] == $this->getFirstOfItsTypeInArray($field['type'], $fields_array)['name']) | |
| 844 | - return true; | |
| 846 | +        if ($field['name'] == $this->getFirstOfItsTypeInArray($field['type'], $fields_array)['name']) { | |
| 847 | + return true; | |
| 848 | + } | |
| 845 | 849 | |
| 846 | 850 | return false; | 
| 847 | 851 | } | 
| @@ -998,11 +1002,17 @@ discard block | ||
| 998 | 1002 | */ | 
| 999 | 1003 | public function getFieldTypeFromDbColumnType($field) | 
| 1000 | 1004 |      { | 
| 1001 | - if (!array_key_exists($field, $this->field_types)) return 'text'; | |
| 1005 | +        if (!array_key_exists($field, $this->field_types)) { | |
| 1006 | + return 'text'; | |
| 1007 | + } | |
| 1002 | 1008 | |
| 1003 | - if ($field == 'password') return 'password'; | |
| 1009 | +        if ($field == 'password') { | |
| 1010 | + return 'password'; | |
| 1011 | + } | |
| 1004 | 1012 | |
| 1005 | - if ($field == 'email') return 'email'; | |
| 1013 | +        if ($field == 'email') { | |
| 1014 | + return 'email'; | |
| 1015 | + } | |
| 1006 | 1016 | |
| 1007 | 1017 | switch ($this->field_types[$field]['type']) | 
| 1008 | 1018 |          { | 
| @@ -1075,7 +1085,9 @@ discard block | ||
| 1075 | 1085 | $columns = \Schema::getColumnListing($this->model->getTable()); | 
| 1076 | 1086 | $fillable = $this->model->getFillable(); | 
| 1077 | 1087 | |
| 1078 | - if (!empty($fillable)) $columns = array_intersect($columns, $fillable); | |
| 1088 | +        if (!empty($fillable)) { | |
| 1089 | + $columns = array_intersect($columns, $fillable); | |
| 1090 | + } | |
| 1079 | 1091 | |
| 1080 | 1092 | // but not updated_at, deleted_at | 
| 1081 | 1093 | return array_values(array_diff($columns, [$this->model->getKeyName(), 'updated_at', 'deleted_at'])); | 
| @@ -1403,8 +1415,11 @@ discard block | ||
| 1403 | 1415 | |
| 1404 | 1416 |              foreach ($this->{$fields} as $key => $field) | 
| 1405 | 1417 |              { | 
| 1406 | -                if (array_key_exists($field['name'], $this->relations) && $this->relations[$field['name']]['pivot']) $this->{$fields}[$key]['value'] = $this->entry->{$this->relations[$field['name']]['name']}()->lists($this->relations[$field['name']]['model']->getKeyName())->toArray(); | |
| 1407 | -                    else $this->{$fields}[$key]['value'] = $this->entry->{$field['name']}; | |
| 1418 | +                if (array_key_exists($field['name'], $this->relations) && $this->relations[$field['name']]['pivot']) { | |
| 1419 | +                    $this->{$fields}[$key]['value'] = $this->entry->{$this->relations[$field['name']]['name']}()->lists($this->relations[$field['name']]['model']->getKeyName())->toArray(); | |
| 1420 | +                } else { | |
| 1421 | +                        $this->{$fields}[$key]['value'] = $this->entry->{$field['name']}; | |
| 1422 | + } | |
| 1408 | 1423 | } | 
| 1409 | 1424 | } | 
| 1410 | 1425 | } | 
| @@ -1424,7 +1439,9 @@ discard block | ||
| 1424 | 1439 |          if (!empty($this->{$type})) | 
| 1425 | 1440 |          { | 
| 1426 | 1441 |              $this->{$type} = array_map(function($field) use ($fields, $attributes) { | 
| 1427 | - if (in_array($field['name'], (array)$fields)) $field = array_merge($field, $attributes); | |
| 1442 | +                if (in_array($field['name'], (array)$fields)) { | |
| 1443 | + $field = array_merge($field, $attributes); | |
| 1444 | + } | |
| 1428 | 1445 | |
| 1429 | 1446 | return $field; | 
| 1430 | 1447 |              }, $this->{$type}); | 
| @@ -1451,7 +1468,9 @@ discard block | ||
| 1451 | 1468 | |
| 1452 | 1469 | foreach ($this->sort[$items] as $item) | 
| 1453 | 1470 |              { | 
| 1454 | -                if (is_numeric($key = array_search($item, array_column($this->{$items}, 'name')))) $elements[] = $this->{$items}[$key]; | |
| 1471 | +                if (is_numeric($key = array_search($item, array_column($this->{$items}, 'name')))) { | |
| 1472 | +                    $elements[] = $this->{$items}[$key]; | |
| 1473 | + } | |
| 1455 | 1474 | } | 
| 1456 | 1475 | |
| 1457 | 1476 |              return $this->{$items} = array_merge($elements, array_filter($this->{$items}, function($item) use($items) {return !in_array($item['name'], $this->sort[$items]);})); | 
| @@ -1470,9 +1489,13 @@ discard block | ||
| 1470 | 1489 | $order = (array)$order; | 
| 1471 | 1490 |          $values = $model->select('*'); | 
| 1472 | 1491 | |
| 1473 | - if (!empty($where)) call_user_func_array([$values, $where[0]], array_slice($where, 1)); | |
| 1492 | +        if (!empty($where)) { | |
| 1493 | + call_user_func_array([$values, $where[0]], array_slice($where, 1)); | |
| 1494 | + } | |
| 1474 | 1495 | |
| 1475 | - if (!empty($order)) call_user_func_array([$values, 'orderBy'], $order); | |
| 1496 | +        if (!empty($order)) { | |
| 1497 | + call_user_func_array([$values, 'orderBy'], $order); | |
| 1498 | + } | |
| 1476 | 1499 | |
| 1477 | 1500 | return $values->get()->lists($field, $model->getKeyName())->toArray(); | 
| 1478 | 1501 | } | 
| @@ -1481,8 +1504,11 @@ discard block | ||
| 1481 | 1504 | public function syncRelations($entity) | 
| 1482 | 1505 |      { | 
| 1483 | 1506 |          foreach ($this->relations as $field => $relation) { | 
| 1484 | - if ($relation['pivot']) $this->add($entity, ['name' => $field, 'type' => 'multiselect', 'value' => [], 'values' => $this->relations[$field]['values']]); | |
| 1485 | - else $this->sync($entity, $field, ['type' => 'select', 'values' => $this->relations[$field]['values']]); | |
| 1507 | +            if ($relation['pivot']) { | |
| 1508 | + $this->add($entity, ['name' => $field, 'type' => 'multiselect', 'value' => [], 'values' => $this->relations[$field]['values']]); | |
| 1509 | +            } else { | |
| 1510 | + $this->sync($entity, $field, ['type' => 'select', 'values' => $this->relations[$field]['values']]); | |
| 1511 | + } | |
| 1486 | 1512 | } | 
| 1487 | 1513 | } | 
| 1488 | 1514 | |