Feature #16 : Status Permohonan
This commit is contained in:
43
app/Http/Requests/StatusPermohonanRequest.php
Normal file
43
app/Http/Requests/StatusPermohonanRequest.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class StatusPermohonanRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*/
|
||||
public function rules()
|
||||
: array
|
||||
{
|
||||
$rules = [
|
||||
'description' => 'nullable|max:255',
|
||||
'status' => 'required|boolean',
|
||||
];
|
||||
|
||||
if ($this->method() == 'PUT') {
|
||||
$rules['name'] = 'required|max:50|unique:status_permohonan,name,' . $this->id;
|
||||
} else {
|
||||
$rules['name'] = 'required|max:50|unique:status_permohonan,name';
|
||||
}
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize()
|
||||
: bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function prepareForValidation()
|
||||
{
|
||||
$this->merge([
|
||||
'status' => isset($this->status) ? 1 : 0,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user