1 | <?php |
||
20 | class ModelAdmin extends Admin implements AttributesAccessable, ModelWriteable, ModelQueryable, ModelValidatable, ModelCloneable |
||
21 | { |
||
22 | use AttributeAccess, ModelWriting, ModelQuerying, ModelValidating, ModelCloning; |
||
23 | |||
24 | /** |
||
25 | * Class of Model to Manage. |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | protected static $managedModel; |
||
30 | |||
31 | /** |
||
32 | * ModelAdmin Icon. |
||
33 | * |
||
34 | * Font Awesome Defined Icon, eg 'user' = 'fa-user' |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | protected static $icon = 'user'; |
||
39 | |||
40 | /** |
||
41 | * Validation Rules for onCreate, onEdit actions. |
||
42 | * |
||
43 | * @var array |
||
44 | */ |
||
45 | protected $rules = []; |
||
46 | |||
47 | /** |
||
48 | * Columns for Model. |
||
49 | * |
||
50 | * Defines which fields to show in the listing tables output. |
||
51 | * |
||
52 | * @var array |
||
53 | */ |
||
54 | protected $columns = []; |
||
55 | |||
56 | /** |
||
57 | * Columns for Model are Sortable. |
||
58 | * |
||
59 | * @var boolean |
||
60 | */ |
||
61 | protected $sortable = true; |
||
62 | |||
63 | /** |
||
64 | * The Controller to be used by the Model Admin. |
||
65 | * |
||
66 | * This defaults to parent::getController() |
||
67 | * if it has been left undefined. |
||
68 | * |
||
69 | * @var string |
||
70 | */ |
||
71 | protected static $controller = '\LaravelFlare\Flare\Admin\Models\ModelAdminController'; |
||
72 | |||
73 | /** |
||
74 | * The Policy used for the Model Authorization logic. |
||
75 | * |
||
76 | * This class should implement the ModelAdminPoliceable which |
||
77 | * includes authorization checks for the create, view, edit and delete actions. |
||
78 | * |
||
79 | * @var string |
||
80 | */ |
||
81 | protected static $policy = '\LaravelFlare\Flare\Permissions\ModelAdminPolicy'; |
||
82 | |||
83 | /** |
||
84 | * The current model to be managed. |
||
85 | * |
||
86 | * @var Model |
||
87 | */ |
||
88 | public $model; |
||
89 | |||
90 | /** |
||
91 | * __construct. |
||
92 | */ |
||
93 | public function __construct() |
||
101 | |||
102 | /** |
||
103 | * Returns a Model Instance. |
||
104 | * |
||
105 | * Note: We should revisit this as really we shouldn't |
||
106 | * be returning a new instance of the object on every |
||
107 | * request. |
||
108 | * |
||
109 | * @return Model |
||
110 | */ |
||
111 | public function model() |
||
115 | |||
116 | /** |
||
117 | * Returns the Route Paramets. |
||
118 | * |
||
119 | * @return array |
||
120 | */ |
||
121 | public function routeParameters() |
||
127 | |||
128 | /** |
||
129 | * Formats and returns the Columns. |
||
130 | * |
||
131 | * This is really gross, I'm removing it soon. |
||
132 | * |
||
133 | * @return |
||
134 | */ |
||
135 | public function getColumns() |
||
175 | |||
176 | /** |
||
177 | * Gets an Attribute by the provided key |
||
178 | * on either the current model or a provided model instance. |
||
179 | * |
||
180 | * @param string $key |
||
181 | * @param mixed $model |
||
182 | * |
||
183 | * @return mixed |
||
184 | */ |
||
185 | public function getAttribute($key, $model = false) |
||
203 | |||
204 | /** |
||
205 | * Determine if a get accessor exists for an attribute. |
||
206 | * |
||
207 | * @param string $key |
||
208 | * |
||
209 | * @return bool |
||
210 | */ |
||
211 | public function hasGetAccessor($key) |
||
215 | |||
216 | /** |
||
217 | * Determines if a key resolved a related Model. |
||
218 | * |
||
219 | * @param string $key |
||
220 | * @param mixed $model |
||
221 | * |
||
222 | * @return bool |
||
223 | */ |
||
224 | public function hasRelatedKey($key, $model = false) |
||
239 | |||
240 | /** |
||
241 | * Resolves a relation based on the key provided, |
||
242 | * either on the current model or a provided model instance. |
||
243 | * |
||
244 | * @param string $key |
||
245 | * @param mixed $model |
||
246 | * |
||
247 | * @return mixed |
||
248 | */ |
||
249 | public function relatedKey($key, $model = false) |
||
272 | |||
273 | /** |
||
274 | * Set a given attribute on the model. |
||
275 | * |
||
276 | * @param string $key |
||
277 | * @param mixed $value |
||
278 | */ |
||
279 | public function setAttribute($key, $value) |
||
289 | |||
290 | /** |
||
291 | * Determine if a set mutator exists for an attribute. |
||
292 | * |
||
293 | * @param string $key |
||
294 | * |
||
295 | * @return bool |
||
296 | */ |
||
297 | public function hasSetMutator($key) |
||
301 | |||
302 | /** |
||
303 | * Determine if a get mutator exists for an attribute. |
||
304 | * |
||
305 | * @param string $key |
||
306 | * |
||
307 | * @return bool |
||
308 | */ |
||
309 | public function hasGetMutator($key) |
||
313 | |||
314 | /** |
||
315 | * Determine if the Model Admin is sortable in it's list view. |
||
316 | * |
||
317 | * @param string $key |
||
|
|||
318 | * |
||
319 | * @return bool |
||
320 | */ |
||
321 | public function isSortable() |
||
325 | |||
326 | /** |
||
327 | * Returns a DefaultWidget instance based on the currently ManagedModel. |
||
328 | * |
||
329 | * @return DefaultWidget |
||
330 | */ |
||
331 | public function defaultWidget() |
||
335 | |||
336 | /** |
||
337 | * Determine if the Managed Model is using the SoftDeletes Trait. |
||
338 | * |
||
339 | * @return bool |
||
340 | */ |
||
341 | public function hasSoftDeletes() |
||
347 | } |
||
348 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.