12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace App\Models;
- use App\Traits\ModelHelpers;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Support\Facades\Log;
- class Advertisement extends Model
- {
- use ModelHelpers;
- //
- protected $table = "advertisements";
- protected $guarded = [];
- const DISPLAY_YES = 1;
- const DISPLAY_NO = 0;
- public static $displayMaps = [
- self::DISPLAY_NO => '未展示',
- self::DISPLAY_YES => '已展示',
- ];
- // 广告位
- public static function advertisementPositioin(){
- $data = [];
- $advertisementPositioinCategorySlug = config('systemConfig.sort.advertisement_position.slug','AdvertisementPosition');
- $ConfigCategory = ConfigCategory::where('slug',$advertisementPositioinCategorySlug)->first();
- $ConfigCategoryId = $ConfigCategory->id ?? '';
- if(empty($ConfigCategoryId)) {
- Log::error('找不到配置广告位数据');
- return $data;
- };
- $data = Config::where('category_id',$ConfigCategoryId)->get(['id','name','slug'])->toArray();
- return $data;
- }
- // 广告类型
- public static function advertisementType(){
- $data = [];
- $advertisementTypeCategorySlug = config('systemConfig.sort.advertisement_type.slug','AdvertisementType');
- $ConfigCategory = ConfigCategory::where('slug',$advertisementTypeCategorySlug)->first();
- $ConfigCategoryId = $ConfigCategory->id ?? '';
- if(empty($ConfigCategoryId)) {
- Log::error('找不到配置广告位数据');
- return $data;
- };
- $data = Config::where('category_id',$ConfigCategoryId)->get(['id','name','slug'])->toArray();
- return $data;
- }
- // 关联区域
- public function areas(){
- return $this->belongsTo(Area::class,'area_id','id');
- }
- }
|