Merge branch 'master' of https://git.putrakuningan.com/daengdeni/lpj into andydev
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
: array
|
||||
{
|
||||
$rules = [
|
||||
'debiture_id' => 'required|exists:debtures,id',
|
||||
'debiture_id' => 'required|exists:debitures,id',
|
||||
'pemilik_jaminan_id' => 'required',
|
||||
'jenis_jaminan_id' => 'required',
|
||||
'jenis_legalitas_jaminan_id' => 'required',
|
||||
|
||||
50
app/Http/Requests/PermohonanRequest.php
Normal file
50
app/Http/Requests/PermohonanRequest.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Requests;
|
||||
|
||||
use daengdeni\LaravelIdGenerator\IdGenerator;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class PermohonanRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*/
|
||||
public function rules()
|
||||
: array
|
||||
{
|
||||
$rules = [
|
||||
'nomor_registrasi' => 'nullable|string|max:10',
|
||||
'tanggal_permohonan' => 'nullable|date',
|
||||
'user_id' => 'nullable|exists:users,id',
|
||||
'branch_id' => 'required|exists:branches,id',
|
||||
'tujuan_penilaian_id' => 'required|exists:tujuan_penilaian,id',
|
||||
'debiture_id' => 'required|exists:debitures,id',
|
||||
'status' => 'required|string',
|
||||
];
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize()
|
||||
: bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function prepareForValidation()
|
||||
{
|
||||
if (!$this->id) {
|
||||
$this->merge([
|
||||
'nomor_registrasi' => IdGenerator::generate(
|
||||
['table' => 'permohonan', 'length' => 10, 'prefix'=>'REG', 'field' => 'nomor_registrasi'],
|
||||
),
|
||||
'tanggal_permohonan' => date('Y-m-d'),
|
||||
'user_id' => auth()->user()->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
45
app/Http/Requests/StatusPermohonanRequest.php
Normal file
45
app/Http/Requests/StatusPermohonanRequest.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
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,
|
||||
'slug'=> Str::slug($this->name)
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user