fix:change models problems and routes
This commit is contained in:
+1
-1
@@ -8,7 +8,7 @@ use App\Models\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class LoginController extends Controller
|
||||
class LogInController extends Controller
|
||||
{
|
||||
public function index()
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Flight;
|
||||
use App\Models\Tour;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class IndexController extends Controller
|
||||
@@ -9,7 +11,23 @@ class IndexController extends Controller
|
||||
//
|
||||
public function index()
|
||||
{
|
||||
return view('index');
|
||||
$flights = Flight::query()
|
||||
->with([
|
||||
'departureAirport.city',
|
||||
'arrivalAirport.city',
|
||||
'airline',
|
||||
'file',
|
||||
])
|
||||
->orderByDesc('created_at')
|
||||
->limit(10)
|
||||
->paginate();
|
||||
|
||||
$tours = Tour::query()
|
||||
->orderByDesc('created_at')
|
||||
->take(10)
|
||||
->paginate();
|
||||
|
||||
return view('index', compact('flights', 'tours'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-2
@@ -14,10 +14,11 @@ use Illuminate\Database\Eloquent\Model;
|
||||
*
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $city
|
||||
* @property int|null $city_id
|
||||
* @property string $code
|
||||
* @property string $country
|
||||
*
|
||||
* @property City|null $city
|
||||
* @property Collection|Flight[] $flights
|
||||
*
|
||||
* @package App\Models
|
||||
@@ -28,13 +29,22 @@ class Airport extends Model
|
||||
public $timestamps = false;
|
||||
public static $snakeAttributes = false;
|
||||
|
||||
protected $casts = [
|
||||
'city_id' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'city',
|
||||
'city_id',
|
||||
'code',
|
||||
'country'
|
||||
];
|
||||
|
||||
public function city()
|
||||
{
|
||||
return $this->belongsTo(City::class);
|
||||
}
|
||||
|
||||
public function flights()
|
||||
{
|
||||
return $this->hasMany(Flight::class, 'departure_airport_id');
|
||||
|
||||
+11
-6
@@ -12,7 +12,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class Flight
|
||||
*
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $arrival_aiport_id
|
||||
* @property int $departure_airport_id
|
||||
@@ -27,7 +27,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
* @property int $status
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
*
|
||||
*
|
||||
* @property Airline $airline
|
||||
* @property File $file
|
||||
* @property Airport $airport
|
||||
@@ -72,16 +72,21 @@ class Flight extends Model
|
||||
{
|
||||
return $this->belongsTo(Airline::class);
|
||||
}
|
||||
public function departureAirport()
|
||||
{
|
||||
return $this->belongsTo(Airport::class, 'departure_airport_id');
|
||||
}
|
||||
|
||||
public function arrivalAirport()
|
||||
{
|
||||
return $this->belongsTo(Airport::class, 'arrival_aiport_id');
|
||||
}
|
||||
|
||||
public function file()
|
||||
{
|
||||
return $this->belongsTo(File::class);
|
||||
}
|
||||
|
||||
public function airport()
|
||||
{
|
||||
return $this->belongsTo(Airport::class, 'departure_airport_id');
|
||||
}
|
||||
|
||||
public function bookings()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user