diff --git a/app/Http/Controllers/IndexController.php b/app/Http/Controllers/IndexController.php index d478538..fb558db 100644 --- a/app/Http/Controllers/IndexController.php +++ b/app/Http/Controllers/IndexController.php @@ -2,6 +2,8 @@ namespace App\Http\Controllers; +use App\Models\Flight; +use App\Models\Tour; use Illuminate\Http\Request; class IndexController extends Controller @@ -9,6 +11,12 @@ class IndexController extends Controller // public function index() { - return view('index'); + $tours = Tour::query() + ->with(['file', 'tour_details','originAirport' , 'destinationAirport']) + ->orderByDesc('created_at') + ->limit(4) + ->get(); + + return view('index' , compact('tours')); } } diff --git a/app/Http/Controllers/TourController.php b/app/Http/Controllers/TourController.php new file mode 100644 index 0000000..68b4648 --- /dev/null +++ b/app/Http/Controllers/TourController.php @@ -0,0 +1,21 @@ +load([ + 'tour_details', + 'originAirport', + 'destinationAirport', + 'file', + ]); + + return view('tours.show', compact('tour')); + } +} diff --git a/app/Models/Airport.php b/app/Models/Airport.php index 3b80ffc..9f0e854 100644 --- a/app/Models/Airport.php +++ b/app/Models/Airport.php @@ -12,15 +12,16 @@ use Illuminate\Database\Eloquent\Model; /** * Class Airport - * + * * @property int $id * @property string $name * @property string $city * @property string $country * @property Carbon $created_at * @property Carbon $updated_at - * + * * @property Collection|Flight[] $flights + * @property Collection|Tour[] $tours * * @package App\Models */ @@ -38,4 +39,14 @@ class Airport extends Model { return $this->hasMany(Flight::class, 'origin_airports_id'); } + + public function originTours() + { + return $this->hasMany(Tour::class, 'origin_airports_id'); + } + + public function destinationTours() + { + return $this->hasMany(Tour::class, 'destination_airports_id'); + } } diff --git a/app/Models/Tour.php b/app/Models/Tour.php index 1d0b6a3..54295e5 100644 --- a/app/Models/Tour.php +++ b/app/Models/Tour.php @@ -12,17 +12,21 @@ use Illuminate\Database\Eloquent\Model; /** * Class Tour - * + * * @property int $id * @property string $title - * @property int $file_id + * @property int|null $file_id * @property string $tour_type * @property string $summary * @property string $description * @property Carbon $created_at * @property Carbon $updated_at - * - * @property File $file + * @property int $origin_airports_id + * @property int $destination_airports_id + * + * @property Airport $originAirport + * @property Airport $destinationAirport + * @property File|null $file * @property Collection|TourDetail[] $tour_details * * @package App\Models @@ -32,7 +36,9 @@ class Tour extends Model protected $table = 'tours'; protected $casts = [ - 'file_id' => 'int' + 'file_id' => 'int', + 'origin_airports_id' => 'int', + 'destination_airports_id' => 'int' ]; protected $fillable = [ @@ -40,9 +46,21 @@ class Tour extends Model 'file_id', 'tour_type', 'summary', - 'description' + 'description', + 'origin_airports_id', + 'destination_airports_id' ]; + public function originAirport() + { + return $this->belongsTo(Airport::class, 'origin_airports_id'); + } + + public function destinationAirport() + { + return $this->belongsTo(Airport::class, 'destination_airports_id'); + } + public function file() { return $this->belongsTo(File::class); diff --git a/resources/views/components/flightcard.blade.php b/resources/views/components/flightcard.blade.php new file mode 100644 index 0000000..99cbd62 --- /dev/null +++ b/resources/views/components/flightcard.blade.php @@ -0,0 +1,33 @@ +
25/B جاده میلف خیابان انقلاب
-25/B جاده میلف خیابان انقلاب
-25/B جاده میلف خیابان انقلاب
-25/B جاده میلف خیابان انقلاب
-25/B جاده میلف خیابان انقلاب
-25/B جاده میلف خیابان انقلاب
-25/B جاده میلف خیابان انقلاب
-25/B جاده میلف خیابان انقلاب
-