koel/app/Http/Requests/API/UserUpdateRequest.php
Pedro Borges 899c7176c1 Use Laravel built-in authorization
The comment below motivated me to find a better solution for the
repeated authorisation checks:

```php
// This can't be put into a Request authorize(), due to Laravel(?)'s
limitation.
```

This is the result.
2015-12-14 14:27:26 -02:00

29 lines
570 B
PHP

<?php
namespace App\Http\Requests\API;
class UserUpdateRequest extends Request
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return auth()->user()->is_admin;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required',
'email' => 'required|email|unique:users,email,'.$this->route('user')->id,
];
}
}