From 970786ae94ea468b68a36d34a6db47a19c6d79a1 Mon Sep 17 00:00:00 2001 From: hatame Date: Mon, 17 Aug 2026 11:36:19 +0330 Subject: [PATCH] git add . git commit "add tours pages, components and show views" --- app/Http/Controllers/HomeController.php | 24 ++- app/Http/Controllers/TourController.php | 15 +- app/Models/City.php | 4 +- app/Models/Province.php | 2 +- app/Models/Tour.php | 10 +- app/Models/TravelType.php | 8 +- composer.json | 1 + composer.lock | 185 +++++++++++++++++++++- public/assets/css/styles2.css.php | 157 ------------------ resources/views/components/tour.blade.php | 67 +++++--- resources/views/flights/show.blade.php | 161 ++++++++++++++++++- resources/views/home/index.blade.php | 36 +++-- resources/views/layouts/app.blade.php | 3 +- resources/views/tours/index.blade.php | 55 +++---- resources/views/tours/show.blade.php | 116 +++++++++++++- 15 files changed, 595 insertions(+), 249 deletions(-) diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 497e36a..1e5c764 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -10,10 +10,26 @@ class HomeController extends Controller { public function index() { - $newestFlight = Flight::latest()->take(10)->get(); - $flights=Flight::latest()->paginate(5); - $newestTour = Tour::latest()->take(10)->get(); + $newestFlight = Flight:: + where('departure_date', '>=', now()) + ->orderBy('departure_date', 'asc') + ->take(3) + ->get(); + $newestTour = Tour::latest() + ->take(10) + ->get(); - return view('home.index', compact('newestFlight','flights', 'newestTour')); + $flights = Flight::latest() + ->paginate(5); + + $tours = Tour::latest() + ->paginate(5); + + return view('home.index', compact( + 'newestFlight', + 'newestTour', + 'flights', + 'tours' + )); } } diff --git a/app/Http/Controllers/TourController.php b/app/Http/Controllers/TourController.php index 6b5f337..9a06251 100644 --- a/app/Http/Controllers/TourController.php +++ b/app/Http/Controllers/TourController.php @@ -6,19 +6,24 @@ use App\Models\Tour; class TourController extends Controller { - // صفحه لیست تورها: اسلایدر آخرین‌ها + گرید صفحه‌بندی‌شده public function index() { - $newestTour = Tour::latest()->take(10)->get(); - $tours = Tour::latest()->paginate(9); + $newestTour = Tour::with('travelType') + ->latest() + ->take(10) + ->get(); + + $tours = Tour::with('travelType') + ->latest() + ->paginate(5); return view('tours.index', compact('newestTour', 'tours')); } - // جزئیات تور + شمارنده بازدید + public function show(Tour $tour) { - $tour->increment('views'); + $tour->load('travelType'); return view('tours.show', compact('tour')); } diff --git a/app/Models/City.php b/app/Models/City.php index 248cc83..f0cc7fc 100644 --- a/app/Models/City.php +++ b/app/Models/City.php @@ -14,7 +14,7 @@ use Illuminate\Database\Eloquent\Model; * Class City * * @property int $id - * @property int $provinces + * @property int $province_id * @property string $name * @property Carbon $created_at * @property Carbon $updated_at @@ -33,7 +33,7 @@ class City extends Model ]; protected $fillable = [ - 'provinces', + 'province_id', 'name' ]; diff --git a/app/Models/Province.php b/app/Models/Province.php index 37e8455..3603111 100644 --- a/app/Models/Province.php +++ b/app/Models/Province.php @@ -34,7 +34,7 @@ class Province extends Model } public function cities() { - return $this->hasMany(City::class); + return $this->belongsTo(City::class); } } diff --git a/app/Models/Tour.php b/app/Models/Tour.php index 495f1d9..2e226ea 100644 --- a/app/Models/Tour.php +++ b/app/Models/Tour.php @@ -12,7 +12,7 @@ use Illuminate\Database\Eloquent\Model; /** * Class Tour - * + * * @property int $id * @property string $title * @property string $summary @@ -24,7 +24,7 @@ use Illuminate\Database\Eloquent\Model; * @property int $status * @property Carbon $created_at * @property Carbon $updated_at - * + * * @property Collection|Comment[] $comments * * @package App\Models @@ -56,4 +56,8 @@ class Tour extends Model { return $this->hasMany(Comment::class); } -} + public function travelType() + { + return $this->belongsTo(TravelType::class); + } + } diff --git a/app/Models/TravelType.php b/app/Models/TravelType.php index 2adf351..e5fed5c 100644 --- a/app/Models/TravelType.php +++ b/app/Models/TravelType.php @@ -11,7 +11,7 @@ use Illuminate\Database\Eloquent\Model; /** * Class TravelType - * + * * @property int $id * @property string $name * @property int $status @@ -33,4 +33,8 @@ class TravelType extends Model 'name', 'status' ]; -} + public function tours() + { + return $this->hasMany(Tour::class, 'travel_type_id'); + } + } diff --git a/composer.json b/composer.json index 91c2788..af831e2 100644 --- a/composer.json +++ b/composer.json @@ -7,6 +7,7 @@ "license": "MIT", "require": { "php": "^8.2", + "hekmatinasser/verta": "^9.0", "laravel/framework": "^12.0", "laravel/tinker": "^2.10.1", "sadegh19b/laravel-persian-validation": "^2.1" diff --git a/composer.lock b/composer.lock index d7fad92..b341a2a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "32f38eafa73f2600bea6b75e538fc42e", + "content-hash": "d2f9c73ad216c4d120251d41cec0c1ee", "packages": [ { "name": "brick/math", @@ -1058,6 +1058,189 @@ ], "time": "2026-07-17T13:53:03+00:00" }, + { + "name": "hekmatinasser/jalali", + "version": "v8.2.4", + "source": { + "type": "git", + "url": "https://github.com/hekmatinasser/jalali.git", + "reference": "423c848ec32fb36e9ab9610d82f98efa2de0f79d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hekmatinasser/jalali/zipball/423c848ec32fb36e9ab9610d82f98efa2de0f79d", + "reference": "423c848ec32fb36e9ab9610d82f98efa2de0f79d", + "shasum": "" + }, + "require": { + "hekmatinasser/notowo": "^1.0", + "php": "^8.0" + }, + "require-dev": { + "orchestra/testbench": "^4.18|^5.20|^6.24|^7.0" + }, + "type": "library", + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Hekmatinasser\\Jalali\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nasser Hekmati", + "email": "hekmati.nasser@gmail.com" + } + ], + "description": "This Package helps developers to work with Jalali Datetime class for PHP", + "keywords": [ + "Jalali", + "date", + "datetime", + "php", + "shamsi" + ], + "support": { + "issues": "https://github.com/hekmatinasser/jalali/issues", + "source": "https://github.com/hekmatinasser/jalali/tree/x8.2.3" + }, + "funding": [ + { + "url": "https://github.com/hekmatinasser", + "type": "github" + } + ], + "time": "2024-04-09T12:43:59+00:00" + }, + { + "name": "hekmatinasser/notowo", + "version": "v1.0.1", + "source": { + "type": "git", + "url": "https://github.com/hekmatinasser/notowo.git", + "reference": "c51ad5dcedac966dd93ce558ac7e6a84e0020d6d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hekmatinasser/notowo/zipball/c51ad5dcedac966dd93ce558ac7e6a84e0020d6d", + "reference": "c51ad5dcedac966dd93ce558ac7e6a84e0020d6d", + "shasum": "" + }, + "require": { + "php": ">=5.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Hekmatinasser\\Notowo\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nasser Hekmati", + "email": "hekmati.nasser@gmail.com" + } + ], + "description": "This Package helps developers change number to word for all language on Laravel freamwork PHP", + "keywords": [ + "Notowo", + "laravel", + "n2w", + "number", + "word" + ], + "support": { + "issues": "https://github.com/hekmatinasser/notowo/issues", + "source": "https://github.com/hekmatinasser/notowo/tree/v1.0.1" + }, + "time": "2017-09-22T13:41:16+00:00" + }, + { + "name": "hekmatinasser/verta", + "version": "v9.0", + "source": { + "type": "git", + "url": "https://github.com/hekmatinasser/verta.git", + "reference": "f3cff537f07ef302b1ea24f59e9c1d5e3a1c36cb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hekmatinasser/verta/zipball/f3cff537f07ef302b1ea24f59e9c1d5e3a1c36cb", + "reference": "f3cff537f07ef302b1ea24f59e9c1d5e3a1c36cb", + "shasum": "" + }, + "require": { + "hekmatinasser/jalali": "^8.2.3", + "illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0", + "illuminate/validation": "^8.0|^9.0|^10.0|^11.0|^12.0|^13.0", + "php": "^8.0" + }, + "require-dev": { + "orchestra/testbench": "^6.23|^7.0|^8.0|^11.0" + }, + "type": "library", + "extra": { + "laravel": { + "aliases": { + "Verta": "Hekmatinasser\\Verta\\Verta" + }, + "providers": [ + "Hekmatinasser\\Verta\\Laravel\\VertaServiceProvider" + ] + } + }, + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Hekmatinasser\\Verta\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nasser Hekmati", + "email": "hekmati.nasser@gmail.com" + } + ], + "description": "This Package helps developers to work with Jalali Datetime class for Laravel Framework PHP", + "keywords": [ + "Jalali", + "Verta", + "date", + "datetime", + "laravel", + "shamsi" + ], + "support": { + "issues": "https://github.com/hekmatinasser/verta/issues", + "source": "https://github.com/hekmatinasser/verta/tree/v9.0" + }, + "funding": [ + { + "url": "https://github.com/hekmatinasser", + "type": "github" + } + ], + "time": "2026-05-08T06:26:09+00:00" + }, { "name": "laravel/framework", "version": "v12.65.0", diff --git a/public/assets/css/styles2.css.php b/public/assets/css/styles2.css.php index 35fbc37..e69de29 100644 --- a/public/assets/css/styles2.css.php +++ b/public/assets/css/styles2.css.php @@ -1,157 +0,0 @@ - diff --git a/resources/views/components/tour.blade.php b/resources/views/components/tour.blade.php index f243280..533b28d 100644 --- a/resources/views/components/tour.blade.php +++ b/resources/views/components/tour.blade.php @@ -1,43 +1,66 @@ -
+
+
-
- @if($tour->image) - {{ $tour->title }} - @else -
- @endif - +
+ + {{ $tour->title }} + + + تور +
+ +
-
{{ $tour->title }}
- @if($tour->summary) -

{{ \Illuminate\Support\Str::limit($tour->summary, 70) }}

- @endif -
- - تاریخ حرکت: {{ optional($tour->departure_date)->format('Y/m/d') }} +
+ {{ $tour->title }} +
+ + + +
+ + + {{ $tour->travelType?->name ?? 'تور گردشگری' }} + + + + + + + + {{ \Carbon\Carbon::parse($tour->departure_date)->format('Y/m/d') }} + +
+ +
- + + {{ number_format($tour->price) }} تومان - - + + + + مشاهده +
+ +
+
diff --git a/resources/views/flights/show.blade.php b/resources/views/flights/show.blade.php index c66844e..673b2b3 100644 --- a/resources/views/flights/show.blade.php +++ b/resources/views/flights/show.blade.php @@ -1,3 +1,162 @@ + + +
@@ -54,7 +213,7 @@
تاریخ حرکت - {{ $flight->departure_date }} + {{ $flight->departure_date->toJalali()->format('Y/m/d') }}
diff --git a/resources/views/home/index.blade.php b/resources/views/home/index.blade.php index 368b6cc..e8e2eb7 100644 --- a/resources/views/home/index.blade.php +++ b/resources/views/home/index.blade.php @@ -8,29 +8,35 @@
@forelse($newestFlight as $flight) @include('components.flight') - @empty + @empty

هنوز پروازی ثبت نشده است.

@endforelse + @foreach($newestTour as $tour) + @include('components.tour', ['tour' => $tour]) + @endforeach +
-

همه پروازها و تورها

+

همه پروازها و تورها

-
- @forelse($flights as $flight) -
- @include('components.flight') -
- @empty -

چیزی برای نمایش وجود ندارد.

- @endforelse -
+
-
- {{ $flights->links() }} -
-
+ @foreach($flights as $flight) + @include('components.flight', ['flight' => $flight]) + @endforeach + + @foreach($tours as $tour) + @include('components.tour', ['tour' => $tour]) + @endforeach + +
+ +
+ {{ $flights->links() }} +
+ @endsection diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 99c8312..e0f4777 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -11,8 +11,7 @@ - - + @includeUnless(isset($withoutHeader),'layouts.header') diff --git a/resources/views/tours/index.blade.php b/resources/views/tours/index.blade.php index c4c6933..7c3dd0a 100644 --- a/resources/views/tours/index.blade.php +++ b/resources/views/tours/index.blade.php @@ -1,64 +1,51 @@ @foreach($tours as $tour) - +
- - - + {{ $tour->title }} - + src="{{ asset($tour->image) }}" alt="{{ $tour->title }}" > - +
- - + {{ $tour->title }} - +
- - - 📍 - - - {{ $tour->destination }} - + 📍 + {{ Str::limit($tour->summary, 60) }}
- +
-
- مدت تور - +
+ تاریخ حرکت - {{ $tour->duration }} روز + {{ \Carbon\Carbon::parse($tour->departure_date)->format('Y/m/d') }}
-
- ظرفیت +
+ نوع سفر - {{ $tour->capacity }} نفر + {{ $tour->travelType->name ?? '---' }}
- +
- - شروع قیمت از - + شروع قیمت از {{ number_format($tour->price) }} @@ -67,6 +54,12 @@
+ + + مشاهده تور + +
diff --git a/resources/views/tours/show.blade.php b/resources/views/tours/show.blade.php index 4530ca4..50cba9c 100644 --- a/resources/views/tours/show.blade.php +++ b/resources/views/tours/show.blade.php @@ -1,3 +1,113 @@ -
- -
+@extends('layouts.app') + +@section('content') + +
+ +
+ + +
+ + {{ $tour->title }} + + + + تور + + +
+ + + +
+ + +

+ {{ $tour->title }} +

+ + + +

+ {{ $tour->summary }} +

+ + + +
+ + + +
+ + +
+ + + نوع سفر + + +
+ {{ $tour->travelType?->name ?? '-' }} +
+ +
+ + + +
+ + + تاریخ حرکت + + +
+ {{ \Carbon\Carbon::parse($tour->departure_date)->format('Y/m/d') }} +
+ +
+ + + +
+ + + قیمت + + +
+ {{ number_format($tour->price) }} + تومان +
+ +
+ + +
+ + + +
+ + + +

+ توضیحات تور +

+ + +

+ {{ $tour->description }} +

+ + +
+ +
+ +
+ + +@endsection