first commit
This commit is contained in:
35
app/Http/Requests/Task/DestroyRelationRequest.php
Normal file
35
app/Http/Requests/Task/DestroyRelationRequest.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Task;
|
||||
|
||||
use App\Http\Requests\AuthorizesAfterValidation;
|
||||
use App\Models\Task;
|
||||
use App\Http\Requests\CattrFormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class DestroyRelationRequest extends CattrFormRequest
|
||||
{
|
||||
use AuthorizesAfterValidation;
|
||||
|
||||
public function authorizeValidated(): bool
|
||||
{
|
||||
return $this->user()->can('update', Task::find(request('parent_id')))
|
||||
&& $this->user()->can('update', Task::find(request('child_id')));
|
||||
}
|
||||
|
||||
public function _rules(): array
|
||||
{
|
||||
return [
|
||||
'parent_id' => [
|
||||
'required',
|
||||
'int',
|
||||
Rule::exists('tasks', 'id'),
|
||||
],
|
||||
'child_id' => [
|
||||
'required',
|
||||
'int',
|
||||
Rule::exists('tasks', 'id'),
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user