Files
BarangaySystem/app/Models/Barangay/Blotter.php
Jonathan Sykes fbb7e3ff37
Some checks failed
tests / PHP 8.2 (swoole-5.1.6) (push) Has been cancelled
tests / PHP 8.3 (swoole-5.1.6) (push) Has been cancelled
tests / PHP 8.4 (swoole-6.0) (push) Has been cancelled
feat: implement barangay system phases 2-14
Complete adaptation from BukidBountyApp to Philippine barangay governance:

- Barangay models: Resident, Household, HouseholdMember, Blotter, BlotterHearing,
  DocumentRequest, RequestPayment, RequestType, BarangayProject, BarangayBudget
- Controllers: ResidentController, HouseholdController, BlotterController,
  BlotterHearingController, DocumentRequestController, RequestTypeController,
  ProjectController, BudgetController, QRPHController, AdminConsoleController,
  UserController, FileController, ChapterController, LoginController
- Vue pages: Home, ManageResidents, ResidentProfile, ManageHouseholds, ManageBlotters,
  BlotterDetail, RequestDocument, ManageDocumentRequests, DocumentRequestDetail,
  ManageRequestTypes, ManageProjects, BudgetLedger, AdminConsole
- Barangay roles: PunongBarangay, Kagawad, Secretary, Treasurer, SK, Tanod, BHW, Staff, Resident
- UserPermissions matrix rewritten with barangay-specific permission mappings
- VueRouteMap replaced with barangay SPA routes
- UserActions enum references corrected across all controllers
- Removed all market/cooperative/POS/subscription code and models
2026-06-07 03:09:09 +08:00

71 lines
1.9 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Models\Barangay;
use App\Models\Model;
use App\Enums\Barangay\BlotterStatus;
use Hypervel\Database\Eloquent\SoftDeletes;
class Blotter extends Model
{
use SoftDeletes;
protected ?string $table = 'barangay_blotters';
protected array $fillable = [
'hashkey', 'blotter_no',
'complainant_user_id', 'complainant_name', 'complainant_contact', 'complainant_address',
'respondent_user_id', 'respondent_name', 'respondent_contact', 'respondent_address',
'incident_type', 'incident_date', 'incident_location', 'narrative',
'status', 'complaint_date', 'filed_by', 'assigned_officer_id',
'resolution', 'settlement_type', 'endorsed_to', 'is_active',
'created_by', 'updated_by',
];
protected array $casts = [
'incident_date' => 'date',
'complaint_date' => 'date',
'is_active' => 'boolean',
'status' => BlotterStatus::class,
];
public function complainant()
{
return $this->belongsTo(\App\Models\User::class, 'complainant_user_id');
}
public function respondent()
{
return $this->belongsTo(\App\Models\User::class, 'respondent_user_id');
}
public function assignedOfficer()
{
return $this->belongsTo(\App\Models\User::class, 'assigned_officer_id');
}
public function hearings()
{
return $this->hasMany(BlotterHearing::class, 'blotter_id');
}
public function nextHearing()
{
return $this->hearings()->where('status', 'SCHEDULED')->orderBy('hearing_date')->first();
}
public function scopeActive($query)
{
return $query->where('is_active', true);
}
public static function generateBlotterNo(): string
{
$year = date('Y');
$count = static::whereYear('created_at', $year)->count() + 1;
return sprintf('BLT-%s-%04d', $year, $count);
}
}