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 |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | <!-- elFinder JS (REQUIRED) --> |
18 | 18 | <script src="<?= asset($dir.'/js/elfinder.min.js') ?>"></script> |
19 | 19 | |
20 | - <?php if($locale){ ?> |
|
20 | + <?php if ($locale) { ?> |
|
21 | 21 | <!-- elFinder translation (OPTIONAL) --> |
22 | 22 | <script src="<?= asset($dir."/js/i18n/elfinder.$locale.js") ?>"></script> |
23 | 23 | <?php } ?> |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $().ready(function() { |
41 | 41 | var elf = $('#elfinder').elfinder({ |
42 | 42 | // set your elFinder options here |
43 | - <?php if($locale){ ?> |
|
43 | + <?php if ($locale) { ?> |
|
44 | 44 | lang: '<?= $locale ?>', // locale |
45 | 45 | <?php } ?> |
46 | 46 | customData: { |
@@ -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 | ]; |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | <!-- elFinder JS (REQUIRED) --> |
18 | 18 | <script src="<?= asset($dir.'/js/elfinder.min.js') ?>"></script> |
19 | 19 | |
20 | - <?php if($locale){ ?> |
|
20 | + <?php if ($locale) { ?> |
|
21 | 21 | <!-- elFinder translation (OPTIONAL) --> |
22 | 22 | <script src="<?= asset($dir."/js/i18n/elfinder.$locale.js") ?>"></script> |
23 | 23 | <?php } ?> |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $().ready(function() { |
41 | 41 | var elf = $('#elfinder').elfinder({ |
42 | 42 | // set your elFinder options here |
43 | - <?php if($locale){ ?> |
|
43 | + <?php if ($locale) { ?> |
|
44 | 44 | lang: '<?= $locale ?>', // locale |
45 | 45 | <?php } ?> |
46 | 46 | customData: { |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | <!-- elFinder JS (REQUIRED) --> |
18 | 18 | <script src="<?= asset($dir.'/js/elfinder.min.js') ?>"></script> |
19 | 19 | |
20 | - <?php if($locale){ ?> |
|
20 | + <?php if ($locale) { ?> |
|
21 | 21 | <!-- elFinder translation (OPTIONAL) --> |
22 | 22 | <script src="<?= asset($dir."/js/i18n/elfinder.$locale.js") ?>"></script> |
23 | 23 | <?php } ?> |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $().ready(function() { |
41 | 41 | var elf = $('#elfinder').elfinder({ |
42 | 42 | // set your elFinder options here |
43 | - <?php if($locale){ ?> |
|
43 | + <?php if ($locale) { ?> |
|
44 | 44 | lang: '<?= $locale ?>', // locale |
45 | 45 | <?php } ?> |
46 | 46 | customData: { |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | <!-- elFinder JS (REQUIRED) --> |
18 | 18 | <script src="<?= asset($dir.'/js/elfinder.min.js') ?>"></script> |
19 | 19 | |
20 | - <?php if($locale){ ?> |
|
20 | + <?php if ($locale) { ?> |
|
21 | 21 | <!-- elFinder translation (OPTIONAL) --> |
22 | 22 | <script src="<?= asset($dir."/js/i18n/elfinder.$locale.js") ?>"></script> |
23 | 23 | <?php } ?> |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | $().ready(function() { |
41 | 41 | var elf = $('#elfinder').elfinder({ |
42 | 42 | // set your elFinder options here |
43 | - <?php if($locale){ ?> |
|
43 | + <?php if ($locale) { ?> |
|
44 | 44 | lang: '<?= $locale ?>', // locale |
45 | 45 | <?php } ?> |
46 | 46 | customData: { |
@@ -12,14 +12,14 @@ |
||
12 | 12 | |-------------------------------------------------------------------------- |
13 | 13 | */ |
14 | 14 | |
15 | - public static function getPossibleEnumValues($field_name){ |
|
15 | + public static function getPossibleEnumValues($field_name) { |
|
16 | 16 | $instance = new static; // create an instance of the model to be able to get the table name |
17 | - $type = DB::select( DB::raw('SHOW COLUMNS FROM '.$instance->getTable().' WHERE Field = "'.$field_name.'"') )[0]->Type; |
|
17 | + $type = DB::select(DB::raw('SHOW COLUMNS FROM '.$instance->getTable().' WHERE Field = "'.$field_name.'"'))[0]->Type; |
|
18 | 18 | preg_match('/^enum\((.*)\)$/', $type, $matches); |
19 | 19 | $enum = array(); |
20 | 20 | $exploded = explode(',', $matches[1]); |
21 | - foreach($exploded as $value){ |
|
22 | - $v = trim( $value, "'" ); |
|
21 | + foreach ($exploded as $value) { |
|
22 | + $v = trim($value, "'"); |
|
23 | 23 | $enum[] = $v; |
24 | 24 | } |
25 | 25 | return $enum; |
@@ -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 |