26 lines
625 B
PHP
26 lines
625 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
|
|
class Tour extends Model
|
|
{
|
|
protected $fillable = ['name', 'internal_name', 'short_description'];
|
|
public $timestamps = false;
|
|
|
|
public function countries()
|
|
{
|
|
return $this->belongsToMany(Country::class, 'tour_countries', 'tour_id', 'country_id');
|
|
}
|
|
|
|
public static function featuredTours(){
|
|
return Tour::whereHas('countries.continent')
|
|
->with('countries.continent')
|
|
->inRandomOrder()
|
|
->limit(4)
|
|
->get();
|
|
}
|
|
}
|