We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -3,19 +3,17 @@ |
||
| 3 | 3 | namespace Backpack\CRUD\app\Http\Controllers; |
| 4 | 4 | |
| 5 | 5 | use Backpack\CRUD\CrudPanel; |
| 6 | -use Illuminate\Http\Request; |
|
| 7 | -use Illuminate\Support\Facades\Form as Form; |
|
| 6 | +use Backpack\CRUD\app\Http\Controllers\CrudFeatures\AjaxTable; |
|
| 7 | +use Backpack\CRUD\app\Http\Controllers\CrudFeatures\Reorder; |
|
| 8 | 8 | use Illuminate\Foundation\Bus\DispatchesJobs; |
| 9 | -use Illuminate\Routing\Controller as BaseController; |
|
| 10 | 9 | use Illuminate\Foundation\Validation\ValidatesRequests; |
| 11 | -use Backpack\CRUD\app\Http\Controllers\CrudFeatures\Reorder; |
|
| 12 | -use Backpack\CRUD\app\Http\Controllers\CrudFeatures\AjaxTable; |
|
| 10 | +use Illuminate\Http\Request; |
|
| 11 | +use Illuminate\Routing\Controller as BaseController; |
|
| 13 | 12 | // CRUD Traits for non-core features |
| 14 | 13 | use Backpack\CRUD\app\Http\Controllers\CrudFeatures\Revisions; |
| 15 | 14 | use Backpack\CRUD\app\Http\Controllers\CrudFeatures\SaveActions; |
| 16 | -use Backpack\CRUD\app\Http\Requests\CrudRequest as StoreRequest; |
|
| 17 | -use Backpack\CRUD\app\Http\Requests\CrudRequest as UpdateRequest; |
|
| 18 | 15 | use Backpack\CRUD\app\Http\Controllers\CrudFeatures\ShowDetailsRow; |
| 16 | +use Backpack\CRUD\app\Http\Requests\CrudRequest as UpdateRequest; |
|
| 19 | 17 | |
| 20 | 18 | class CrudController extends BaseController |
| 21 | 19 | { |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | |
| 126 | 126 | // show a success message |
| 127 | 127 | if($this->crud->model::find($item->id)) |
| 128 | - \Alert::success(trans('backpack::crud.insert_success'))->flash(); |
|
| 128 | + \Alert::success(trans('backpack::crud.insert_success'))->flash(); |
|
| 129 | 129 | |
| 130 | 130 | // save the redirect choice for next time |
| 131 | 131 | $this->setSaveAction(); |
@@ -159,18 +159,18 @@ discard block |
||
| 159 | 159 | if($this->crud->eagerLoad && !empty($this->crud->eagerLoad)) |
| 160 | 160 | foreach($this->crud->eagerLoad as $relation_name) |
| 161 | 161 | { |
| 162 | - if($this->data['entry'] && $rel = $this->data['entry']->{$relation_name}) |
|
| 163 | - { |
|
| 164 | - foreach($this->data['fields'] as $field_name => $field) |
|
| 165 | - { |
|
| 166 | - if(starts_with($field_name, $relation_name)) |
|
| 167 | - { |
|
| 162 | + if($this->data['entry'] && $rel = $this->data['entry']->{$relation_name}) |
|
| 163 | + { |
|
| 164 | + foreach($this->data['fields'] as $field_name => $field) |
|
| 165 | + { |
|
| 166 | + if(starts_with($field_name, $relation_name)) |
|
| 167 | + { |
|
| 168 | 168 | $column_name = str_replace("{$relation_name}.", '', $field_name); |
| 169 | 169 | |
| 170 | 170 | $this->data['fields'][$field_name]['value'] = $rel->{$column_name}; |
| 171 | - } |
|
| 172 | - } |
|
| 173 | - } |
|
| 171 | + } |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | // load the view from /resources/views/vendor/backpack/crud/ if it exists, otherwise load the one in the package |
@@ -271,23 +271,23 @@ discard block |
||
| 271 | 271 | |
| 272 | 272 | public function handleEagerLoad($item) |
| 273 | 273 | { |
| 274 | - collect($this->crud->eagerLoad)->each(function($relation_name, $key) use ($item) |
|
| 275 | - { |
|
| 276 | - $data = collect(request()->all()) |
|
| 277 | - ->filter(function($value, $key) use ($relation_name) |
|
| 278 | - { |
|
| 279 | - return starts_with($key, $relation_name); |
|
| 280 | - }) |
|
| 281 | - ->mapWithKeys(function($value, $key) use ($relation_name) |
|
| 282 | - { |
|
| 283 | - return [str_replace("{$relation_name}_", '', $key) => $value ?? '']; |
|
| 284 | - }) |
|
| 285 | - ->toArray(); |
|
| 286 | - |
|
| 287 | - if(!$rel = $item->{$relation_name}) |
|
| 288 | - $item->{$relation_name}()->create($data); |
|
| 289 | - else |
|
| 290 | - $item->{$relation_name}->update($data); |
|
| 291 | - }); |
|
| 274 | + collect($this->crud->eagerLoad)->each(function($relation_name, $key) use ($item) |
|
| 275 | + { |
|
| 276 | + $data = collect(request()->all()) |
|
| 277 | + ->filter(function($value, $key) use ($relation_name) |
|
| 278 | + { |
|
| 279 | + return starts_with($key, $relation_name); |
|
| 280 | + }) |
|
| 281 | + ->mapWithKeys(function($value, $key) use ($relation_name) |
|
| 282 | + { |
|
| 283 | + return [str_replace("{$relation_name}_", '', $key) => $value ?? '']; |
|
| 284 | + }) |
|
| 285 | + ->toArray(); |
|
| 286 | + |
|
| 287 | + if(!$rel = $item->{$relation_name}) |
|
| 288 | + $item->{$relation_name}()->create($data); |
|
| 289 | + else |
|
| 290 | + $item->{$relation_name}->update($data); |
|
| 291 | + }); |
|
| 292 | 292 | } |
| 293 | 293 | } |
@@ -33,13 +33,13 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | public function __construct() |
| 35 | 35 | { |
| 36 | - if (! $this->crud) { |
|
| 36 | + if (!$this->crud) { |
|
| 37 | 37 | $this->crud = app()->make(CrudPanel::class); |
| 38 | - $this->crud->ajax_table=false; |
|
| 38 | + $this->crud->ajax_table = false; |
|
| 39 | 39 | |
| 40 | 40 | // call the setup function inside this closure to also have the request there |
| 41 | 41 | // this way, developers can use things stored in session (auth variables, etc) |
| 42 | - $this->middleware(function ($request, $next) { |
|
| 42 | + $this->middleware(function($request, $next) { |
|
| 43 | 43 | $this->request = $request; |
| 44 | 44 | $this->crud->request = $request; |
| 45 | 45 | $this->setup(); |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | $this->data['title'] = ucfirst($this->crud->entity_name_plural); |
| 70 | 70 | |
| 71 | 71 | // get all entries if AJAX is not enabled |
| 72 | - if (! $this->data['crud']->ajaxTable()) { |
|
| 72 | + if (!$this->data['crud']->ajaxTable()) { |
|
| 73 | 73 | $this->data['entries'] = $this->data['crud']->getEntries(); |
| 74 | 74 | } |
| 75 | 75 | |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | $this->data['entry'] = $this->crud->entry = $item; |
| 125 | 125 | |
| 126 | 126 | // show a success message |
| 127 | - if($this->crud->model::find($item->id)) |
|
| 127 | + if ($this->crud->model::find($item->id)) |
|
| 128 | 128 | \Alert::success(trans('backpack::crud.insert_success'))->flash(); |
| 129 | 129 | |
| 130 | 130 | // save the redirect choice for next time |
@@ -156,14 +156,14 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | $this->data['id'] = $id; |
| 158 | 158 | |
| 159 | - if($this->crud->eagerLoad && !empty($this->crud->eagerLoad)) |
|
| 160 | - foreach($this->crud->eagerLoad as $relation_name) |
|
| 159 | + if ($this->crud->eagerLoad && !empty($this->crud->eagerLoad)) |
|
| 160 | + foreach ($this->crud->eagerLoad as $relation_name) |
|
| 161 | 161 | { |
| 162 | - if($this->data['entry'] && $rel = $this->data['entry']->{$relation_name}) |
|
| 162 | + if ($this->data['entry'] && $rel = $this->data['entry']->{$relation_name}) |
|
| 163 | 163 | { |
| 164 | - foreach($this->data['fields'] as $field_name => $field) |
|
| 164 | + foreach ($this->data['fields'] as $field_name => $field) |
|
| 165 | 165 | { |
| 166 | - if(starts_with($field_name, $relation_name)) |
|
| 166 | + if (starts_with($field_name, $relation_name)) |
|
| 167 | 167 | { |
| 168 | 168 | $column_name = str_replace("{$relation_name}.", '', $field_name); |
| 169 | 169 | |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | }) |
| 285 | 285 | ->toArray(); |
| 286 | 286 | |
| 287 | - if(!$rel = $item->{$relation_name}) |
|
| 287 | + if (!$rel = $item->{$relation_name}) |
|
| 288 | 288 | $item->{$relation_name}()->create($data); |
| 289 | 289 | else |
| 290 | 290 | $item->{$relation_name}->update($data); |
@@ -124,8 +124,9 @@ discard block |
||
| 124 | 124 | $this->data['entry'] = $this->crud->entry = $item; |
| 125 | 125 | |
| 126 | 126 | // show a success message |
| 127 | - if($this->crud->model::find($item->id)) |
|
| 128 | - \Alert::success(trans('backpack::crud.insert_success'))->flash(); |
|
| 127 | + if($this->crud->model::find($item->id)) { |
|
| 128 | + \Alert::success(trans('backpack::crud.insert_success'))->flash(); |
|
| 129 | + } |
|
| 129 | 130 | |
| 130 | 131 | // save the redirect choice for next time |
| 131 | 132 | $this->setSaveAction(); |
@@ -156,8 +157,8 @@ discard block |
||
| 156 | 157 | |
| 157 | 158 | $this->data['id'] = $id; |
| 158 | 159 | |
| 159 | - if($this->crud->eagerLoad && !empty($this->crud->eagerLoad)) |
|
| 160 | - foreach($this->crud->eagerLoad as $relation_name) |
|
| 160 | + if($this->crud->eagerLoad && !empty($this->crud->eagerLoad)) { |
|
| 161 | + foreach($this->crud->eagerLoad as $relation_name) |
|
| 161 | 162 | { |
| 162 | 163 | if($this->data['entry'] && $rel = $this->data['entry']->{$relation_name}) |
| 163 | 164 | { |
@@ -166,6 +167,7 @@ discard block |
||
| 166 | 167 | if(starts_with($field_name, $relation_name)) |
| 167 | 168 | { |
| 168 | 169 | $column_name = str_replace("{$relation_name}.", '', $field_name); |
| 170 | + } |
|
| 169 | 171 | |
| 170 | 172 | $this->data['fields'][$field_name]['value'] = $rel->{$column_name}; |
| 171 | 173 | } |
@@ -284,10 +286,11 @@ discard block |
||
| 284 | 286 | }) |
| 285 | 287 | ->toArray(); |
| 286 | 288 | |
| 287 | - if(!$rel = $item->{$relation_name}) |
|
| 288 | - $item->{$relation_name}()->create($data); |
|
| 289 | - else |
|
| 290 | - $item->{$relation_name}->update($data); |
|
| 289 | + if(!$rel = $item->{$relation_name}) { |
|
| 290 | + $item->{$relation_name}()->create($data); |
|
| 291 | + } else { |
|
| 292 | + $item->{$relation_name}->update($data); |
|
| 293 | + } |
|
| 291 | 294 | }); |
| 292 | 295 | } |
| 293 | 296 | } |
@@ -2,27 +2,27 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Backpack\CRUD; |
| 4 | 4 | |
| 5 | -use Backpack\CRUD\PanelTraits\Read; |
|
| 6 | -use Backpack\CRUD\PanelTraits\Tabs; |
|
| 5 | +use Backedin\BackpackTraits\Backpack\Buttons; |
|
| 7 | 6 | use Backedin\BackpackTraits\Backpack\Query; |
| 8 | -use Backpack\CRUD\PanelTraits\Views; |
|
| 9 | 7 | use Backpack\CRUD\PanelTraits\Access; |
| 8 | +use Backpack\CRUD\PanelTraits\AutoFocus; |
|
| 9 | +use Backpack\CRUD\PanelTraits\AutoSet; |
|
| 10 | +use Backpack\CRUD\PanelTraits\Columns; |
|
| 10 | 11 | use Backpack\CRUD\PanelTraits\Create; |
| 11 | 12 | use Backpack\CRUD\PanelTraits\Delete; |
| 12 | 13 | use Backpack\CRUD\PanelTraits\Errors; |
| 14 | +use Backpack\CRUD\PanelTraits\FakeColumns; |
|
| 15 | +use Backpack\CRUD\PanelTraits\FakeFields; |
|
| 13 | 16 | use Backpack\CRUD\PanelTraits\Fields; |
| 14 | -use Backpack\CRUD\PanelTraits\Search; |
|
| 15 | -use Backpack\CRUD\PanelTraits\Update; |
|
| 16 | -use Backpack\CRUD\PanelTraits\AutoSet; |
|
| 17 | -use Backedin\BackpackTraits\Backpack\Buttons; |
|
| 18 | -use Backpack\CRUD\PanelTraits\Columns; |
|
| 19 | 17 | use Backpack\CRUD\PanelTraits\Filters; |
| 18 | +use Backpack\CRUD\PanelTraits\Read; |
|
| 20 | 19 | use Backpack\CRUD\PanelTraits\Reorder; |
| 21 | -use Backpack\CRUD\PanelTraits\AutoFocus; |
|
| 22 | -use Backpack\CRUD\PanelTraits\FakeFields; |
|
| 23 | -use Backpack\CRUD\PanelTraits\FakeColumns; |
|
| 24 | -use Illuminate\Database\Eloquent\Collection; |
|
| 20 | +use Backpack\CRUD\PanelTraits\Search; |
|
| 21 | +use Backpack\CRUD\PanelTraits\Tabs; |
|
| 22 | +use Backpack\CRUD\PanelTraits\Update; |
|
| 23 | +use Backpack\CRUD\PanelTraits\Views; |
|
| 25 | 24 | use Backpack\CRUD\PanelTraits\ViewsAndRestoresRevisions; |
| 25 | +use Illuminate\Database\Eloquent\Collection; |
|
| 26 | 26 | |
| 27 | 27 | class CrudPanel |
| 28 | 28 | { |
@@ -268,26 +268,26 @@ |
||
| 268 | 268 | */ |
| 269 | 269 | public function getRelationModel($relationString, $length = null, $model = null) |
| 270 | 270 | { |
| 271 | - if(!$model = $this->model->find($this->getLastParameter())) |
|
| 272 | - { |
|
| 273 | - $model = $this->model; |
|
| 274 | - } |
|
| 271 | + if(!$model = $this->model->find($this->getLastParameter())) |
|
| 272 | + { |
|
| 273 | + $model = $this->model; |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - $relationArray = explode('.', $relationString); |
|
| 276 | + $relationArray = explode('.', $relationString); |
|
| 277 | 277 | |
| 278 | - if (! isset($length)) { |
|
| 279 | - $length = count($relationArray); |
|
| 280 | - } |
|
| 278 | + if (! isset($length)) { |
|
| 279 | + $length = count($relationArray); |
|
| 280 | + } |
|
| 281 | 281 | |
| 282 | - if (! isset($model)) { |
|
| 283 | - $model = $this->model; |
|
| 284 | - } |
|
| 282 | + if (! isset($model)) { |
|
| 283 | + $model = $this->model; |
|
| 284 | + } |
|
| 285 | 285 | |
| 286 | - $result = array_reduce(array_splice($relationArray, 0, $length), function ($obj, $method) { |
|
| 287 | - return $obj->$method()->getRelated(); |
|
| 288 | - }, $model); |
|
| 286 | + $result = array_reduce(array_splice($relationArray, 0, $length), function ($obj, $method) { |
|
| 287 | + return $obj->$method()->getRelated(); |
|
| 288 | + }, $model); |
|
| 289 | 289 | |
| 290 | - return get_class($result); |
|
| 290 | + return get_class($result); |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | /** |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public function setModel($model_namespace) |
| 92 | 92 | { |
| 93 | - if (! class_exists($model_namespace)) { |
|
| 93 | + if (!class_exists($model_namespace)) { |
|
| 94 | 94 | throw new \Exception('This model does not exist.', 404); |
| 95 | 95 | } |
| 96 | 96 | |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | { |
| 141 | 141 | $complete_route = $route.'.index'; |
| 142 | 142 | |
| 143 | - if (! \Route::has($complete_route)) { |
|
| 143 | + if (!\Route::has($complete_route)) { |
|
| 144 | 144 | throw new \Exception('There are no routes for this route name.', 404); |
| 145 | 145 | } |
| 146 | 146 | |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | */ |
| 191 | 191 | public function getFirstOfItsTypeInArray($type, $array) |
| 192 | 192 | { |
| 193 | - return array_first($array, function ($item) use ($type) { |
|
| 193 | + return array_first($array, function($item) use ($type) { |
|
| 194 | 194 | return $item['type'] == $type; |
| 195 | 195 | }); |
| 196 | 196 | } |
@@ -207,8 +207,8 @@ discard block |
||
| 207 | 207 | |
| 208 | 208 | public function sync($type, $fields, $attributes) |
| 209 | 209 | { |
| 210 | - if (! empty($this->{$type})) { |
|
| 211 | - $this->{$type} = array_map(function ($field) use ($fields, $attributes) { |
|
| 210 | + if (!empty($this->{$type})) { |
|
| 211 | + $this->{$type} = array_map(function($field) use ($fields, $attributes) { |
|
| 212 | 212 | if (in_array($field['name'], (array) $fields)) { |
| 213 | 213 | $field = array_merge($field, $attributes); |
| 214 | 214 | } |
@@ -240,8 +240,8 @@ discard block |
||
| 240 | 240 | } |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | - return $this->{$items} = array_merge($elements, array_filter($this->{$items}, function ($item) use ($items) { |
|
| 244 | - return ! in_array($item['name'], $this->sort[$items]); |
|
| 243 | + return $this->{$items} = array_merge($elements, array_filter($this->{$items}, function($item) use ($items) { |
|
| 244 | + return !in_array($item['name'], $this->sort[$items]); |
|
| 245 | 245 | })); |
| 246 | 246 | } |
| 247 | 247 | |
@@ -268,22 +268,22 @@ discard block |
||
| 268 | 268 | */ |
| 269 | 269 | public function getRelationModel($relationString, $length = null, $model = null) |
| 270 | 270 | { |
| 271 | - if(!$model = $this->model->find($this->getLastParameter())) |
|
| 271 | + if (!$model = $this->model->find($this->getLastParameter())) |
|
| 272 | 272 | { |
| 273 | 273 | $model = $this->model; |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | $relationArray = explode('.', $relationString); |
| 277 | 277 | |
| 278 | - if (! isset($length)) { |
|
| 278 | + if (!isset($length)) { |
|
| 279 | 279 | $length = count($relationArray); |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | - if (! isset($model)) { |
|
| 282 | + if (!isset($model)) { |
|
| 283 | 283 | $model = $this->model; |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | - $result = array_reduce(array_splice($relationArray, 0, $length), function ($obj, $method) { |
|
| 286 | + $result = array_reduce(array_splice($relationArray, 0, $length), function($obj, $method) { |
|
| 287 | 287 | return $obj->$method()->getRelated(); |
| 288 | 288 | }, $model); |
| 289 | 289 | |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | $relation = $model->{$firstRelationName}; |
| 331 | 331 | |
| 332 | 332 | $results = []; |
| 333 | - if (! empty($relation)) { |
|
| 333 | + if (!empty($relation)) { |
|
| 334 | 334 | if ($relation instanceof Collection) { |
| 335 | 335 | $currentResults = $relation->toArray(); |
| 336 | 336 | } else { |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | |
| 340 | 340 | array_shift($relationArray); |
| 341 | 341 | |
| 342 | - if (! empty($relationArray)) { |
|
| 342 | + if (!empty($relationArray)) { |
|
| 343 | 343 | foreach ($currentResults as $currentResult) { |
| 344 | 344 | $results = array_merge($results, $this->getRelationModelInstances($currentResult, implode('.', $relationArray))); |
| 345 | 345 | } |