feat(webstatement): implement periode statement management feature
- Menambahkan menu "Periode Statement" pada module.json dengan akses untuk role administrator. - Menambahkan model `PeriodeStatement` dengan fitur tracking user dan scoped query. - Menyediakan controller `PeriodeStatementController` dengan fungsi CRUD, otorisasi, proses, ekspor data ke Excel, dan datatables. - Menambahkan request validation melalui `PeriodeStatementRequest`. - Menyediakan view untuk list, create, edit, dan otorisasi periode statement. - Menambahkan routing termasuk resource routes dan breadcrumbs untuk mendukung fitur ini. - Menambahkan migrasi database `periode_statements` dengan kolom untuk menyimpan data periode, status, otorisasi, serta metadata. - Fitur ini memungkinkan pengelolaan dan pemrosesan periode statement secara terstruktur dan aman. Signed-off-by: Daeng Deni Mardaeni <ddeni05@gmail.com>
This commit is contained in:
74
app/Http/Requests/PeriodeStatementRequest.php
Normal file
74
app/Http/Requests/PeriodeStatementRequest.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Webstatement\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class PeriodeStatementRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize()
|
||||
: bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*/
|
||||
public function rules()
|
||||
: array
|
||||
{
|
||||
$rules = [
|
||||
'periode' => [
|
||||
'required',
|
||||
'string',
|
||||
'max:255',
|
||||
'regex:/^\d{4}-\d{2}$/', // Format YYYY-MM
|
||||
],
|
||||
'notes' => [
|
||||
'nullable',
|
||||
'string',
|
||||
],
|
||||
];
|
||||
|
||||
// If we're updating an existing record, add a unique constraint that ignores the current record
|
||||
if ($this->isMethod('PUT') || $this->isMethod('PATCH')) {
|
||||
$rules['periode'][] = Rule::unique('periode_statements', 'periode')
|
||||
->ignore($this->route('periode_statement'));
|
||||
} else {
|
||||
// For new records, just check uniqueness
|
||||
$rules['periode'][] = 'unique:periode_statements,periode';
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get custom attributes for validator errors.
|
||||
*/
|
||||
public function attributes()
|
||||
: array
|
||||
{
|
||||
return [
|
||||
'periode' => 'Periode',
|
||||
'notes' => 'Notes',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the error messages for the defined validation rules.
|
||||
*/
|
||||
public function messages()
|
||||
: array
|
||||
{
|
||||
return [
|
||||
'periode.required' => 'The periode field is required.',
|
||||
'periode.unique' => 'This periode already exists.',
|
||||
'periode.regex' => 'The periode must be in the format YYYY-MM (e.g., 2023-01).',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user