50 lines
1.0 KiB
PHP
50 lines
1.0 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\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class CityMunicipality extends Model
|
|
{
|
|
use HasFactory, SoftDeletes;
|
|
|
|
protected $table = 'cities_municipalities';
|
|
|
|
public const TYPE_CITY = 'city';
|
|
|
|
public const TYPE_MUNICIPALITY = 'municipality';
|
|
|
|
public const TYPE_SUB_MUNICIPALITY = 'sub_municipality';
|
|
|
|
protected $fillable = [
|
|
'psgc_code',
|
|
'code',
|
|
'name',
|
|
'province_id',
|
|
'type',
|
|
'is_capital',
|
|
'classification',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'is_capital' => 'boolean',
|
|
];
|
|
}
|
|
|
|
public function province(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Province::class);
|
|
}
|
|
|
|
public function barangays(): HasMany
|
|
{
|
|
return $this->hasMany(Barangay::class);
|
|
}
|
|
}
|