From 043b6ed931312fc07a363f06f893d02dbdbd448b Mon Sep 17 00:00:00 2001 From: hatame Date: Sun, 16 Aug 2026 16:56:21 +0330 Subject: [PATCH] git commit "Complete today's development" --- app/Http/Controllers/CityController.php | 10 +- app/Http/Controllers/FlightController.php | 30 + app/Http/Controllers/HomeController.php | 10 +- app/Http/Requests/FlightSearchRequest.php | 46 + app/Models/City.php | 8 +- app/Models/Flight.php | 22 +- app/Models/Province.php | 4 + app/Providers/AppServiceProvider.php | 10 +- app/View/Components/Home/LatestFlights.php | 26 + public/assets/js/custom.js | 462 +++------- resources/views/components/flight.blade.php | 130 +++ resources/views/components/tour.blade.php | 75 ++ resources/views/flights/archive.blade.php | 35 + resources/views/flights/search.blade.php | 136 +++ resources/views/home/index.blade.php | 7 + resources/views/layouts/hero.blade.php | 914 ++++++++++---------- routes/web.php | 7 + 17 files changed, 1107 insertions(+), 825 deletions(-) create mode 100644 app/Http/Controllers/FlightController.php create mode 100644 app/Http/Requests/FlightSearchRequest.php create mode 100644 app/View/Components/Home/LatestFlights.php create mode 100644 resources/views/components/flight.blade.php create mode 100644 resources/views/components/tour.blade.php create mode 100644 resources/views/flights/archive.blade.php create mode 100644 resources/views/flights/search.blade.php diff --git a/app/Http/Controllers/CityController.php b/app/Http/Controllers/CityController.php index d896f3c..0dc208c 100644 --- a/app/Http/Controllers/CityController.php +++ b/app/Http/Controllers/CityController.php @@ -10,8 +10,12 @@ class CityController extends Controller // public function getCities($province) { - return City::where('province_id', $province) + + $cities = City::where('province_id',$province) ->orderBy('name') ->get(); - } -} + + + return response()->json($cities); + + }} diff --git a/app/Http/Controllers/FlightController.php b/app/Http/Controllers/FlightController.php new file mode 100644 index 0000000..46fb3aa --- /dev/null +++ b/app/Http/Controllers/FlightController.php @@ -0,0 +1,30 @@ +validated(); + + $flights = Flight::query() + ->applySearch($filters) + ->get(); + + return view('flights.search', compact('flights')); + } + + public function archive() + { + $flights = Flight::query() + ->latest() + ->paginate(12); + + return view('flights.archive', compact('flights')); + + } +} diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index dc0ebbd..5cd29ae 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -2,13 +2,17 @@ namespace App\Http\Controllers; -use Illuminate\Http\Request; +use App\Models\Flight; class HomeController extends Controller { - // public function index() { - return view('layouts.app'); + $latestFlights = Flight::query() + ->latest() + ->take(6) + ->get(); + + return view('home.index', compact('latestFlights')); } } diff --git a/app/Http/Requests/FlightSearchRequest.php b/app/Http/Requests/FlightSearchRequest.php new file mode 100644 index 0000000..0d2cf01 --- /dev/null +++ b/app/Http/Requests/FlightSearchRequest.php @@ -0,0 +1,46 @@ +|string> + */ + public function rules(): array + { + return [ + 'origin' => + [ + 'required', + ], + 'destination' => + [ + 'required', + ], + 'departure_date' => + [ + 'required', + 'date', + ], + 'passengers' => + [ 'required', + 'integer', + 'min:1', + ], + + ]; } +} diff --git a/app/Models/City.php b/app/Models/City.php index 51eb137..248cc83 100644 --- a/app/Models/City.php +++ b/app/Models/City.php @@ -12,13 +12,13 @@ use Illuminate\Database\Eloquent\Model; /** * Class City - * + * * @property int $id * @property int $provinces * @property string $name * @property Carbon $created_at * @property Carbon $updated_at - * + * * @property Collection|User[] $users * * @package App\Models @@ -41,4 +41,8 @@ class City extends Model { return $this->hasMany(User::class); } + public function province() + { + return $this->hasMany(Province::class); + } } diff --git a/app/Models/Flight.php b/app/Models/Flight.php index a35469a..4e84d74 100644 --- a/app/Models/Flight.php +++ b/app/Models/Flight.php @@ -7,11 +7,13 @@ namespace App\Models; use Carbon\Carbon; +use Illuminate\Database\Eloquent\Attributes\Scope; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Model; /** * Class Flight - * + * * @property int $id * @property string|null $airline * @property string|null $flight_number @@ -56,4 +58,22 @@ class Flight extends Model 'price', 'status' ]; + + #[Scope] +public function applySearch(Builder $query, array $filters): void +{ + $query + ->when($filters['origin'] ?? null, function ($query, $origin) { + $query->where('origin', $origin); + }) + ->when($filters['destination'] ?? null, function ($query, $destination) { + $query->where('destination', $destination); + }) + ->when($filters['departure_date'] ?? null, function ($query, $date) { + $query->whereDate('departure_date', $date); + }) + ->when($filters['passengers'] ?? null, function ($query, $passengers) { + $query->where('capacity', '>=', $passengers); + }); } + } diff --git a/app/Models/Province.php b/app/Models/Province.php index 92bebe9..37e8455 100644 --- a/app/Models/Province.php +++ b/app/Models/Province.php @@ -32,5 +32,9 @@ class Province extends Model { return $this->hasMany(User::class); } + public function cities() + { + return $this->hasMany(City::class); + } } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 447e3e3..68fdf4e 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,6 +2,7 @@ namespace App\Providers; +use App\Models\Province; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider @@ -19,6 +20,13 @@ class AppServiceProvider extends ServiceProvider */ public function boot(): void { - // + \Illuminate\Support\Facades\View::composer('layouts.hero', function ($view) { + + $provinces = Province::orderBy('name')->get(); + + $view->with('provinces', $provinces); + + }); + } } diff --git a/app/View/Components/Home/LatestFlights.php b/app/View/Components/Home/LatestFlights.php new file mode 100644 index 0000000..7b062e2 --- /dev/null +++ b/app/View/Components/Home/LatestFlights.php @@ -0,0 +1,26 @@ + -1; -var isChrome = navigator.userAgent.indexOf('Chrome') > -1; -if((isSafari) && (isChrome)) { - isSafari = false; -} -$(document).ready(function(){ - OwlCarousel(); + $('#origin_province').on('change', function () { - $('.blur-area').blurArea(); - $('.ws-action').windowScrollAction(); - checkboxes(); - afternavHeight(); - activeBookmark(); - magnificLightbox(); - priceSlider(); - BSTabsActions(); - heroSearchSections(); - $('.quantity-selector').quantitySelector(); - autocomplete(); - searchResultsCollapse(); - comingSoonCountdown(); - smoothScroll(); + let provinceId = $(this).val(); + + $('#origin_city').html( + '' + ); + + + if(provinceId){ + + $.ajax({ + + url: '/users/cities/' + provinceId, + + type: 'GET', + + success:function (cities) { + + + $('#origin_city').empty(); + + $('#origin_city').append( + '' + ); + + + $.each(cities,function(index,city){ + + $('#origin_city').append( + `` + ); + + }); + + + } + + }); + + + } + + }); + + + + + + $('#destination_province').on('change', function () { + + + let provinceId = $(this).val(); + + + $('#destination_city').html( + '' + ); + + + if(provinceId){ + + + $.ajax({ + + url:'/users/cities/' + provinceId, + + type:'GET', + + success:function(cities){ + + + $('#destination_city').empty(); + + + $('#destination_city').append( + '' + ); + + + $.each(cities,function(index,city){ + + + $('#destination_city').append( + + `` + + ); + + + }); + + + } + + + }); + + + } + + + }); - if($(window).width() > mobileViewport) { - YouTubeVideo(); - stickySidebars(); - } - if($(window).width() < mobileViewport) { - mobileFilters(); - } -}); - -googleMaps(); - - -function smoothScroll() { - var scroll = new SmoothScroll('a[data-scroll]'); -} - - -function YouTubeVideo() { - var $video = $('#youtube-video'); - if($video.length) { - - $video.YTPlayer({ - fitToBackground: true, - videoId: $video.data('video-id'), - events: { - onReady: function() { - $video.data('ytPlayer').player.mute(); - } - } - }); - - $(document).on('scroll', function(){ - videoScroll(); - }); - - function videoScroll() { - var fraction = 0.75, - player = $video.data('ytPlayer').player, - videoHeight = $video.height(), - videoOffsetTop = $video.offset().top, - windowScrollY = window.scrollY; - - if(windowScrollY > (videoHeight + videoOffsetTop) *fraction) { - player.pauseVideo(); - } else { - player.playVideo(); - } - } - } -} - -function OwlCarousel() { - $('.owl-carousel').each( function() { - var $carousel = $(this); - $carousel.owlCarousel({ - // dots : false, - // items : $carousel.data("items"), - slideBy : $carousel.data("slideby"), - center : $carousel.data("center"), - loop : $carousel.data("loop"), - margin : $carousel.data("margin"), - - autoplay : $carousel.data("autoplay"), - autoplayTimeout : $carousel.data("autoplay-timeout"), - navText : [ '', '' ], - responsive: { - 0 : { - items: 1, - dots: true, - nav: false - }, - 992 : { - items: $carousel.data("items"), - dots: false, - nav : $carousel.data("nav") - } - } - }); - }); -} - -function stickySidebars() { - $('.sticky-col').stick_in_parent({ - parent: $('#sticky-parent') - }); - - $('.sticky-cols').stick_in_parent({ - parent: $('.sticky-parent') - }); -} - - -function mobileFilters() { - if($('#mobileFilters').length) { - $(document).on('scroll', function(){ - filtersScroll(); - }); - } - - function filtersScroll() { - - var filters = $('#mobileFilters'); - var footer = $('#mainFooter'); - - if(filters.offset().top + filters.height() > footer.offset().top - 10 || !$(document).scrollTop()) { - filters.removeClass('active'); - } else { - filters.addClass('active'); - } - - if($(document).scrollTop + window.innerHeight > footer.offset().top) { - filters.addClass('active'); - } - } -} - -function checkboxes() { - $('.icheck, .iradio').iCheck({ - checkboxClass: 'icheck', - radioClass: 'iradio' - }); -} - - -function googleMaps() { - if($('.google-map').length) { - window.initMap = function() { - $('.google-map').gmap(); - } - } else { - window.initMap = function() { - return; - } - } -} - - - -function afternavHeight() { - $('.afternav-height').each(function(){ - var $mainNav = $('#main-nav'), - mainNavHeight = $mainNav.height(), - height = $(window).height() - mainNavHeight; - - $(this).css('height', height); - }); -} - - -function activeBookmark() { - $('.theme-search-results-item-bookmark').each(function(index, el){ - $(el).on('click', function(e){ - e.preventDefault(); - $(this).toggleClass('active'); - }); - }); -} - - - -function magnificLightbox() { - $('.magnific-gallery').each(function(index, el){ - $(el).magnificPopup({ - delegate: 'a', - type: 'image', - gallery: { - enabled: true, - navigateByImgClick: true, - preload: [0,1] - } - }) - }); - - $('.magnific-gallery-link').each(function(index , value){ - var gallery = $(this); - var galleryImages = $(this).data('items').split(','); - var items = []; - for(var i=0;i

%D

روز' - + '

%H

ساعت
' - + '

%M

دقیه
' - + '

%S

ثانیه
' - )); - }); -} - -$('.mobile-picker').each(function(i, item){ - if(!isSafari) { - $(item).attr('type', 'text'); - $(item).val($(item).attr('value')); - $(item).on('focus', function(){ - $(item).attr('type', 'date'); - }); - $(item).on('blur', function(){ - $(item).attr('type', 'text'); - }); - } }); diff --git a/resources/views/components/flight.blade.php b/resources/views/components/flight.blade.php new file mode 100644 index 0000000..757d258 --- /dev/null +++ b/resources/views/components/flight.blade.php @@ -0,0 +1,130 @@ +@foreach($flights as $flight) + + +
+ + +
+ +
+ + {{ $flight->airline }} + + + + {{ $flight->flight_number }} + +
+ + @if($flight->flight_class) + + {{ $flight->flight_class }} + + @endif + +
+ + + +
+ +
+ + + مبدا + + + + {{ $flight->origin }} + + +
+ + +
+ ✈ +
+ + +
+ + + مقصد + + + + {{ $flight->destination }} + + +
+ +
+ + + +
+ +
+ + تاریخ پرواز + + + + {{ $flight->departure_date?->format('Y/m/d') }} + +
+ + +
+ + ساعت حرکت + + + + {{ $flight->departure_time?->format('H:i') }} + +
+ + +
+ + ساعت رسیدن + + + + {{ $flight->arrival_time?->format('H:i') }} + +
+ +
+ + + + + +
+ +@endforeach diff --git a/resources/views/components/tour.blade.php b/resources/views/components/tour.blade.php new file mode 100644 index 0000000..029cd00 --- /dev/null +++ b/resources/views/components/tour.blade.php @@ -0,0 +1,75 @@ +@foreach($tours as $tour) + + +
+ + + + + {{ $tour->title }} + + + + +
+ + + + {{ $tour->title }} + + + +
+ + + 📍 + + + {{ $tour->destination }} + +
+ + +
+ +
+ مدت تور + + + {{ $tour->duration }} روز + +
+ +
+ ظرفیت + + + {{ $tour->capacity }} نفر + +
+ +
+ + +
+ + + شروع قیمت از + + + + {{ number_format($tour->price) }} + تومان + + +
+ +
+ +
+ +@endforeach diff --git a/resources/views/flights/archive.blade.php b/resources/views/flights/archive.blade.php new file mode 100644 index 0000000..3db0b94 --- /dev/null +++ b/resources/views/flights/archive.blade.php @@ -0,0 +1,35 @@ +@extends('layouts.app') + +@section('content') + +
+ +

آرشیو پروازها

+ + @foreach($flights as $flight) + +
+ {{ $flight->airline }} + - + {{ $flight->flight_number }} + +
+ + {{ $flight->origin }} + → + {{ $flight->destination }} + +
+ + {{ $flight->departure_date }} +
+ +
+ + @endforeach + + {{ $flights->links() }} + +
+ +@endsection diff --git a/resources/views/flights/search.blade.php b/resources/views/flights/search.blade.php new file mode 100644 index 0000000..2708c12 --- /dev/null +++ b/resources/views/flights/search.blade.php @@ -0,0 +1,136 @@ + @extends('layouts.app') + +@section('content') + +
+ +
+ +
+ +
+

نتایج جستجوی پرواز

+ +

+ {{ $flights->count() }} پرواز پیدا شد +

+
+ + + @forelse($flights as $flight) + +
+ +
+ + {{-- ایرلاین --}} +
+ + {{ $flight->airline }} + + +
+ {{ $flight->flight_number }} +
+
+ + + {{-- مبدا --}} +
+ + + {{ $flight->origin }} + + +
+ {{ $flight->departure_time }} +
+ +
+ + + {{-- مسیر --}} +
+ + + → + + +
+ + + {{-- مقصد --}} +
+ + + {{ $flight->destination }} + + +
+ {{ $flight->arrival_time }} +
+ +
+ + + {{-- کلاس --}} +
+ +
+ کلاس: + {{ $flight->flight_class }} +
+ +
+ ظرفیت: + {{ $flight->capacity }} +
+ +
+ + + {{-- قیمت --}} +
+ + + {{ number_format($flight->price) }} + + +
+ تومان +
+ + + +
+ +
+ +
+ + @empty + +
+ +

+ پروازی پیدا نشد +

+ +

+ لطفاً مبدا، مقصد یا تاریخ دیگری را امتحان کنید. +

+ +
+ + @endforelse + +
+ +
+ +
+ +@endsection + diff --git a/resources/views/home/index.blade.php b/resources/views/home/index.blade.php index 8b13789..2d924ef 100644 --- a/resources/views/home/index.blade.php +++ b/resources/views/home/index.blade.php @@ -1 +1,8 @@ +@extends('layouts.app') +@section('content') + +@include('components.flight') +@include('components.tour') + +@endsection diff --git a/resources/views/layouts/hero.blade.php b/resources/views/layouts/hero.blade.php index 5dcc046..82212c9 100644 --- a/resources/views/layouts/hero.blade.php +++ b/resources/views/layouts/hero.blade.php @@ -1,462 +1,456 @@ -
-
-
-
-
-
-
-
-
-
-
-

سفر خود را شروع کنید

-

صدها وب سایت مسافرتی را همزمان با هم مقایسه کنید

-
-
- -
-
-
-
-
-
-
-
- - -
-
-
-
-
-
-
-
- - - -
-
-
-
-
-
- - - -
-
-
-
-
-
-
-
-
-
- - -
-
-

اتاق ها

-
    -
  • - - -
  • -
  • 1
  • -
  • - + -
  • -
-
-
-
-
-
-
-
-
- - -
-
-

مهمان

-
    -
  • - - -
  • -
  • 1
  • -
  • - + -
  • -
-
-
-
-
-
-
-
-
- -
-
-
-
-
- - - - - - -
-
-
-
-
-
-
-
-
-
-
- - -
-
-
-
-
-
-
-
- - - -
-
-
-
-
-
- - - -
-
-
-
-
-
- - -
-
-

مهمان

-
    -
  • - - -
  • -
  • 1
  • -
  • - + -
  • -
-
-
-
-
-
-
-
-
- -
-
-
-
-
- - - - -
-
-
-
-
-
-
-
-
-
-
-
-
- - -
-
-
-
-
-
- - -
-
-
-
-
-
-
-
-
-
- - - -
-
-
-
-
-
- - - -
-
-
-
-
-
- - -
-
-

مسافران

-
    -
  • - - -
  • -
  • 1
  • -
  • - + -
  • -
-
-
-
-
-
-
-
-
- -
-
-
-
-
- - -
-
-
-
-
-
-
-
-
-
-
-
-
- - -
-
-
-
-
-
- - -
-
-
-
-
-
-
-
- - - -
-
-
-
-
-
- - - -
-
-
-
- -
-
-
-
-
- - - - - - -
-
-
-
-
-
-
-
-
-
-
- - -
-
-
-
-
-
-
-
- - - -
-
-
-
-
-
- - - -
-
-
-
-
-
- - -
-
-

مهمان

-
    -
  • - - -
  • -
  • 1
  • -
  • - + -
  • -
-
-
-
-
-
-
-
-
- -
-
-
-
-
- - - -
-
-
-
-
-
-
-
+
+ +
+ +
+ + + ✈️ سفر بعدی شما از اینجا شروع می‌شود + + +

+ پرواز خود را + پیدا کنید +

+ +

+ مبدا، مقصد و تاریخ سفر خود را انتخاب کنید. +

+
+ + +
+ +
+ +
+

+ جستجوی پرواز +

+ + + اطلاعات سفر خود را وارد کنید + +
+ +
+ + + + + +
+ +
+ + +
+ + +
+ + + {{-- مبدا --}} +
+ + + + + + +
+ + + {{-- مقصد --}} +
+ + + + + + +
+ + + {{-- تاریخ رفت --}} +
+ + + + + +
+ + + {{-- تاریخ برگشت --}} +
+ + + + + +
+ + + {{-- تعداد مسافر --}} +
+ + + + + +
+ + + {{-- جستجو --}} +
+ + + +
+ + +
+ +
+ +
+
-
+ + + + + + diff --git a/routes/web.php b/routes/web.php index a9a4faf..e7339bc 100644 --- a/routes/web.php +++ b/routes/web.php @@ -4,6 +4,7 @@ use App\Http\Controllers\CityController; use App\Http\Controllers\CommentController; use App\Http\Controllers\DashboardController; use App\Http\Controllers\FavoriteController; +use App\Http\Controllers\FlightController; use App\Http\Controllers\HomeController; use App\Http\Controllers\ProfileController; use Illuminate\Support\Facades\Route; @@ -12,6 +13,12 @@ use Illuminate\Support\Facades\Route; Route::get('/', [HomeController::class,'index']) ->name('index'); +Route::get('/flights/search', [FlightController::class, 'search']) + ->name('flights.search'); + +Route::get('/flights/archive', [FlightController::class, 'archive']) + ->name('flights.archive'); + Route::prefix('users')->name('users.')->middleware('auth:web')->group(function (){ Route::get('/',[DashboardController::class,'index'])->name('dashboard');