We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -2,7 +2,6 @@ |
||
2 | 2 | namespace Backpack\CRUD; |
3 | 3 | |
4 | 4 | use Illuminate\Support\ServiceProvider; |
5 | -use Illuminate\Routing\Router; |
|
6 | 5 | use Route; |
7 | 6 | |
8 | 7 | class CrudServiceProvider extends ServiceProvider |
@@ -71,8 +71,7 @@ |
||
71 | 71 | if ($results && $results->count()) { |
72 | 72 | $results_array = $results->lists($column['attribute'], 'id'); |
73 | 73 | echo implode(', ', $results_array->toArray()); |
74 | - } |
|
75 | - else |
|
74 | + } else |
|
76 | 75 | { |
77 | 76 | echo '-'; |
78 | 77 | } |
@@ -3,16 +3,12 @@ |
||
3 | 3 | use Illuminate\Foundation\Bus\DispatchesJobs; |
4 | 4 | use Illuminate\Routing\Controller as BaseController; |
5 | 5 | use Illuminate\Foundation\Validation\ValidatesRequests; |
6 | -use Illuminate\Foundation\Auth\Access\AuthorizesRequests; |
|
7 | -use Illuminate\Support\Facades\Form as Form; |
|
8 | 6 | use Illuminate\Http\Request; |
9 | 7 | use Backpack\CRUD\Crud; |
10 | -use Crypt; |
|
11 | 8 | use Alert; |
12 | 9 | |
13 | 10 | |
14 | 11 | // VALIDATION: change the requests to match your own file names if you need form validation |
15 | -use Backpack\CRUD\app\Http\Requests\CrudRequest as StoreRequest; |
|
16 | 12 | use Backpack\CRUD\app\Http\Requests\CrudRequest as UpdateRequest; |
17 | 13 | |
18 | 14 | class CrudController extends BaseController { |
@@ -1,12 +1,8 @@ |
||
1 | 1 | <?php namespace App\Http\Controllers\Admin; |
2 | 2 | |
3 | -use App\Http\Requests; |
|
4 | -use App\Http\Controllers\Controller; |
|
5 | 3 | use Backpack\CRUD\app\Http\Controllers\CrudController; |
6 | -use Illuminate\Http\Request; |
|
7 | 4 | |
8 | 5 | // VALIDATION: change the requests to match your own file names if you need form validation |
9 | -use Backpack\CRUD\app\Http\Requests\CrudRequest as StoreRequest; |
|
10 | 6 | use Backpack\CRUD\app\Http\Requests\CrudRequest as UpdateRequest; |
11 | 7 | |
12 | 8 | class ExampleCrudController extends CrudController { |
@@ -1,9 +1,6 @@ |
||
1 | 1 | <?php namespace Backpack\Crud\app\Http\Controllers; |
2 | 2 | |
3 | -use Illuminate\Foundation\Bus\DispatchesJobs; |
|
4 | 3 | use Illuminate\Routing\Controller as BaseController; |
5 | -use Illuminate\Foundation\Validation\ValidatesRequests; |
|
6 | -use Illuminate\Foundation\Auth\Access\AuthorizesRequests; |
|
7 | 4 | use Backpack\CRUD\Crud; |
8 | 5 | |
9 | 6 | /** |
@@ -4,10 +4,7 @@ |
||
4 | 4 | */ |
5 | 5 | namespace Backpack\Crud\Http\Controllers; |
6 | 6 | |
7 | -use Illuminate\Foundation\Bus\DispatchesJobs; |
|
8 | 7 | use Illuminate\Routing\Controller as BaseController; |
9 | -use Illuminate\Foundation\Validation\ValidatesRequests; |
|
10 | -use Illuminate\Foundation\Auth\Access\AuthorizesRequests; |
|
11 | 8 | use Backpack\Crud\Crud; |
12 | 9 | |
13 | 10 | /** |
@@ -1,9 +1,6 @@ |
||
1 | 1 | <?php namespace Backpack\CRUD; |
2 | 2 | |
3 | -use Illuminate\Database\Eloquent\Collection; |
|
4 | -use Illuminate\Database\Eloquent\Model; |
|
5 | 3 | use DB; |
6 | -use Lang; |
|
7 | 4 | |
8 | 5 | trait CrudTrait { |
9 | 6 |
@@ -238,7 +238,9 @@ discard block |
||
238 | 238 | $item = $this->model->findOrFail($id); |
239 | 239 | $updated = $item->update($this->compactFakeFields($data)); |
240 | 240 | |
241 | - if ($updated) $this->syncPivot($item, $data); |
|
241 | + if ($updated) { |
|
242 | + $this->syncPivot($item, $data); |
|
243 | + } |
|
242 | 244 | |
243 | 245 | return $item; |
244 | 246 | } |
@@ -436,7 +438,9 @@ discard block |
||
436 | 438 | */ |
437 | 439 | public function setModel($model_namespace) |
438 | 440 | { |
439 | - if (!class_exists($model_namespace)) throw new \Exception('This model does not exist.', 404); |
|
441 | + if (!class_exists($model_namespace)) { |
|
442 | + throw new \Exception('This model does not exist.', 404); |
|
443 | + } |
|
440 | 444 | |
441 | 445 | $this->model = new $model_namespace(); |
442 | 446 | $this->query = $this->model->select('*'); |
@@ -478,7 +482,9 @@ discard block |
||
478 | 482 | { |
479 | 483 | $complete_route = $route.'.index'; |
480 | 484 | |
481 | - if (!\Route::has($complete_route)) throw new \Exception('There are no routes for this route name.', 404); |
|
485 | + if (!\Route::has($complete_route)) { |
|
486 | + throw new \Exception('There are no routes for this route name.', 404); |
|
487 | + } |
|
482 | 488 | |
483 | 489 | $this->route = route($complete_route, $parameters); |
484 | 490 | $this->initButtons(); |
@@ -534,8 +540,7 @@ discard block |
||
534 | 540 | // if label and other details have been defined in the array |
535 | 541 | if (is_array($columns[0])) { |
536 | 542 | $this->addColumn($column); |
537 | - } |
|
538 | - else |
|
543 | + } else |
|
539 | 544 | { |
540 | 545 | $this->addColumn([ |
541 | 546 | 'name' => $column, |
@@ -831,11 +836,17 @@ discard block |
||
831 | 836 | */ |
832 | 837 | public function getFieldTypeFromDbColumnType($field) |
833 | 838 | { |
834 | - if (!array_key_exists($field, $this->field_types)) return 'text'; |
|
839 | + if (!array_key_exists($field, $this->field_types)) { |
|
840 | + return 'text'; |
|
841 | + } |
|
835 | 842 | |
836 | - if ($field == 'password') return 'password'; |
|
843 | + if ($field == 'password') { |
|
844 | + return 'password'; |
|
845 | + } |
|
837 | 846 | |
838 | - if ($field == 'email') return 'email'; |
|
847 | + if ($field == 'email') { |
|
848 | + return 'email'; |
|
849 | + } |
|
839 | 850 | |
840 | 851 | switch ($this->field_types[$field]['type']) |
841 | 852 | { |
@@ -908,7 +919,9 @@ discard block |
||
908 | 919 | $columns = \Schema::getColumnListing($this->model->getTable()); |
909 | 920 | $fillable = $this->model->getFillable(); |
910 | 921 | |
911 | - if (!empty($fillable)) $columns = array_intersect($columns, $fillable); |
|
922 | + if (!empty($fillable)) { |
|
923 | + $columns = array_intersect($columns, $fillable); |
|
924 | + } |
|
912 | 925 | |
913 | 926 | // but not updated_at, deleted_at |
914 | 927 | return array_values(array_diff($columns, [$this->model->getKeyName(), 'updated_at', 'deleted_at'])); |
@@ -1208,7 +1221,9 @@ discard block |
||
1208 | 1221 | |
1209 | 1222 | public function syncField($field) |
1210 | 1223 | { |
1211 | - if (array_key_exists('name', (array)$field)) return array_merge(['type' => $this->getFieldTypeFromDbColumnType($field['name']), 'value' => '', 'default' => null, 'values' => [], 'attributes' => []], $field); |
|
1224 | + if (array_key_exists('name', (array)$field)) { |
|
1225 | + return array_merge(['type' => $this->getFieldTypeFromDbColumnType($field['name']), 'value' => '', 'default' => null, 'values' => [], 'attributes' => []], $field); |
|
1226 | + } |
|
1212 | 1227 | |
1213 | 1228 | return false; |
1214 | 1229 | } |
@@ -1226,8 +1241,11 @@ discard block |
||
1226 | 1241 | |
1227 | 1242 | foreach ($this->{$fields} as $key => $field) |
1228 | 1243 | { |
1229 | - if (array_key_exists($field['name'], $this->relations) && $this->relations[$field['name']]['pivot']) $this->{$fields}[$key]['value'] = $this->entry->{$this->relations[$field['name']]['name']}()->lists($this->relations[$field['name']]['model']->getKeyName())->toArray(); |
|
1230 | - else $this->{$fields}[$key]['value'] = $this->entry->{$field['name']}; |
|
1244 | + if (array_key_exists($field['name'], $this->relations) && $this->relations[$field['name']]['pivot']) { |
|
1245 | + $this->{$fields}[$key]['value'] = $this->entry->{$this->relations[$field['name']]['name']}()->lists($this->relations[$field['name']]['model']->getKeyName())->toArray(); |
|
1246 | + } else { |
|
1247 | + $this->{$fields}[$key]['value'] = $this->entry->{$field['name']}; |
|
1248 | + } |
|
1231 | 1249 | } |
1232 | 1250 | } |
1233 | 1251 | } |
@@ -1247,7 +1265,9 @@ discard block |
||
1247 | 1265 | if (!empty($this->{$type})) |
1248 | 1266 | { |
1249 | 1267 | $this->{$type} = array_map(function($field) use ($fields, $attributes) { |
1250 | - if (in_array($field['name'], (array)$fields)) $field = array_merge($field, $attributes); |
|
1268 | + if (in_array($field['name'], (array)$fields)) { |
|
1269 | + $field = array_merge($field, $attributes); |
|
1270 | + } |
|
1251 | 1271 | |
1252 | 1272 | return $field; |
1253 | 1273 | }, $this->{$type}); |
@@ -1274,7 +1294,9 @@ discard block |
||
1274 | 1294 | |
1275 | 1295 | foreach ($this->sort[$items] as $item) |
1276 | 1296 | { |
1277 | - if (is_numeric($key = array_search($item, array_column($this->{$items}, 'name')))) $elements[] = $this->{$items}[$key]; |
|
1297 | + if (is_numeric($key = array_search($item, array_column($this->{$items}, 'name')))) { |
|
1298 | + $elements[] = $this->{$items}[$key]; |
|
1299 | + } |
|
1278 | 1300 | } |
1279 | 1301 | |
1280 | 1302 | return $this->{$items} = array_merge($elements, array_filter($this->{$items}, function($item) use($items) {return !in_array($item['name'], $this->sort[$items]);})); |
@@ -1293,9 +1315,13 @@ discard block |
||
1293 | 1315 | $order = (array)$order; |
1294 | 1316 | $values = $model->select('*'); |
1295 | 1317 | |
1296 | - if (!empty($where)) call_user_func_array([$values, $where[0]], array_slice($where, 1)); |
|
1318 | + if (!empty($where)) { |
|
1319 | + call_user_func_array([$values, $where[0]], array_slice($where, 1)); |
|
1320 | + } |
|
1297 | 1321 | |
1298 | - if (!empty($order)) call_user_func_array([$values, 'orderBy'], $order); |
|
1322 | + if (!empty($order)) { |
|
1323 | + call_user_func_array([$values, 'orderBy'], $order); |
|
1324 | + } |
|
1299 | 1325 | |
1300 | 1326 | return $values->get()->lists($field, $model->getKeyName())->toArray(); |
1301 | 1327 | } |
@@ -1304,8 +1330,11 @@ discard block |
||
1304 | 1330 | public function syncRelations($entity) |
1305 | 1331 | { |
1306 | 1332 | foreach ($this->relations as $field => $relation) { |
1307 | - if ($relation['pivot']) $this->add($entity, ['name' => $field, 'type' => 'multiselect', 'value' => [], 'values' => $this->relations[$field]['values']]); |
|
1308 | - else $this->sync($entity, $field, ['type' => 'select', 'values' => $this->relations[$field]['values']]); |
|
1333 | + if ($relation['pivot']) { |
|
1334 | + $this->add($entity, ['name' => $field, 'type' => 'multiselect', 'value' => [], 'values' => $this->relations[$field]['values']]); |
|
1335 | + } else { |
|
1336 | + $this->sync($entity, $field, ['type' => 'select', 'values' => $this->relations[$field]['values']]); |
|
1337 | + } |
|
1309 | 1338 | } |
1310 | 1339 | } |
1311 | 1340 |
@@ -45,7 +45,7 @@ |
||
45 | 45 | $secondary_ids[$second_item] = $second_item; |
46 | 46 | } |
47 | 47 | } |
48 | - }else{ //create dependecies from relation if not from validate error |
|
48 | + } else{ //create dependecies from relation if not from validate error |
|
49 | 49 | foreach( $primary_array as $primary_item ){ |
50 | 50 | foreach($primary_item[$secondary_dependency['entity']] as $second_item ){ |
51 | 51 | $secondary_ids[$second_item['id']] = $second_item['id']; |