Addition of repository to ease testing and maintainability
This commit is contained in:
parent
2f4ec64f2a
commit
5c3dc60d1e
22 changed files with 617 additions and 853 deletions
|
@ -28,6 +28,8 @@ use Illuminate\Foundation\Http\FormRequest;
|
|||
|
||||
abstract class AdminFormRequest extends FormRequest
|
||||
{
|
||||
abstract public function rules();
|
||||
|
||||
/**
|
||||
* Determine if the user is an admin and has permission to access this
|
||||
* form controller in the first place.
|
||||
|
@ -47,12 +49,14 @@ abstract class AdminFormRequest extends FormRequest
|
|||
* Return only the fields that we are interested in from the request.
|
||||
* This will include empty fields as a null value.
|
||||
*
|
||||
* @param array $only
|
||||
* @return array
|
||||
*/
|
||||
public function normalize()
|
||||
public function normalize($only = [])
|
||||
{
|
||||
return $this->only(
|
||||
array_keys($this->rules())
|
||||
return array_merge(
|
||||
$this->only($only),
|
||||
$this->intersect(array_keys($this->rules()))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ class UserFormRequest extends AdminFormRequest
|
|||
return User::getCreateRules();
|
||||
}
|
||||
|
||||
public function normalize()
|
||||
public function normalize($only = [])
|
||||
{
|
||||
if ($this->method === 'PATCH') {
|
||||
return array_merge(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue