Files
kiarash-airline/app/Http/Controllers/IndexController.php
T

30 lines
788 B
PHP

<?php
namespace App\Http\Controllers;
use App\Models\Flight;
use App\Models\Tour;
use Illuminate\Http\Request;
class IndexController extends Controller
{
//
public function index()
{
$tours = Tour::query()
->with(['file', 'tour_details','originAirport' , 'destinationAirport'])
->orderByDesc('created_at')
->limit(4)
->get();
$flights = Flight::query()
->with(['airline', 'airport', 'destinationAirport'])
->orderByDesc('created_at')
->limit(4)
->get();
$flights->each(function ($flight) {
$flight->start_date_fa = verta($flight->start_time)->format('%d %B');
});
return view('index' , compact('tours' , 'flights'));
}
}