diff --git a/app/Http/Controllers/CityController.php b/app/Http/Controllers/CityController.php index 33beded..034efbf 100644 --- a/app/Http/Controllers/CityController.php +++ b/app/Http/Controllers/CityController.php @@ -8,9 +8,9 @@ class CityController extends Controller { public function byProvince(int $province) { - $cities = City::where('provinces', $province) + $cities = City::where('provinces_id', $province) ->orderBy('name') - ->get(['id', 'name']); + ->get(); return response()->json($cities); } diff --git a/app/Http/Controllers/CommentController.php b/app/Http/Controllers/CommentController.php index 2213537..622a8a6 100644 --- a/app/Http/Controllers/CommentController.php +++ b/app/Http/Controllers/CommentController.php @@ -16,8 +16,10 @@ class CommentController extends Controller ->latest() ->paginate(4); - return view('account.users.comments.index',compact('comments')); - + return view('account.users.comments.index', [ + 'comments' => $comments, + 'withoutHero' => true + ]); } public function store(CommentStoreRequest $request) diff --git a/app/Http/Controllers/FavoriteController.php b/app/Http/Controllers/FavoriteController.php index b8e030a..21086df 100644 --- a/app/Http/Controllers/FavoriteController.php +++ b/app/Http/Controllers/FavoriteController.php @@ -14,10 +14,11 @@ class FavoriteController extends Controller ->latest() ->get(); - return view('account.users.favorite.index', compact('favorites')); - - } - public function store(Request $request) + return view('account.users.favorite.index', [ + 'favorites' => $favorites, + 'withoutHero' => true + ]); + } public function store(Request $request) { Favorite::firstOrCreate([ 'user_id' => auth()->id(), diff --git a/app/Http/Controllers/FlightController.php b/app/Http/Controllers/FlightController.php index 25be11a..bd6a42d 100644 --- a/app/Http/Controllers/FlightController.php +++ b/app/Http/Controllers/FlightController.php @@ -3,33 +3,49 @@ namespace App\Http\Controllers; use App\Models\Flight; +use App\Models\Tour; use Illuminate\Http\Request; class FlightController extends Controller { - public function index() + public function index(Request $request) { - $newestFlight = Flight:: - latest() - ->applySearch() - ->take(10) + $flights = Flight::latest() + ->applySearch($request->all()) + ->paginate(10); + + + $newestFlight = Flight::latest() + ->take(3) ->get(); - $flights = Flight::latest()-> - paginate(9); - return view('home.index', compact('newestFlight', 'flights')); + + $newestTour = Tour::latest() + ->take(3) + ->get(); + + + $tours = Tour::latest() + ->paginate(10); + + + return view('flights.index', compact( + 'flights', + 'newestFlight', + 'newestTour', + 'tours' + )); } - - public function show(Flight $flight) + public function show(Flight $flight) { $flight->increment('views'); $comments = $flight->comments() - ->latest() + ->latest() ->get(); - return view('flights.show', compact('flight','comments')); + return view('flights.show', compact('flight', 'comments')); } - } +} diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 1e5c764..36d55ce 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -11,13 +11,12 @@ class HomeController extends Controller public function index() { $newestFlight = Flight:: - where('departure_date', '>=', now()) - ->orderBy('departure_date', 'asc') - ->take(3) - ->get(); + orderBy('created_at', 'desc') + ->paginate(1); + $newestTour = Tour::latest() - ->take(10) - ->get(); + ->paginate(2); + $flights = Flight::latest() ->paginate(5); diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index fcc2500..ef2f60e 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -50,10 +50,10 @@ class ProfileController extends Controller $inputs['profile_image'] = $imageName; } - $user->update($inputs); + $user->update($inputs); return back()->with([ - 'success','اطلاعات کاربر با موفقیت ویرایش شد.' + 'success'=>'اطلاعات کاربر با موفقیت ویرایش شد.' ]); } diff --git a/app/Http/Controllers/TourController.php b/app/Http/Controllers/TourController.php index 7de2338..b62971f 100644 --- a/app/Http/Controllers/TourController.php +++ b/app/Http/Controllers/TourController.php @@ -10,12 +10,11 @@ class TourController extends Controller { $newestTour = Tour::with('travelType') ->latest() - ->take(10) - ->get(); + ->paginate(3); $tours = Tour::with('travelType') ->latest() - ->paginate(5); + ->paginate(2); return view('tours.index', compact('newestTour', 'tours')); } diff --git a/app/Http/Requests/ProfileUpdateRequest.php b/app/Http/Requests/ProfileUpdateRequest.php index 7320e12..7e986b2 100644 --- a/app/Http/Requests/ProfileUpdateRequest.php +++ b/app/Http/Requests/ProfileUpdateRequest.php @@ -104,12 +104,12 @@ class ProfileUpdateRequest extends FormRequest 'password' => [ - 'required', + 'nullable', 'confirmed', 'min:8' ], 'current_password' => [ - 'required_with:new_password', + 'nullable:new_password', 'current_password:web', ], diff --git a/app/Models/City.php b/app/Models/City.php index f0cc7fc..c2a1e7e 100644 --- a/app/Models/City.php +++ b/app/Models/City.php @@ -43,6 +43,6 @@ class City extends Model } public function province() { - return $this->hasMany(Province::class); + return $this->belongsTo(Province::class); } } diff --git a/app/Models/Flight.php b/app/Models/Flight.php index c026b5d..858539f 100644 --- a/app/Models/Flight.php +++ b/app/Models/Flight.php @@ -81,17 +81,12 @@ class Flight extends Model public function applySearch(Builder $query, array $filters): void { $query - ->when($filters['origin'] ?? null, function ($query, $origin) { - $query->where('origin', $origin); + ->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); + + ->when($filters['destination'] ?? null, function($query,$destination){ + $query->where('destination',$destination); }); } } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 68fdf4e..9e47643 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -3,6 +3,7 @@ namespace App\Providers; use App\Models\Province; +use Illuminate\Pagination\Paginator; use Illuminate\Support\ServiceProvider; class AppServiceProvider extends ServiceProvider @@ -26,6 +27,10 @@ class AppServiceProvider extends ServiceProvider $view->with('provinces', $provinces); + Paginator::useTailwind(); + Paginator::useBootstrapFive(); + + }); } diff --git a/public/assets/css/styles2.css.php b/public/assets/css/styles2.css.php deleted file mode 100644 index e69de29..0000000 diff --git a/resources/views/account/users/dashboard.blade.php b/resources/views/account/users/dashboard.blade.php index 576028b..bf5069c 100644 --- a/resources/views/account/users/dashboard.blade.php +++ b/resources/views/account/users/dashboard.blade.php @@ -1,105 +1,65 @@ -@extends('layouts.app') +@extends('account.layout.app') -@section('content') -