You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

39 lines
813 B

<?php
namespace App\Model\v3;
use App\Model\Model;
class Market extends Model
{
protected $table = 'lanzu_market';
protected $appends = [
'province_name',
'city_name',
'region_name'
];
public function getProvinceNameAttribute()
{
$area = Area::query()->find($this->attributes['province_id']);
return $area->name ?? '';
}
public function getCityNameAttribute()
{
$area = Area::query()->find($this->attributes['city_id']);
return $area->name ?? '';
}
public function getRegionNameAttribute()
{
$area = Area::query()->find($this->attributes['region_id']);
return $area->name ?? '';
}
public function stores()
{
return $this->hasMany(Store::class,'market_id','id');
}
}