Addition of repository to ease testing and maintainability

This commit is contained in:
Dane Everitt 2017-07-01 15:29:49 -05:00
parent 2f4ec64f2a
commit 5c3dc60d1e
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
22 changed files with 617 additions and 853 deletions

View file

@ -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()))
);
}
}

View file

@ -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(