first
This commit is contained in:
38
app/Http/Requests/Admin/Setup/UpsertPositionRequest.php
Normal file
38
app/Http/Requests/Admin/Setup/UpsertPositionRequest.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Admin\Setup;
|
||||
|
||||
use App\Models\Position;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UpsertPositionRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return $this->user()?->hasRole('Admin') === true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$position = $this->route('position');
|
||||
|
||||
return [
|
||||
'code' => [
|
||||
'required',
|
||||
'string',
|
||||
'max:50',
|
||||
Rule::unique('positions', 'code')->ignore($position instanceof Position ? $position->id : null),
|
||||
],
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'scope' => ['required', Rule::in(['pusat', 'saluran', 'external'])],
|
||||
'is_public_applyable' => ['nullable', 'boolean'],
|
||||
'is_assignable' => ['nullable', 'boolean'],
|
||||
'allows_dual_role' => ['nullable', 'boolean'],
|
||||
'sort_order' => ['nullable', 'integer', 'min:0', 'max:999'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user