@@ -47,14 +47,14 @@ discard block |
||
47 | 47 | |
48 | 48 | $this->app->bind( |
49 | 49 | 'Anavel\Crud\Contracts\Abstractor\FieldFactory', |
50 | - function () { |
|
50 | + function() { |
|
51 | 51 | return new FieldAbstractorFactory(new FormFactory); |
52 | 52 | } |
53 | 53 | ); |
54 | 54 | |
55 | 55 | $this->app->bind( |
56 | 56 | 'Anavel\Crud\Contracts\Abstractor\RelationFactory', |
57 | - function () { |
|
57 | + function() { |
|
58 | 58 | return new RelationAbstractorFactory( |
59 | 59 | $this->app['ANavallaSuiza\Laravel\Database\Contracts\Manager\ModelManager'], |
60 | 60 | $this->app['Anavel\Crud\Contracts\Abstractor\FieldFactory'] |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | |
65 | 65 | $this->app->bind( |
66 | 66 | 'Anavel\Crud\Contracts\Abstractor\ModelFactory', |
67 | - function () { |
|
67 | + function() { |
|
68 | 68 | return new ModelAbstractorFactory( |
69 | 69 | config('anavel-crud.models'), |
70 | 70 | $this->app['ANavallaSuiza\Laravel\Database\Contracts\Manager\ModelManager'], |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | |
78 | 78 | $this->app->bind( |
79 | 79 | 'Anavel\Crud\Contracts\Form\Generator', |
80 | - function () { |
|
80 | + function() { |
|
81 | 81 | return new FormGenerator(new FormFactory); |
82 | 82 | } |
83 | 83 | ); |
@@ -5,7 +5,7 @@ |
||
5 | 5 | 'prefix' => 'crud', |
6 | 6 | 'namespace' => 'Anavel\Crud\Http\Controllers' |
7 | 7 | ], |
8 | - function () { |
|
8 | + function() { |
|
9 | 9 | Route::get('/', [ |
10 | 10 | 'as' => 'anavel-crud.home', |
11 | 11 | 'uses' => 'HomeController@index' |
@@ -85,6 +85,9 @@ discard block |
||
85 | 85 | return transcrud($this->name); |
86 | 86 | } |
87 | 87 | |
88 | + /** |
|
89 | + * @return string |
|
90 | + */ |
|
88 | 91 | public function getModel() |
89 | 92 | { |
90 | 93 | return $this->model; |
@@ -334,7 +337,7 @@ discard block |
||
334 | 337 | } |
335 | 338 | |
336 | 339 | /** |
337 | - * @param array $requestForm |
|
340 | + * @param array $request |
|
338 | 341 | * @return mixed |
339 | 342 | */ |
340 | 343 | public function persist(Request $request) |
@@ -16,8 +16,6 @@ |
||
16 | 16 | use Anavel\Crud\Abstractor\Exceptions\AbstractorException; |
17 | 17 | use Illuminate\Http\Request; |
18 | 18 | use Illuminate\Support\Collection; |
19 | -use League\Flysystem\Adapter\Local; |
|
20 | -use League\Flysystem\Filesystem; |
|
21 | 19 | |
22 | 20 | class Model implements ModelAbstractorContract |
23 | 21 | { |
@@ -143,10 +143,10 @@ discard block |
||
143 | 143 | } |
144 | 144 | |
145 | 145 | $customDisplayedColumns = $this->getConfigValue($action, 'display'); |
146 | - $customHiddenColumns = $this->getConfigValue($action, 'hide') ? : []; |
|
146 | + $customHiddenColumns = $this->getConfigValue($action, 'hide') ?: []; |
|
147 | 147 | |
148 | 148 | $columns = array(); |
149 | - if (! empty($customDisplayedColumns) && is_array($customDisplayedColumns)) { |
|
149 | + if (!empty($customDisplayedColumns) && is_array($customDisplayedColumns)) { |
|
150 | 150 | foreach ($customDisplayedColumns as $customColumn) { |
151 | 151 | if (strpos($customColumn, '.')) { |
152 | 152 | $customColumnRelation = explode('.', $customColumn); |
@@ -161,14 +161,14 @@ discard block |
||
161 | 161 | |
162 | 162 | $relationColumns = $nestedRelation->getModelAbstractor()->getColumns($action); |
163 | 163 | |
164 | - if (! array_key_exists($customColumnRelationFieldName, $relationColumns)) { |
|
165 | - throw new AbstractorException("Column " . $customColumnRelationFieldName . " does not exist on relation " . implode('.', $customColumnRelation) . " of model " . $this->getModel()); |
|
164 | + if (!array_key_exists($customColumnRelationFieldName, $relationColumns)) { |
|
165 | + throw new AbstractorException("Column ".$customColumnRelationFieldName." does not exist on relation ".implode('.', $customColumnRelation)." of model ".$this->getModel()); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | $columns[$customColumn] = $relationColumns[$customColumnRelationFieldName]; |
169 | 169 | } else { |
170 | - if (! array_key_exists($customColumn, $tableColumns)) { |
|
171 | - throw new AbstractorException("Column " . $customColumn . " does not exist on " . $this->getModel()); |
|
170 | + if (!array_key_exists($customColumn, $tableColumns)) { |
|
171 | + throw new AbstractorException("Column ".$customColumn." does not exist on ".$this->getModel()); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | $columns[$customColumn] = $tableColumns[$customColumn]; |
@@ -195,8 +195,8 @@ discard block |
||
195 | 195 | { |
196 | 196 | $relations = $modelAbstractor->getRelations(); |
197 | 197 | |
198 | - if (! $relations->has($relationName)) { |
|
199 | - throw new AbstractorException("Relation " . $relationName . " not configured on " . $modelAbstractor->getModel()); |
|
198 | + if (!$relations->has($relationName)) { |
|
199 | + throw new AbstractorException("Relation ".$relationName." not configured on ".$modelAbstractor->getModel()); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | $relation = $relations->get($relationName); |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | |
218 | 218 | $relations = collect(); |
219 | 219 | |
220 | - if (! empty($configRelations)) { |
|
220 | + if (!empty($configRelations)) { |
|
221 | 221 | foreach ($configRelations as $relationName => $configRelation) { |
222 | 222 | if (is_int($relationName)) { |
223 | 223 | $relationName = $configRelation; |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | |
226 | 226 | $config = []; |
227 | 227 | if ($configRelation !== $relationName) { |
228 | - if (! is_array($configRelation)) { |
|
228 | + if (!is_array($configRelation)) { |
|
229 | 229 | $config['type'] = $configRelation; |
230 | 230 | } else { |
231 | 231 | $config = $configRelation; |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | $secondaryRelations = $relation->getSecondaryRelations(); |
241 | 241 | |
242 | 242 | |
243 | - if (! $secondaryRelations->isEmpty()) { |
|
243 | + if (!$secondaryRelations->isEmpty()) { |
|
244 | 244 | $relations->put( |
245 | 245 | $relationName, |
246 | 246 | collect(['relation' => $relation, 'secondaryRelations' => $secondaryRelations]) |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | { |
264 | 264 | $columns = $this->getColumns('list'); |
265 | 265 | |
266 | - $fieldsPresentation = $this->getConfigValue('fields_presentation') ? : []; |
|
266 | + $fieldsPresentation = $this->getConfigValue('fields_presentation') ?: []; |
|
267 | 267 | |
268 | 268 | $fields = array(); |
269 | 269 | foreach ($columns as $name => $column) { |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | { |
299 | 299 | $columns = $this->getColumns('detail'); |
300 | 300 | |
301 | - $fieldsPresentation = $this->getConfigValue('fields_presentation') ? : []; |
|
301 | + $fieldsPresentation = $this->getConfigValue('fields_presentation') ?: []; |
|
302 | 302 | |
303 | 303 | $fields = array(); |
304 | 304 | foreach ($columns as $name => $column) { |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | |
339 | 339 | $fields = array(); |
340 | 340 | foreach ($columns as $name => $column) { |
341 | - if (! in_array($name, $this->getReadOnlyColumns())) { |
|
341 | + if (!in_array($name, $this->getReadOnlyColumns())) { |
|
342 | 342 | $presentation = null; |
343 | 343 | if (array_key_exists($name, $this->fieldsPresentation)) { |
344 | 344 | $presentation = $this->fieldsPresentation[$name]; |
@@ -359,24 +359,24 @@ discard block |
||
359 | 359 | ->setConfig($config) |
360 | 360 | ->get(); |
361 | 361 | |
362 | - if (! empty($this->instance) && ! empty($this->instance->getAttribute($name))) { |
|
362 | + if (!empty($this->instance) && !empty($this->instance->getAttribute($name))) { |
|
363 | 363 | $field->setValue($this->instance->getAttribute($name)); |
364 | 364 | } |
365 | 365 | |
366 | 366 | $fields[$arrayKey][$name] = $field; |
367 | 367 | |
368 | - if (! empty($config['form_type']) && $config['form_type'] === 'file') { |
|
368 | + if (!empty($config['form_type']) && $config['form_type'] === 'file') { |
|
369 | 369 | $field = $this->fieldFactory |
370 | 370 | ->setColumn($column) |
371 | 371 | ->setConfig([ |
372 | - 'name' => $name . '__delete', |
|
372 | + 'name' => $name.'__delete', |
|
373 | 373 | 'presentation' => null, |
374 | 374 | 'form_type' => 'checkbox', |
375 | 375 | 'no_validate' => true, |
376 | 376 | 'functions' => null |
377 | 377 | ]) |
378 | 378 | ->get(); |
379 | - $fields[$arrayKey][$name . '__delete'] = $field; |
|
379 | + $fields[$arrayKey][$name.'__delete'] = $field; |
|
380 | 380 | } |
381 | 381 | } |
382 | 382 | } |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | { |
414 | 414 | /** @var \ANavallaSuiza\Laravel\Database\Contracts\Manager\ModelManager $modelManager */ |
415 | 415 | $modelManager = App::make('ANavallaSuiza\Laravel\Database\Contracts\Manager\ModelManager'); |
416 | - if (! empty($this->instance)) { |
|
416 | + if (!empty($this->instance)) { |
|
417 | 417 | $item = $this->instance; |
418 | 418 | } else { |
419 | 419 | $item = $modelManager->getModelInstance($this->getModel()); |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | return; |
426 | 426 | } |
427 | 427 | |
428 | - if (! empty($fields['main'])) { |
|
428 | + if (!empty($fields['main'])) { |
|
429 | 429 | $skip = null; |
430 | 430 | foreach ($fields['main'] as $key => $field) { |
431 | 431 | /** @var FieldContract $field */ |
@@ -449,21 +449,21 @@ discard block |
||
449 | 449 | } |
450 | 450 | |
451 | 451 | if (get_class($field->getFormField()) === \FormManager\Fields\File::class) { |
452 | - $handleResult = $this->handleField($request, $item, $fields['main'], 'main', $fieldName,$this->mustDeleteFilesInFilesystem); |
|
453 | - if (! empty($handleResult['skip'])) { |
|
452 | + $handleResult = $this->handleField($request, $item, $fields['main'], 'main', $fieldName, $this->mustDeleteFilesInFilesystem); |
|
453 | + if (!empty($handleResult['skip'])) { |
|
454 | 454 | $skip = $handleResult['skip']; |
455 | 455 | } |
456 | - if (! empty($handleResult['requestValue'])) { |
|
456 | + if (!empty($handleResult['requestValue'])) { |
|
457 | 457 | $requestValue = $handleResult['requestValue']; |
458 | 458 | } |
459 | 459 | } |
460 | 460 | |
461 | 461 | |
462 | - if (! $field->saveIfEmpty() && empty($requestValue)) { |
|
462 | + if (!$field->saveIfEmpty() && empty($requestValue)) { |
|
463 | 463 | continue; |
464 | 464 | } |
465 | 465 | |
466 | - if (! empty($requestValue) || (empty($requestValue) && ! empty($item->getAttribute($fieldName)))) { |
|
466 | + if (!empty($requestValue) || (empty($requestValue) && !empty($item->getAttribute($fieldName)))) { |
|
467 | 467 | $item->setAttribute( |
468 | 468 | $fieldName, |
469 | 469 | $field->applyFunctions($requestValue) |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | $this->setInstance($item); |
478 | 478 | |
479 | 479 | |
480 | - if (! empty($relations = $this->getRelations())) { |
|
480 | + if (!empty($relations = $this->getRelations())) { |
|
481 | 481 | foreach ($relations as $relationKey => $relation) { |
482 | 482 | if ($relation instanceof Collection) { |
483 | 483 | $input = $request->input($relationKey); |
@@ -27,7 +27,7 @@ |
||
27 | 27 | /** |
28 | 28 | * @param array $config |
29 | 29 | * @param string $columnName |
30 | - * @return array |
|
30 | + * @return \Doctrine\DBAL\Schema\Column |
|
31 | 31 | */ |
32 | 32 | public function setConfig(array $config, $columnName) |
33 | 33 | { |
@@ -55,7 +55,6 @@ |
||
55 | 55 | public function getSecondaryRelations(); |
56 | 56 | |
57 | 57 | /** |
58 | - * @param Model $relatedModel |
|
59 | 58 | * @return Relation |
60 | 59 | */ |
61 | 60 | public function setRelatedModel(\Illuminate\Database\Eloquent\Model $model); |
@@ -25,6 +25,9 @@ |
||
25 | 25 | $this->formGenerator = $formGenerator; |
26 | 26 | } |
27 | 27 | |
28 | + /** |
|
29 | + * @param string $methodName |
|
30 | + */ |
|
28 | 31 | private function authorizeMethod(Model $modelAbstractor, $methodName) |
29 | 32 | { |
30 | 33 | if (array_key_exists('authorize', $config = $modelAbstractor->getConfig()) && $config['authorize'] === true) { |
@@ -39,7 +39,7 @@ |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | - * @param $slug |
|
42 | + * @param string $slug |
|
43 | 43 | * @param null $id |
44 | 44 | * @return Model|null |
45 | 45 | * @throws \Exception |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | |
18 | 18 | public function apply($model, Repository $repository) |
19 | 19 | { |
20 | - $query = $model->where(function ($query) use ($repository) { |
|
20 | + $query = $model->where(function($query) use ($repository) { |
|
21 | 21 | $firstColumn = array_shift($this->columns); |
22 | 22 | |
23 | 23 | if (strpos($firstColumn, '.')) { |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | private function getRelationClosure(array $relations) |
57 | 57 | { |
58 | - return function ($query) use ($relations) { |
|
58 | + return function($query) use ($relations) { |
|
59 | 59 | $relation = array_shift($relations); |
60 | 60 | |
61 | 61 | if (count($relations) > 0) { |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
145 | - * @return mixed |
|
145 | + * @return string |
|
146 | 146 | */ |
147 | 147 | public function getValue() |
148 | 148 | { |
@@ -181,6 +181,9 @@ discard block |
||
181 | 181 | } |
182 | 182 | |
183 | 183 | |
184 | + /** |
|
185 | + * @param boolean $value |
|
186 | + */ |
|
184 | 187 | public function hideValue($value = null) |
185 | 188 | { |
186 | 189 | if (!is_null($value)) { |
@@ -191,6 +194,9 @@ discard block |
||
191 | 194 | } |
192 | 195 | |
193 | 196 | |
197 | + /** |
|
198 | + * @param boolean $value |
|
199 | + */ |
|
194 | 200 | public function saveIfEmpty($value = null) |
195 | 201 | { |
196 | 202 | if (!is_null($value)) { |
@@ -201,6 +207,9 @@ discard block |
||
201 | 207 | } |
202 | 208 | |
203 | 209 | |
210 | + /** |
|
211 | + * @param boolean $value |
|
212 | + */ |
|
204 | 213 | public function noValidate($value = null) |
205 | 214 | { |
206 | 215 | if (!is_null($value)) { |