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:
140
app/Models/PeriodeStatement.php
Normal file
140
app/Models/PeriodeStatement.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Webstatement\Models;
|
||||
|
||||
use Modules\Usermanagement\Models\User;
|
||||
|
||||
// use Modules\Webstatement\Database\Factories\PeriodeStatementFactory;
|
||||
|
||||
class PeriodeStatement extends Base
|
||||
{
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'periode',
|
||||
'status',
|
||||
'authorized_status',
|
||||
'notes',
|
||||
'processed_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
'authorized_by',
|
||||
'authorized_at'
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'processed_at' => 'datetime',
|
||||
'authorized_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the user who authorized this record.
|
||||
*/
|
||||
public function authorizer()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'authorized_by');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the formatted periode (YYYY-MM)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFormattedPeriodeAttribute()
|
||||
{
|
||||
return $this->periode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include pending statements.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopePending($query)
|
||||
{
|
||||
return $query->where('status', 'pending');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include processing statements.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeProcessing($query)
|
||||
{
|
||||
return $query->where('status', 'processing');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include completed statements.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeCompleted($query)
|
||||
{
|
||||
return $query->where('status', 'completed');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include failed statements.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeFailed($query)
|
||||
{
|
||||
return $query->where('status', 'failed');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include pending authorization statements.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopePendingAuthorization($query)
|
||||
{
|
||||
return $query->where('authorized_status', 'pending');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include approved statements.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeApproved($query)
|
||||
{
|
||||
return $query->where('authorized_status', 'approved');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include rejected statements.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeRejected($query)
|
||||
{
|
||||
return $query->where('authorized_status', 'rejected');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user