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.

74 lines
1.5 KiB

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. "avalible_exts",
  28. "memetypes",
  29. "model",
  30. "expire_date",
  31. ];
  32. protected $casts = [
  33. 'exts' => 'array',
  34. 'avalible_exts' => 'array',
  35. 'memetypes' => 'array',
  36. ];
  37. protected function exts(): Attribute
  38. {
  39. return Attribute::make(
  40. set: fn ($value) => json_encode($value),
  41. );
  42. }
  43. protected function avalible_exts(): Attribute
  44. {
  45. return Attribute::make(
  46. set: fn ($value) => json_encode($value),
  47. );
  48. }
  49. protected function memetypes(): Attribute
  50. {
  51. return Attribute::make(
  52. set: fn ($value) => json_encode($value),
  53. );
  54. }
  55. public function getExts()
  56. {
  57. return implode(",", app()->collection->exts);
  58. }
  59. public function getMimeTypes()
  60. {
  61. return implode(",", app()->collection->mimetypes);
  62. }
  63. }