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.

66 lines
1.3 KiB

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 Illuminate\Database\Eloquent\Casts\Attribute;
  4. use Illuminate\Database\Eloquent\Factories\HasFactory;
  5. use Illuminate\Database\Eloquent\Model;
  6. use Illuminate\Database\Eloquent\SoftDeletes;
  7. class Collection extends Model
  8. {
  9. use HasFactory, SoftDeletes;
  10. protected $fillable = [
  11. "name",
  12. "path",
  13. "public",
  14. "disk",
  15. "count",
  16. "tmp_support",
  17. "remove_tmp_time",
  18. "max_file_size",
  19. "min_file_size",
  20. "max_width",
  21. "min_width",
  22. "max_height",
  23. "min_height",
  24. "alt_required",
  25. "description_required",
  26. "exts",
  27. "ext",
  28. "mimetypes",
  29. "model",
  30. "expire_date",
  31. ];
  32. protected $casts = [
  33. 'exts' => 'array',
  34. 'mimetypes' => 'array',
  35. ];
  36. protected function exts(): Attribute
  37. {
  38. return Attribute::make(
  39. set: fn ($value) => json_encode($value),
  40. );
  41. }
  42. protected function mimetypes(): Attribute
  43. {
  44. return Attribute::make(
  45. set: fn ($value) => json_encode($value),
  46. );
  47. }
  48. public function getExts()
  49. {
  50. return implode(",", app()->collection->exts);
  51. }
  52. public function getMimeTypes()
  53. {
  54. return implode(",", app()->collection->mimetypes);
  55. }
  56. }