| 12345678910111213141516171819202122232425262728293031 |
- <?php
-
- namespace App\Models;
-
- use Illuminate\Database\Eloquent\Casts\Attribute;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Support\Facades\Storage;
- use Spatie\Translatable\HasTranslations;
-
- class Badge extends Model
- {
- use HasTranslations;
-
- protected $guarded = ["id"];
- public $translatable = ["title", "img_alt"];
- protected $appends = ["img_url_link"];
-
- protected function imgUrlLink(): Attribute
- {
- return Attribute::make(
- get: fn ($value) => is_null($this->ing_url) ? null :Storage::url($this->ing_url),
- );
- }
-
- public function projects()
- {
- return $this->morphedByMany(Project::class, 'badgeable');
- }
-
- }
|