39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?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'],
|
|
];
|
|
}
|
|
}
|