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
This commit is contained in:
67
app/Models/Barangay/Resident.php
Normal file
67
app/Models/Barangay/Resident.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models\Barangay;
|
||||
|
||||
use App\Models\Model;
|
||||
use Hypervel\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class Resident extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected ?string $table = 'barangay_residents';
|
||||
|
||||
protected array $fillable = [
|
||||
'hashkey', 'user_id', 'firstname', 'middlename', 'lastname', 'suffix',
|
||||
'dob', 'birthplace', 'gender', 'civil_status', 'citizenship', 'religion',
|
||||
'occupation', 'monthly_income', 'blood_type',
|
||||
'voter_status', 'registered_voter_id', 'voter_precinct', 'head_of_household',
|
||||
'purok', 'street', 'barangay', 'city', 'province', 'region',
|
||||
'philhealth_id', 'sss_id', 'gsis_id', 'tin',
|
||||
'emergency_contact_name', 'emergency_contact_phone', 'emergency_contact_address',
|
||||
'is_active', 'created_by', 'updated_by',
|
||||
];
|
||||
|
||||
protected array $casts = [
|
||||
'dob' => 'date',
|
||||
'monthly_income' => 'decimal:2',
|
||||
'voter_status' => 'boolean',
|
||||
'head_of_household' => 'boolean',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\User::class, 'user_id');
|
||||
}
|
||||
|
||||
public function household()
|
||||
{
|
||||
return $this->hasOne(Household::class, 'head_resident_id');
|
||||
}
|
||||
|
||||
public function householdMemberships()
|
||||
{
|
||||
return $this->hasMany(HouseholdMember::class, 'resident_id');
|
||||
}
|
||||
|
||||
public function documentRequests()
|
||||
{
|
||||
return $this->hasMany(DocumentRequest::class, 'resident_user_id', 'user_id');
|
||||
}
|
||||
|
||||
public function scopeActive($query)
|
||||
{
|
||||
return $query->where('is_active', true);
|
||||
}
|
||||
|
||||
public function getFullnameAttribute(): string
|
||||
{
|
||||
$parts = array_filter([$this->firstname, $this->middlename, $this->lastname]);
|
||||
$name = implode(' ', $parts);
|
||||
if ($this->suffix) $name .= ', ' . $this->suffix;
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user