You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1019 B

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <?php
  2. namespace App\Models;
  3. use App\Models\Traits\Validatable;
  4. use App\Models\Traits\ValidationMaker;
  5. use Illuminate\Database\Eloquent\Casts\Attribute;
  6. use Illuminate\Database\Eloquent\Factories\HasFactory;
  7. use Illuminate\Database\Eloquent\Model;
  8. use Illuminate\Database\Eloquent\SoftDeletes;
  9. use Illuminate\Support\Str;
  10. class File extends Model
  11. {
  12. use HasFactory, SoftDeletes;
  13. protected $primaryKey = 'uuid';
  14. public $incrementing = false;
  15. protected $fillable = [
  16. "uuid",
  17. "original_name",
  18. "ext",
  19. "mimetype",
  20. "width",
  21. "server_path",
  22. "height",
  23. "file_size",
  24. "sort",
  25. "alts",
  26. "description",
  27. "user_id",
  28. "ip",
  29. "model_id",
  30. "collection_id",
  31. "published_at",
  32. ];
  33. protected $casts = [
  34. 'alts' => 'array',
  35. ];
  36. protected function alts(): Attribute
  37. {
  38. return Attribute::make(
  39. set: fn ($value) => json_encode($value),
  40. );
  41. }
  42. }