39 lines
609 B
PHP
39 lines
609 B
PHP
<?php
|
|
|
|
|
|
|
|
namespace app\common\model\store;
|
|
|
|
|
|
use app\common\model\BaseModel;
|
|
|
|
class CityArea extends BaseModel
|
|
{
|
|
|
|
public static function tablePk(): ?string
|
|
{
|
|
return 'id';
|
|
}
|
|
|
|
public static function tableName(): string
|
|
{
|
|
return 'city_area';
|
|
}
|
|
|
|
public function parent()
|
|
{
|
|
return $this->hasOne(self::class,'id','parent_id');
|
|
}
|
|
|
|
public function getChildrenAttr()
|
|
{
|
|
return [];
|
|
}
|
|
|
|
public function getHasChildrenAttr()
|
|
{
|
|
$count = self::where('parent_id',$this->id)->count();
|
|
return $count ? true : false;
|
|
}
|
|
}
|