feat: update user and flight models and add comment and admin models

This commit is contained in:
2026-08-18 09:28:06 +03:30
parent bb4196cc1b
commit 7cdfcdbef2
5 changed files with 198 additions and 31 deletions
+76
View File
@@ -0,0 +1,76 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class Admin
*
* @property int $id
* @property string $first_name
* @property string $last_name
* @property string $username
* @property string $email
* @property string $mobile
* @property string $password
* @property int|null $file_id
* @property int $role
* @property int $status
* @property Carbon|null $last_login_at
* @property Carbon $created_at
* @property Carbon $updated_at
* @property string|null $deleted_at
*
* @property File|null $file
* @property Collection|Comment[] $comments
*
* @package App\Models
*/
class Admin extends Model
{
use SoftDeletes;
protected $table = 'admins';
public static $snakeAttributes = false;
protected $casts = [
'file_id' => 'int',
'role' => 'int',
'status' => 'int',
'last_login_at' => 'datetime'
];
protected $hidden = [
'password'
];
protected $fillable = [
'first_name',
'last_name',
'username',
'email',
'mobile',
'password',
'file_id',
'role',
'status',
'last_login_at'
];
public function file()
{
return $this->belongsTo(File::class);
}
public function comments()
{
return $this->hasMany(Comment::class);
}
}
+83
View File
@@ -0,0 +1,83 @@
<?php
/**
* Created by Reliese Model.
*/
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class Comment
*
* @property int $id
* @property int|null $user_id
* @property int|null $admin_id
* @property int|null $tour_id
* @property int|null $flight_id
* @property int|null $parent_id
* @property string|null $guest_name
* @property string $guest_email
* @property string $content
* @property int $status
* @property Carbon $created_at
* @property Carbon $updated_at
* @property string|null $deleted_at
*
* @property Flight|null $flight
* @property Tour|null $tour
* @property User|null $user
* @property Admin|null $admin
*
* @package App\Models
*/
class Comment extends Model
{
use SoftDeletes;
protected $table = 'comments';
public static $snakeAttributes = false;
protected $casts = [
'user_id' => 'int',
'admin_id' => 'int',
'tour_id' => 'int',
'flight_id' => 'int',
'parent_id' => 'int',
'status' => 'int'
];
protected $fillable = [
'user_id',
'admin_id',
'tour_id',
'flight_id',
'parent_id',
'guest_name',
'guest_email',
'content',
'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);
}
public function admin()
{
return $this->belongsTo(Admin::class);
}
}
+3 -3
View File
@@ -146,9 +146,9 @@ class Flight extends Model
{ {
return $this->hasMany(Booking::class); return $this->hasMany(Booking::class);
} }
public function comments()
public function tours()
{ {
return $this->hasMany(Tour::class, 'file_id'); return $this->hasMany(Comment::class, 'flight_id');
} }
} }
+32 -28
View File
@@ -34,24 +34,28 @@ use Illuminate\Database\Eloquent\Model;
*/ */
class Tour extends Model class Tour extends Model
{ {
protected $table = 'tours'; protected $table = 'tours';
public static $snakeAttributes = false; public static $snakeAttributes = false;
protected $casts = [ protected $casts = [
'origin_city_id' => 'int', 'origin_city_id' => 'int',
'destination_city_id' => 'int', 'destination_city_id' => 'int',
'file_id' => 'int' 'file_id' => 'int',
]; 'tour_mode'=> 'int',
'tour_scope' => 'int'
];
protected $fillable = [ protected $fillable = [
'title', 'title',
'summary', 'summary',
'description', 'description',
'origin_city_id', 'origin_city_id',
'destination_city_id', 'destination_city_id',
'file_id', 'file_id',
'tour_type' 'tour_type',
]; 'tour_mode',
'tour_scope'
];
#[Scope] #[Scope]
protected function applySort(Builder $query, ?string $sort = null): void protected function applySort(Builder $query, ?string $sort = null): void
{ {
@@ -73,27 +77,27 @@ class Tour extends Model
} }
} }
public function flight()
{
return $this->belongsTo(Flight::class, 'file_id');
}
public function originCity() public function originCity()
{ {
return $this->belongsTo(City::class, 'origin_city_id'); return $this->belongsTo(City::class, 'origin_city_id');
} }
public function city() public function city()
{ {
return $this->belongsTo(City::class, 'destination_city_id'); return $this->belongsTo(City::class, 'destination_city_id');
} }
public function tourDepartures() public function tourDepartures()
{ {
return $this->hasMany(TourDeparture::class , 'tour_id'); return $this->hasMany(TourDeparture::class , 'tour_id');
} }
public function file() public function file()
{ {
return $this->belongsTo(File::class, 'file_id'); return $this->belongsTo(File::class, 'file_id');
} }
public function comments()
{
return $this->hasMany(Comment::class, 'tour_id');
}
} }
+4
View File
@@ -104,4 +104,8 @@ class User extends Authenticate
{ {
return $this->hasMany(Passenger::class); return $this->hasMany(Passenger::class);
} }
public function comments()
{
return $this->hasMany(Comment::class, 'user_id');
}
} }