feat: add routes, model, controller and update related models relations
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Reliese Model.
|
||||
*/
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Class Favorite
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property int|null $tour_id
|
||||
* @property int|null $flight_id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class Favorite extends Model
|
||||
{
|
||||
protected $table = 'favorites';
|
||||
public static $snakeAttributes = false;
|
||||
|
||||
protected $casts = [
|
||||
'user_id' => 'int',
|
||||
'tour_id' => 'int',
|
||||
'flight_id' => 'int'
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'tour_id',
|
||||
'flight_id'
|
||||
];
|
||||
}
|
||||
@@ -150,5 +150,9 @@ class Flight extends Model
|
||||
{
|
||||
return $this->hasMany(Comment::class, 'flight_id');
|
||||
}
|
||||
public function favorites()
|
||||
{
|
||||
return $this->hasMany(Favorite::class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -100,4 +100,8 @@ class Tour extends Model
|
||||
{
|
||||
return $this->hasMany(Comment::class, 'tour_id');
|
||||
}
|
||||
public function favorites()
|
||||
{
|
||||
return $this->hasMany(Favorite::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,4 +108,8 @@ class User extends Authenticate
|
||||
{
|
||||
return $this->hasMany(Comment::class, 'user_id');
|
||||
}
|
||||
public function favorites()
|
||||
{
|
||||
return $this->hasMany(Favorite::class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user