44 lines
1.0 KiB
PHP
44 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace Modules\Investment\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class InvestmentLimitProfileRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
$isCreate = $this->isMethod('POST');
|
|
$isUpdate = $this->isMethod('PUT') || $this->isMethod('PATCH');
|
|
|
|
if (! $isCreate && ! $isUpdate) {
|
|
return [];
|
|
}
|
|
|
|
$nameRule = Rule::unique('investment_limit_profiles', 'name');
|
|
|
|
if ($isUpdate) {
|
|
$nameRule = $nameRule->ignore($this->route('investment_limit_profile'));
|
|
}
|
|
|
|
return [
|
|
'name' => ['required', 'string', 'max:100', $nameRule],
|
|
'description' => ['nullable', 'string'],
|
|
];
|
|
}
|
|
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'name.required' => 'Nama profil had diperlukan.',
|
|
'name.unique' => 'Nama profil had sudah wujud.',
|
|
];
|
|
}
|
|
}
|