feat: add Province model and update City model relations
This commit is contained in:
@@ -16,6 +16,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||||||
*
|
*
|
||||||
* @property int $id
|
* @property int $id
|
||||||
* @property int $county_id
|
* @property int $county_id
|
||||||
|
* @property int $province_id
|
||||||
* @property string $name
|
* @property string $name
|
||||||
* @property int $status
|
* @property int $status
|
||||||
* @property Carbon $created_at
|
* @property Carbon $created_at
|
||||||
@@ -23,7 +24,9 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||||||
* @property string|null $deleted_at
|
* @property string|null $deleted_at
|
||||||
*
|
*
|
||||||
* @property Country $country
|
* @property Country $country
|
||||||
|
* @property Province $province
|
||||||
* @property Collection|Tour[] $tours
|
* @property Collection|Tour[] $tours
|
||||||
|
* @property Collection|User[] $users
|
||||||
*
|
*
|
||||||
* @package App\Models
|
* @package App\Models
|
||||||
*/
|
*/
|
||||||
@@ -35,11 +38,13 @@ class City extends Model
|
|||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'county_id' => 'int',
|
'county_id' => 'int',
|
||||||
|
'province_id' => 'int',
|
||||||
'status' => 'int'
|
'status' => 'int'
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'county_id',
|
'county_id',
|
||||||
|
'province_id',
|
||||||
'name',
|
'name',
|
||||||
'status'
|
'status'
|
||||||
];
|
];
|
||||||
@@ -49,8 +54,18 @@ class City extends Model
|
|||||||
return $this->belongsTo(Country::class, 'county_id');
|
return $this->belongsTo(Country::class, 'county_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function province()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Province::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function tours()
|
public function tours()
|
||||||
{
|
{
|
||||||
return $this->hasMany(Tour::class, 'destination_city_id');
|
return $this->hasMany(Tour::class, 'destination_city_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function users()
|
||||||
|
{
|
||||||
|
return $this->hasMany(User::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
<?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 Province
|
||||||
|
*
|
||||||
|
* @property int $id
|
||||||
|
* @property string $name
|
||||||
|
* @property int $status
|
||||||
|
* @property Carbon $created_at
|
||||||
|
* @property Carbon $updated_at
|
||||||
|
* @property string|null $deleted_at
|
||||||
|
*
|
||||||
|
* @property Collection|City[] $cities
|
||||||
|
* @property Collection|User[] $users
|
||||||
|
*
|
||||||
|
* @package App\Models
|
||||||
|
*/
|
||||||
|
class Province extends Model
|
||||||
|
{
|
||||||
|
use SoftDeletes;
|
||||||
|
protected $table = 'provinces';
|
||||||
|
public static $snakeAttributes = false;
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'status' => 'int'
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
'status'
|
||||||
|
];
|
||||||
|
|
||||||
|
public function cities()
|
||||||
|
{
|
||||||
|
return $this->hasMany(City::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function users()
|
||||||
|
{
|
||||||
|
return $this->hasMany(User::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user