We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
1 | <?php |
||
21 | class CrudPanel |
||
22 | { |
||
23 | use Create, Read, Update, Delete, Reorder, Access, Columns, Fields, Query, Buttons, AutoSet, FakeFields, FakeColumns, ViewsAndRestoresRevisions, AutoFocus; |
||
24 | |||
25 | // -------------- |
||
26 | // CRUD variables |
||
27 | // -------------- |
||
28 | // These variables are passed to the CRUD views, inside the $crud variable. |
||
29 | // All variables are public, so they can be modified from your EntityCrudController. |
||
30 | // All functions and methods are also public, so they can be used in your EntityCrudController to modify these variables. |
||
31 | |||
32 | // TODO: translate $entity_name and $entity_name_plural by default, with english fallback |
||
33 | |||
34 | public $model = "\App\Models\Entity"; // what's the namespace for your entity's model |
||
35 | public $route; // what route have you defined for your entity? used for links. |
||
36 | public $entity_name = 'entry'; // what name will show up on the buttons, in singural (ex: Add entity) |
||
37 | public $entity_name_plural = 'entries'; // what name will show up on the buttons, in plural (ex: Delete 5 entities) |
||
38 | |||
39 | public $access = ['list', 'create', 'update', 'delete'/* 'revisions', reorder', 'show', 'details_row' */]; |
||
40 | |||
41 | public $reorder = false; |
||
42 | public $reorder_label = false; |
||
43 | public $reorder_max_level = 3; |
||
44 | |||
45 | public $details_row = false; |
||
46 | public $ajax_table = false; |
||
47 | public $export_buttons = false; |
||
48 | |||
49 | public $columns = []; // Define the columns for the table view as an array; |
||
50 | public $create_fields = []; // Define the fields for the "Add new entry" view as an array; |
||
51 | public $update_fields = []; // Define the fields for the "Edit entry" view as an array; |
||
52 | |||
53 | public $query; |
||
54 | public $entry; |
||
55 | public $buttons; |
||
56 | public $db_column_types = []; |
||
57 | public $default_page_length = false; |
||
58 | |||
59 | // TONE FIELDS - TODO: find out what he did with them, replicate or delete |
||
60 | public $sort = []; |
||
61 | |||
62 | // The following methods are used in CrudController or your EntityCrudController to manipulate the variables above. |
||
63 | |||
64 | // ------------------------------------------------------ |
||
65 | // BASICS - model, route, entity_name, entity_name_plural |
||
66 | // ------------------------------------------------------ |
||
67 | |||
68 | /** |
||
69 | * This function binds the CRUD to its corresponding Model (which extends Eloquent). |
||
70 | * All Create-Read-Update-Delete operations are done using that Eloquent Collection. |
||
71 | * |
||
72 | * @param [string] Full model namespace. Ex: App\Models\Article |
||
73 | */ |
||
74 | public function setModel($model_namespace) |
||
83 | |||
84 | /** |
||
85 | * Get the corresponding Eloquent Model for the CrudController, as defined with the setModel() function;. |
||
86 | * |
||
87 | * @return [Eloquent Collection] |
||
88 | */ |
||
89 | public function getModel() |
||
93 | |||
94 | /** |
||
95 | * Set the route for this CRUD. |
||
96 | * Ex: admin/article. |
||
97 | * |
||
98 | * @param [string] Route name. |
||
99 | * @param [array] Parameters. |
||
100 | */ |
||
101 | public function setRoute($route) |
||
106 | |||
107 | /** |
||
108 | * Set the route for this CRUD using the route name. |
||
109 | * Ex: admin.article. |
||
110 | * |
||
111 | * @param [string] Route name. |
||
112 | * @param [array] Parameters. |
||
113 | */ |
||
114 | public function setRouteName($route, $parameters = []) |
||
125 | |||
126 | /** |
||
127 | * Get the current CrudController route. |
||
128 | * |
||
129 | * Can be defined in the CrudController with: |
||
130 | * - $this->crud->setRoute('admin/article') |
||
131 | * - $this->crud->setRouteName('admin.article') |
||
132 | * - $this->crud->route = "admin/article" |
||
133 | * |
||
134 | * @return [string] |
||
135 | */ |
||
136 | public function getRoute() |
||
140 | |||
141 | /** |
||
142 | * Set the entity name in singular and plural. |
||
143 | * Used all over the CRUD interface (header, add button, reorder button, breadcrumbs). |
||
144 | * |
||
145 | * @param [string] Entity name, in singular. Ex: article |
||
146 | * @param [string] Entity name, in plural. Ex: articles |
||
147 | */ |
||
148 | public function setEntityNameStrings($singular, $plural) |
||
153 | |||
154 | // ---------------------------------- |
||
155 | // Miscellaneous functions or methods |
||
156 | // ---------------------------------- |
||
157 | |||
158 | /** |
||
159 | * Return the first element in an array that has the given 'type' attribute. |
||
160 | * |
||
161 | * @param string $type |
||
162 | * @param array $array |
||
163 | * |
||
164 | * @return array |
||
165 | */ |
||
166 | public function getFirstOfItsTypeInArray($type, $array) |
||
172 | |||
173 | // ------------ |
||
174 | // TONE FUNCTIONS - UNDOCUMENTED, UNTESTED, SOME MAY BE USED IN THIS FILE |
||
175 | // ------------ |
||
176 | // |
||
177 | // TODO: |
||
178 | // - figure out if they are really needed |
||
179 | // - comments inside the function to explain how they work |
||
180 | // - write docblock for them |
||
181 | // - place in the correct section above (CREATE, READ, UPDATE, DELETE, ACCESS, MANIPULATION) |
||
182 | |||
183 | public function sync($type, $fields, $attributes) |
||
195 | |||
196 | public function setSort($items, $order) |
||
200 | |||
201 | public function sort($items) |
||
219 | } |
||
220 |
This check marks property names that have not been written in camelCase.
In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes
databaseConnectionString
.