Edit File: Region.php
<?php namespace App\Models; use App\Traits\ModelTrait; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasMany; use Spatie\Translatable\HasTranslations; class Region extends BaseModel { use ModelTrait; const IMAGEPATH = 'regions'; use HasTranslations; protected $fillable = ['name', 'country_id']; public $translatable = ['name']; /** * Get the country that owns the Region * * @return BelongsTo */ public function country(): BelongsTo { return $this->belongsTo(Country::class, 'country_id', 'id'); } /** * Get all of the cities for the Region * * @return HasMany */ public function cities(): HasMany { return $this->hasMany(City::class, 'region_id', 'id'); } }
Back to File Manager