We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
1 | <?php |
||
25 | class CrudPanel |
||
26 | { |
||
27 | use Create, Read, Update, Delete, Errors, Reorder, Access, Columns, Fields, Query, Buttons, AutoSet, FakeFields, FakeColumns, ViewsAndRestoresRevisions, AutoFocus, Filters, Tabs, Views; |
||
28 | |||
29 | // -------------- |
||
30 | // CRUD variables |
||
31 | // -------------- |
||
32 | // These variables are passed to the CRUD views, inside the $crud variable. |
||
33 | // All variables are public, so they can be modified from your EntityCrudController. |
||
34 | // All functions and methods are also public, so they can be used in your EntityCrudController to modify these variables. |
||
35 | |||
36 | // TODO: translate $entity_name and $entity_name_plural by default, with english fallback |
||
37 | |||
38 | public $model = "\App\Models\Entity"; // what's the namespace for your entity's model |
||
39 | public $route; // what route have you defined for your entity? used for links. |
||
40 | public $entity_name = 'entry'; // what name will show up on the buttons, in singural (ex: Add entity) |
||
41 | public $entity_name_plural = 'entries'; // what name will show up on the buttons, in plural (ex: Delete 5 entities) |
||
42 | public $request; |
||
43 | |||
44 | public $access = ['list', 'create', 'update', 'delete'/* 'revisions', reorder', 'show', 'details_row' */]; |
||
45 | |||
46 | public $reorder = false; |
||
47 | public $reorder_label = false; |
||
48 | public $reorder_max_level = 3; |
||
49 | |||
50 | public $details_row = false; |
||
51 | public $ajax_table = false; |
||
52 | public $export_buttons = false; |
||
53 | |||
54 | public $columns = []; // Define the columns for the table view as an array; |
||
55 | public $create_fields = []; // Define the fields for the "Add new entry" view as an array; |
||
56 | public $update_fields = []; // Define the fields for the "Edit entry" view as an array; |
||
57 | |||
58 | public $query; |
||
59 | public $entry; |
||
60 | public $buttons; |
||
61 | public $db_column_types = []; |
||
62 | public $default_page_length = false; |
||
63 | |||
64 | // TONE FIELDS - TODO: find out what he did with them, replicate or delete |
||
65 | public $sort = []; |
||
66 | |||
67 | // The following methods are used in CrudController or your EntityCrudController to manipulate the variables above. |
||
68 | |||
69 | public function __construct() |
||
73 | |||
74 | // ------------------------------------------------------ |
||
75 | // BASICS - model, route, entity_name, entity_name_plural |
||
76 | // ------------------------------------------------------ |
||
77 | |||
78 | /** |
||
79 | * This function binds the CRUD to its corresponding Model (which extends Eloquent). |
||
80 | * All Create-Read-Update-Delete operations are done using that Eloquent Collection. |
||
81 | * |
||
82 | * @param [string] Full model namespace. Ex: App\Models\Article |
||
83 | */ |
||
84 | public function setModel($model_namespace) |
||
93 | |||
94 | /** |
||
95 | * Get the corresponding Eloquent Model for the CrudController, as defined with the setModel() function;. |
||
96 | * |
||
97 | * @return [Eloquent Collection] |
||
98 | */ |
||
99 | public function getModel() |
||
103 | |||
104 | /** |
||
105 | * Set the route for this CRUD. |
||
106 | * Ex: admin/article. |
||
107 | * |
||
108 | * @param [string] Route name. |
||
109 | * @param [array] Parameters. |
||
110 | */ |
||
111 | public function setRoute($route) |
||
116 | |||
117 | /** |
||
118 | * Set the route for this CRUD using the route name. |
||
119 | * Ex: admin.article. |
||
120 | * |
||
121 | * @param [string] Route name. |
||
122 | * @param [array] Parameters. |
||
123 | */ |
||
124 | public function setRouteName($route, $parameters = []) |
||
135 | |||
136 | /** |
||
137 | * Get the current CrudController route. |
||
138 | * |
||
139 | * Can be defined in the CrudController with: |
||
140 | * - $this->crud->setRoute(config('backpack.base.route_prefix').'/article') |
||
141 | * - $this->crud->setRouteName(config('backpack.base.route_prefix').'.article') |
||
142 | * - $this->crud->route = config('backpack.base.route_prefix')."/article" |
||
143 | * |
||
144 | * @return [string] |
||
145 | */ |
||
146 | public function getRoute() |
||
150 | |||
151 | /** |
||
152 | * Set the entity name in singular and plural. |
||
153 | * Used all over the CRUD interface (header, add button, reorder button, breadcrumbs). |
||
154 | * |
||
155 | * @param [string] Entity name, in singular. Ex: article |
||
156 | * @param [string] Entity name, in plural. Ex: articles |
||
157 | */ |
||
158 | public function setEntityNameStrings($singular, $plural) |
||
163 | |||
164 | // ---------------------------------- |
||
165 | // Miscellaneous functions or methods |
||
166 | // ---------------------------------- |
||
167 | |||
168 | /** |
||
169 | * Return the first element in an array that has the given 'type' attribute. |
||
170 | * |
||
171 | * @param string $type |
||
172 | * @param array $array |
||
173 | * |
||
174 | * @return array |
||
175 | */ |
||
176 | public function getFirstOfItsTypeInArray($type, $array) |
||
182 | |||
183 | // ------------ |
||
184 | // TONE FUNCTIONS - UNDOCUMENTED, UNTESTED, SOME MAY BE USED IN THIS FILE |
||
185 | // ------------ |
||
186 | // |
||
187 | // TODO: |
||
188 | // - figure out if they are really needed |
||
189 | // - comments inside the function to explain how they work |
||
190 | // - write docblock for them |
||
191 | // - place in the correct section above (CREATE, READ, UPDATE, DELETE, ACCESS, MANIPULATION) |
||
192 | |||
193 | public function sync($type, $fields, $attributes) |
||
205 | |||
206 | public function setSort($items, $order) |
||
210 | |||
211 | public function sort($items) |
||
229 | } |
||
230 |
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
.