Files

33 lines
697 B
PHP
Raw Permalink Normal View History

2026-01-24 14:03:11 +00:00
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class City extends Model
{
use HasFactory;
public $timestamps = false;
protected $fillable=[
'title',
'code',
'parent_id',
'has_children',
'level'
];
protected $casts = [
'has_children'=>'boolean'
];
static $LEVEL = [
1=>'استان',
2=>'شهر',
];
public function children(){
return $this->hasMany(City::class,'parent_id')->with('children');
}
public function parent(){
return $this->belongsTo(City::class,'parent_id')->with('parent');
}
}