History.php 594B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Casts\Attribute;
  4. use Illuminate\Database\Eloquent\Model;
  5. use Illuminate\Support\Facades\Storage;
  6. use Spatie\Translatable\HasTranslations;
  7. class History extends Model
  8. {
  9. use HasTranslations;
  10. protected $guarded = ["id"];
  11. public $translatable = ['title', 'img_alt'];
  12. public $appends = [
  13. "img_url_link"
  14. ];
  15. protected function imgUrlLink(): Attribute
  16. {
  17. return Attribute::make(
  18. get: fn ($value) => is_null($this->img_url) ? null :Storage::url($this->img_url),
  19. );
  20. }
  21. }