feat: update user and flight models and add comment and admin models
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -146,9 +146,9 @@ class Flight extends Model
|
||||
{
|
||||
return $this->hasMany(Booking::class);
|
||||
}
|
||||
|
||||
public function tours()
|
||||
public function comments()
|
||||
{
|
||||
return $this->hasMany(Tour::class, 'file_id');
|
||||
return $this->hasMany(Comment::class, 'flight_id');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+10
-6
@@ -40,7 +40,9 @@ class Tour extends Model
|
||||
protected $casts = [
|
||||
'origin_city_id' => 'int',
|
||||
'destination_city_id' => 'int',
|
||||
'file_id' => 'int'
|
||||
'file_id' => 'int',
|
||||
'tour_mode'=> 'int',
|
||||
'tour_scope' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
@@ -50,7 +52,9 @@ class Tour extends Model
|
||||
'origin_city_id',
|
||||
'destination_city_id',
|
||||
'file_id',
|
||||
'tour_type'
|
||||
'tour_type',
|
||||
'tour_mode',
|
||||
'tour_scope'
|
||||
];
|
||||
#[Scope]
|
||||
protected function applySort(Builder $query, ?string $sort = null): void
|
||||
@@ -73,10 +77,6 @@ class Tour extends Model
|
||||
}
|
||||
}
|
||||
|
||||
public function flight()
|
||||
{
|
||||
return $this->belongsTo(Flight::class, 'file_id');
|
||||
}
|
||||
public function originCity()
|
||||
{
|
||||
return $this->belongsTo(City::class, 'origin_city_id');
|
||||
@@ -96,4 +96,8 @@ class Tour extends Model
|
||||
{
|
||||
return $this->belongsTo(File::class, 'file_id');
|
||||
}
|
||||
public function comments()
|
||||
{
|
||||
return $this->hasMany(Comment::class, 'tour_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,4 +104,8 @@ class User extends Authenticate
|
||||
{
|
||||
return $this->hasMany(Passenger::class);
|
||||
}
|
||||
public function comments()
|
||||
{
|
||||
return $this->hasMany(Comment::class, 'user_id');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user