Edit File: Country.php
<?php namespace App\Models; use App\Traits\ModelTrait; use Illuminate\Database\Eloquent\Relations\HasMany; use Spatie\Translatable\HasTranslations; class Country extends BaseModel { use HasTranslations, ModelTrait; const IMAGEPATH = 'countries'; protected $fillable = ['name','key' , 'flag']; public $translatable = ['name']; /** * Get the flag attribute. * @return string */ public function getFlagAttribute(): string { if ($this->attributes['flag']) { $flag = asset('admin/assets/flags/png/' . $this->attributes['flag']); } else { $flag = $this->defaultImage('users'); } return $flag; } /** * Get the flag attribute. * @return string */ public function myFlag(): string { return $this->attributes['flag']; } public function cities() { return $this->hasMany(City::class, 'country_id', 'id'); } }
Back to File Manager