Files
2026-02-11 10:08:39 +07:00

80 lines
1.5 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Ward extends Model
{
use HasFactory;
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'wards';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = false;
/**
* The primary key for the model.
*
* @var string
*/
protected $primaryKey = 'code';
/**
* The "type" of the primary key ID.
*
* @var string
*/
protected $keyType = 'string';
/**
* Indicates if the IDs are auto-incrementing.
*
* @var bool
*/
public $incrementing = false;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'code',
'name',
'name_en',
'full_name',
'full_name_en',
'code_name',
'province_code',
'administrative_unit_id',
];
/**
* Get the province that owns the ward.
*/
public function province()
{
return $this->belongsTo(Province::class, 'province_code', 'code');
}
/**
* Get the administrative unit that owns the ward.
*/
public function administrativeUnit()
{
return $this->belongsTo(AdministrativeUnit::class, 'administrative_unit_id');
}
}