| Total Complexity | 6 |
| Total Lines | 56 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class Spot extends Model |
||
| 8 | { |
||
| 9 | protected $fillable = [ |
||
| 10 | 'name', |
||
| 11 | 'slug', |
||
| 12 | 'address', |
||
| 13 | 'email', |
||
| 14 | 'phone_number', |
||
| 15 | 'city', |
||
| 16 | 'country_id', |
||
| 17 | 'image', |
||
| 18 | 'website', |
||
| 19 | 'latitude', |
||
| 20 | 'longitude', |
||
| 21 | 'is_approved', |
||
| 22 | 'is_featured', |
||
| 23 | ]; |
||
| 24 | |||
| 25 | public function getRouteKeyName() |
||
| 26 | { |
||
| 27 | return 'slug'; |
||
| 28 | } |
||
| 29 | |||
| 30 | public function country() |
||
| 31 | { |
||
| 32 | return $this->belongsTo(Country::class); |
||
| 33 | } |
||
| 34 | |||
| 35 | public function getImageAttribute($imagePath) |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Returns the 3 most recent Spots that have an image |
||
| 42 | * and are approved |
||
| 43 | * |
||
| 44 | * @param $query |
||
| 45 | * @param int $take |
||
| 46 | */ |
||
| 47 | public function scopeMostRecent($query, $take = 3) |
||
| 54 | } |
||
| 55 | |||
| 56 | public function scopeFeatured($query, $take = 3) |
||
| 63 | } |
||
| 64 | } |
||
| 65 |