Skip to content

Commit 4a0a624

Browse files
committed
add invokable support to strippedRequest
1 parent b29cc1f commit 4a0a624

File tree

3 files changed

+31
-19
lines changed

3 files changed

+31
-19
lines changed

src/app/Library/CrudPanel/Traits/Fields.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,14 @@ public function getStrippedSaveRequest($request)
479479
{
480480
$setting = $this->getOperationSetting('strippedRequest');
481481

482+
// if an invokable class was passed
483+
// eg. \App\Http\Requests\BackpackStrippedRequest
484+
if (class_exists($setting)) {
485+
$setting = new $setting();
486+
return $setting($request);
487+
}
488+
489+
// if a closure was passed
482490
if (is_callable($setting)) {
483491
return $setting($request);
484492
}

src/config/backpack/operations/create.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,17 @@
3535
// Should we warn a user before leaving the page with unsaved changes?
3636
'warnBeforeLeaving' => false,
3737

38-
/**
39-
* Before saving the entry, how would you like the request to be stripped?
40-
* - false - fall back to Backpack's default (ONLY save inputs that have fields)
41-
* - closure - process your own request (example removes all inputs that begin with underscode).
42-
*
43-
* @param \Illuminate\Http\Request $request
44-
* @return array
45-
*/
38+
/**
39+
* Before saving the entry, how would you like the request to be stripped?
40+
* - false - use Backpack's default (ONLY save inputs that have fields)
41+
* - closure - custom request processing (quick, but will stop config caching)
42+
* - invokable class - eg. App\Http\Requests\StripBackpackRequest::class
43+
*
44+
* @param \Illuminate\Http\Request $request
45+
* @return array
46+
*/
47+
// 'strippedRequest' => App\Http\Requests\StripBackpackRequest::class,
4648
// 'strippedRequest' => (function ($request) {
4749
// return $request->except('_token', '_method', '_http_referrer', '_current_tab', '_save_action');
48-
// }),
50+
// }),
4951
];

src/config/backpack/operations/update.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
return [
1010
// Define the size/looks of the content div for all CRUDs
1111
// To override per view use $this->crud->setEditContentClass('class-string')
12-
'contentClass' => 'col-md-8 bold-labels',
12+
'contentClass' => 'col-md-8 bold-labels',
1313

1414
// When using tabbed forms (create & update), what kind of tabs would you like?
1515
'tabsType' => 'horizontal', //options: horizontal, vertical
@@ -35,15 +35,17 @@
3535
// Should we warn a user before leaving the page with unsaved changes?
3636
'warnBeforeLeaving' => false,
3737

38-
/**
39-
* Before saving the entry, how would you like the request to be stripped?
40-
* - false - fall back to Backpack's default (ONLY save inputs that have fields)
41-
* - closure - process your own request (example removes all inputs that begin with underscode).
42-
*
43-
* @param \Illuminate\Http\Request $request
44-
* @return array
45-
*/
38+
/**
39+
* Before saving the entry, how would you like the request to be stripped?
40+
* - false - use Backpack's default (ONLY save inputs that have fields)
41+
* - closure - custom request processing (quick, but will stop config caching)
42+
* - invokable class - eg. App\Http\Requests\StripBackpackRequest::class
43+
*
44+
* @param \Illuminate\Http\Request $request
45+
* @return array
46+
*/
47+
// 'strippedRequest' => App\Http\Requests\StripBackpackRequest::class,
4648
// 'strippedRequest' => (function ($request) {
4749
// return $request->except('_token', '_method', '_http_referrer', '_current_tab', '_save_action');
48-
// }),
50+
// }),
4951
];

0 commit comments

Comments
 (0)