From ff69c76dc427f5d3b222a3ff1c8dd4bf13c57cd7 Mon Sep 17 00:00:00 2001 From: Bahar Date: Sun, 16 Aug 2026 08:06:57 +0330 Subject: [PATCH] fix: regenerate models and add database --- .../Controllers/Auth/RegisterController.php | 2 +- app/Models/Airport.php | 2 +- app/Models/Booking.php | 21 +++---- app/Models/City.php | 48 +++++++++++++++ app/Models/Comment.php | 23 +++++++- app/Models/Favorite.php | 59 +++++++++++++++++++ app/Models/Flight.php | 40 ++++++++----- app/Models/Province.php | 42 +++++++++++++ app/Models/Tour.php | 12 ++++ app/Models/User.php | 54 +++++++++++------ resources/views/layouts/header.blade.php | 20 +++---- 11 files changed, 264 insertions(+), 59 deletions(-) create mode 100644 app/Models/City.php create mode 100644 app/Models/Favorite.php create mode 100644 app/Models/Province.php diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 884ca9f..c77fd79 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -9,7 +9,7 @@ class RegisterController extends Controller { public function index() { -return view('auth.register'); + return view('auth.register'); } public function post() diff --git a/app/Models/Airport.php b/app/Models/Airport.php index 60ed63f..d472862 100644 --- a/app/Models/Airport.php +++ b/app/Models/Airport.php @@ -37,6 +37,6 @@ class Airport extends Model public function flights() { - return $this->hasMany(Flight::class, 'deprature_airport_id'); + return $this->hasMany(Flight::class, 'departure_airport_id'); } } diff --git a/app/Models/Booking.php b/app/Models/Booking.php index 1bceaec..3d5d5a8 100644 --- a/app/Models/Booking.php +++ b/app/Models/Booking.php @@ -7,7 +7,6 @@ namespace App\Models; use Carbon\Carbon; -use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Model; /** @@ -15,8 +14,8 @@ use Illuminate\Database\Eloquent\Model; * * @property int $id * @property int $user_id - * @property int $flight_id - * @property int $tour_date_id + * @property int|null $flight_id + * @property int|null $tour_date_id * @property int $adult_count * @property int $child_count * @property int $total_price @@ -25,10 +24,9 @@ use Illuminate\Database\Eloquent\Model; * @property int $status * @property Carbon $updated_at * - * @property Booking $booking - * @property Flight $flight - * @property TourDate $tourDate - * @property Collection|Booking[] $bookings + * @property User $user + * @property Flight|null $flight + * @property TourDate|null $tourDate * * @package App\Models */ @@ -58,9 +56,9 @@ class Booking extends Model 'status' ]; - public function booking() + public function user() { - return $this->belongsTo(Booking::class, 'user_id'); + return $this->belongsTo(User::class); } public function flight() @@ -72,9 +70,4 @@ class Booking extends Model { return $this->belongsTo(TourDate::class); } - - public function bookings() - { - return $this->hasMany(Booking::class, 'user_id'); - } } diff --git a/app/Models/City.php b/app/Models/City.php new file mode 100644 index 0000000..7006477 --- /dev/null +++ b/app/Models/City.php @@ -0,0 +1,48 @@ + 'int' + ]; + + protected $fillable = [ + 'province_id', + 'name' + ]; + + public function province() + { + return $this->belongsTo(Province::class); + } + + public function users() + { + return $this->hasMany(User::class); + } +} diff --git a/app/Models/Comment.php b/app/Models/Comment.php index a832b85..4349f86 100644 --- a/app/Models/Comment.php +++ b/app/Models/Comment.php @@ -14,10 +14,16 @@ use Illuminate\Database\Eloquent\Model; * * @property int $id * @property int $user_id + * @property int|null $flight_id + * @property int|null $tour_id * @property string $comment + * @property int|null $rating * @property int $status * @property Carbon $created_at + * @property Carbon|null $updated_at * + * @property Flight|null $flight + * @property Tour|null $tour * @property User $user * * @package App\Models @@ -25,20 +31,35 @@ use Illuminate\Database\Eloquent\Model; class Comment extends Model { protected $table = 'comments'; - public $timestamps = false; public static $snakeAttributes = false; protected $casts = [ 'user_id' => 'int', + 'flight_id' => 'int', + 'tour_id' => 'int', + 'rating' => 'int', 'status' => 'int' ]; protected $fillable = [ 'user_id', + 'flight_id', + 'tour_id', 'comment', + 'rating', 'status' ]; + public function flight() + { + return $this->belongsTo(Flight::class); + } + + public function tour() + { + return $this->belongsTo(Tour::class); + } + public function user() { return $this->belongsTo(User::class); diff --git a/app/Models/Favorite.php b/app/Models/Favorite.php new file mode 100644 index 0000000..fd6b21f --- /dev/null +++ b/app/Models/Favorite.php @@ -0,0 +1,59 @@ + 'int', + 'flight_id' => 'int', + 'tour_id' => 'int' + ]; + + protected $fillable = [ + 'user_id', + 'flight_id', + 'tour_id' + ]; + + public function flight() + { + return $this->belongsTo(Flight::class); + } + + public function tour() + { + return $this->belongsTo(Tour::class); + } + + public function user() + { + return $this->belongsTo(User::class); + } +} diff --git a/app/Models/Flight.php b/app/Models/Flight.php index 09fb3df..fe52e55 100644 --- a/app/Models/Flight.php +++ b/app/Models/Flight.php @@ -14,16 +14,15 @@ use Illuminate\Database\Eloquent\Model; * Class Flight * * @property int $id + * @property int $arrival_aiport_id + * @property int $departure_airport_id + * @property int $airline_id + * @property int $file_id * @property string $title * @property string $summary - * @property int $arrival_aiport_id - * @property int $file_id * @property int $flight_type - * @property int $departure_time + * @property Carbon $departure_time * @property float $price - * @property int $deprature_airport_id - * @property string $destination - * @property int $airline_id * @property int $capacity * @property int $status * @property Carbon $created_at @@ -33,6 +32,8 @@ use Illuminate\Database\Eloquent\Model; * @property File $file * @property Airport $airport * @property Collection|Booking[] $bookings + * @property Collection|Comment[] $comments + * @property Collection|Favorite[] $favorites * * @package App\Models */ @@ -43,27 +44,26 @@ class Flight extends Model protected $casts = [ 'arrival_aiport_id' => 'int', + 'departure_airport_id' => 'int', + 'airline_id' => 'int', 'file_id' => 'int', 'flight_type' => 'int', - 'departure_time' => 'int', + 'departure_time' => 'datetime', 'price' => 'float', - 'deprature_airport_id' => 'int', - 'airline_id' => 'int', 'capacity' => 'int', 'status' => 'int' ]; protected $fillable = [ + 'arrival_aiport_id', + 'departure_airport_id', + 'airline_id', + 'file_id', 'title', 'summary', - 'arrival_aiport_id', - 'file_id', 'flight_type', 'departure_time', 'price', - 'deprature_airport_id', - 'destination', - 'airline_id', 'capacity', 'status' ]; @@ -80,11 +80,21 @@ class Flight extends Model public function airport() { - return $this->belongsTo(Airport::class, 'deprature_airport_id'); + return $this->belongsTo(Airport::class, 'departure_airport_id'); } public function bookings() { return $this->hasMany(Booking::class); } + + public function comments() + { + return $this->hasMany(Comment::class); + } + + public function favorites() + { + return $this->hasMany(Favorite::class); + } } diff --git a/app/Models/Province.php b/app/Models/Province.php new file mode 100644 index 0000000..be8e547 --- /dev/null +++ b/app/Models/Province.php @@ -0,0 +1,42 @@ +hasMany(City::class); + } + + public function users() + { + return $this->hasMany(User::class); + } +} diff --git a/app/Models/Tour.php b/app/Models/Tour.php index aa86edc..0fcb7e5 100644 --- a/app/Models/Tour.php +++ b/app/Models/Tour.php @@ -26,6 +26,8 @@ use Illuminate\Database\Eloquent\Model; * @property Carbon $updated_at * * @property File $file + * @property Collection|Comment[] $comments + * @property Collection|Favorite[] $favorites * @property Collection|TourDate[] $tourDates * * @package App\Models @@ -57,6 +59,16 @@ class Tour extends Model return $this->belongsTo(File::class); } + public function comments() + { + return $this->hasMany(Comment::class); + } + + public function favorites() + { + return $this->hasMany(Favorite::class); + } + public function tourDates() { return $this->hasMany(TourDate::class); diff --git a/app/Models/User.php b/app/Models/User.php index d3c7d74..e955e75 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -10,11 +10,10 @@ use Carbon\Carbon; use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; -use Illuminate\Foundation\Auth\User as Authenticated ; /** * Class User - * + * * @property int $id * @property string $first_name * @property string $last_name @@ -27,32 +26,35 @@ use Illuminate\Foundation\Auth\User as Authenticated ; * @property int|null $image_id * @property string $username * @property string $password - * @property string $password_confirmation - * @property string $user_province - * @property string $user_city + * @property int $province_id + * @property int $city_id * @property int|null $status * @property Carbon $created_at - * @property Carbon $updatet_at - * @property string $deleted_at - * + * @property Carbon $updated_at + * @property string|null $deleted_at + * * @property File|null $file + * @property City $city + * @property Province $province + * @property Collection|Booking[] $bookings * @property Collection|Comment[] $comments + * @property Collection|Favorite[] $favorites * * @package App\Models */ -class User extends Authenticated +class User extends Model { use SoftDeletes; protected $table = 'users'; - public $timestamps = false; public static $snakeAttributes = false; protected $casts = [ 'gender' => 'int', 'marital_status' => 'int', 'image_id' => 'int', - 'status' => 'int', - 'updatet_at' => 'datetime' + 'province_id' => 'int', + 'city_id' => 'int', + 'status' => 'int' ]; protected $hidden = [ @@ -71,11 +73,9 @@ class User extends Authenticated 'image_id', 'username', 'password', - 'password_confirmation', - 'user_province', - 'user_city', - 'status', - 'updatet_at' + 'province_id', + 'city_id', + 'status' ]; public function file() @@ -83,8 +83,28 @@ class User extends Authenticated return $this->belongsTo(File::class, 'image_id'); } + public function city() + { + return $this->belongsTo(City::class); + } + + public function province() + { + return $this->belongsTo(Province::class); + } + + public function bookings() + { + return $this->hasMany(Booking::class); + } + public function comments() { return $this->hasMany(Comment::class); } + + public function favorites() + { + return $this->hasMany(Favorite::class); + } } diff --git a/resources/views/layouts/header.blade.php b/resources/views/layouts/header.blade.php index eb8a163..c58c9c6 100644 --- a/resources/views/layouts/header.blade.php +++ b/resources/views/layouts/header.blade.php @@ -5,17 +5,17 @@
-
- - - - -
+{{--
--}} +{{-- --}} +{{-- --}} +{{-- --}} +{{-- --}} +{{--
--}}
- +{{-- --}}