first commit
This commit is contained in:
47
app/Http/Requests/Invitation/CreateInvitationRequest.php
Normal file
47
app/Http/Requests/Invitation/CreateInvitationRequest.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Invitation;
|
||||
|
||||
use App\Enums\Role;
|
||||
use App\Http\Requests\CattrFormRequest;
|
||||
use App\Models\Invitation;
|
||||
use Illuminate\Validation\Rules\Enum;
|
||||
|
||||
class CreateInvitationRequest extends CattrFormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if user authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function _authorize(): bool
|
||||
{
|
||||
return $this->user()->can('create', Invitation::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function _rules(): array
|
||||
{
|
||||
return [
|
||||
'users' => 'required|array',
|
||||
'users.*.email' => 'required|email|unique:users,email|unique:invitations,email',
|
||||
'users.*.role_id' => ['required', new Enum(Role::class)],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function attributes(): array
|
||||
{
|
||||
return [
|
||||
'users.*.email' => 'Email'
|
||||
];
|
||||
}
|
||||
}
|
||||
29
app/Http/Requests/Invitation/DestroyInvitationRequest.php
Normal file
29
app/Http/Requests/Invitation/DestroyInvitationRequest.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Invitation;
|
||||
|
||||
use App\Http\Requests\CattrFormRequest;
|
||||
use App\Models\Invitation;
|
||||
|
||||
class DestroyInvitationRequest extends CattrFormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if user authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function _authorize(): bool
|
||||
{
|
||||
return $this->user()->can('destroy', Invitation::find(request('id')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function _rules(): array
|
||||
{
|
||||
return ['id' => 'required|int|exists:invitations,id'];
|
||||
}
|
||||
}
|
||||
30
app/Http/Requests/Invitation/ListInvitationRequest.php
Normal file
30
app/Http/Requests/Invitation/ListInvitationRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Invitation;
|
||||
|
||||
use App\Helpers\QueryHelper;
|
||||
use App\Http\Requests\CattrFormRequest;
|
||||
use App\Models\Invitation;
|
||||
|
||||
class ListInvitationRequest extends CattrFormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if user authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function _authorize(): bool
|
||||
{
|
||||
return $this->user()->can('viewAny', Invitation::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function _rules(): array
|
||||
{
|
||||
return QueryHelper::getValidationRules();
|
||||
}
|
||||
}
|
||||
31
app/Http/Requests/Invitation/ShowInvitationRequest.php
Normal file
31
app/Http/Requests/Invitation/ShowInvitationRequest.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Invitation;
|
||||
|
||||
use App\Http\Requests\CattrFormRequest;
|
||||
use App\Models\Invitation;
|
||||
|
||||
class ShowInvitationRequest extends CattrFormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if user authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function _authorize(): bool
|
||||
{
|
||||
return $this->user()->can('view', Invitation::find(request('id')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function _rules(): array
|
||||
{
|
||||
return [
|
||||
'id' => 'required|integer|exists:invitations,id'
|
||||
];
|
||||
}
|
||||
}
|
||||
31
app/Http/Requests/Invitation/UpdateInvitationRequest.php
Normal file
31
app/Http/Requests/Invitation/UpdateInvitationRequest.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Invitation;
|
||||
|
||||
use App\Http\Requests\CattrFormRequest;
|
||||
use App\Models\Invitation;
|
||||
|
||||
class UpdateInvitationRequest extends CattrFormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if user authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function _authorize(): bool
|
||||
{
|
||||
return $this->user()->can('update', Invitation::find(request('id')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function _rules(): array
|
||||
{
|
||||
return [
|
||||
'id' => 'required|integer|exists:invitations,id'
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user