belongsTo('App\Category'); } public function place() { return $this->belongsTo('App\Place'); } public function area() { return $this->belongsTo('App\Area'); } public function attributes() { return $this->hasMany('App\Attribute'); } public function attribute($key) { $attribute = $this->attributes()->where('key', $key)->first(); return $attribute ? $attribute->value : null; } public function getThumbnailAttribute() { return $this->images->count() ? $this->images->first()->thumbnail : 'images/no-photo.png'; } public function scopeFeatured($query) { return $query->whereFeatured(1); } }