Files
Verde-Web/app/Models/Barangay.php
admin c8404564fe feat(backend): complete Modules 2 + 3 (geo + user management)
Module 2 — Geographic Data: PSGC tables (regions/provinces/cities/
barangays) with native geometry(polygon|point, 4326) columns; cascading
dropdown endpoints; ST_Contains-based GPS resolution; service-area CRUD
with barangay attach/detach; SamplePsgcSeeder + psgc:import command.

Module 3 — User Management: 5 role-specific profile tables (driver/
helper/scanner/store_partner with verification_status + rejection
reason); profile auto-created on register; admin user CRUD with
filters/pagination, suspend/activate, profile approve/reject;
self-service /me + /me/profile with role-aware validation that blocks
self-approval and resets rejected profiles to pending on resubmit.

69 feature tests passing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-29 23:59:56 +08:00

52 lines
1.3 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use MatanYadaev\EloquentSpatial\Objects\Point;
use MatanYadaev\EloquentSpatial\Objects\Polygon;
use MatanYadaev\EloquentSpatial\Traits\HasSpatial;
class Barangay extends Model
{
use HasFactory, HasSpatial, SoftDeletes;
public const URBAN = 'urban';
public const RURAL = 'rural';
public const URBAN_RURAL_UNKNOWN = 'unknown';
protected $fillable = [
'psgc_code',
'code',
'name',
'city_municipality_id',
'urban_rural',
'population',
'boundary',
'centroid',
];
protected function casts(): array
{
return [
'boundary' => Polygon::class,
'centroid' => Point::class,
];
}
public function cityMunicipality(): BelongsTo
{
return $this->belongsTo(CityMunicipality::class);
}
public function serviceAreas(): BelongsToMany
{
return $this->belongsToMany(ServiceArea::class, 'service_area_barangay')
->withTimestamps();
}
}