client api
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Province extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'provinces';
|
||||
|
||||
/**
|
||||
* 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',
|
||||
'administrative_unit_id',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the administrative unit that owns the province.
|
||||
*/
|
||||
public function administrativeUnit()
|
||||
{
|
||||
return $this->belongsTo(AdministrativeUnit::class, 'administrative_unit_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the wards for the province.
|
||||
*/
|
||||
public function wards()
|
||||
{
|
||||
return $this->hasMany(Ward::class, 'province_code', 'code');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user