belongsTo(BusinessCategory::class, 'category_id')->select(['id', 'name']); } public function getCoverAttribute($val) { if (empty($val)) { return config('app.url') . '/default/headimg.png'; } return path_to_url($val); } public function setCoverAttribute($val) { $this->attributes['cover'] = url_to_path($val); } public function getPathAttribute($val) { if (empty($val)) { return null; } return path_to_url($val); } public function setPathAttribute($val) { $this->attributes['path'] = url_to_path($val); } }