feat: implement tour listing with sorting and pagination
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Tour;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TourController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$title = 'تورها';
|
||||
|
||||
$sort = $request->query('sort', 'default');
|
||||
|
||||
$tours = Tour::with([
|
||||
'originCity',
|
||||
'city',
|
||||
'tourDepartures',
|
||||
])
|
||||
->applySort($sort)
|
||||
->paginate(3)
|
||||
->withQueryString();
|
||||
|
||||
return view('tours.index', compact('title', 'tours', 'sort'));
|
||||
}
|
||||
|
||||
public function show(Tour $tour)
|
||||
{
|
||||
$title= 'جزئیات تور';
|
||||
return view('tours.show', compact('title'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user