AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

StoreImage.php 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Attributes\Fillable;
  4. use Illuminate\Database\Eloquent\Model;
  5. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  6. use Illuminate\Support\Facades\Storage;
  7. /**
  8. * A photo the merchant uploaded for the store's design, such as a hero banner.
  9. * The file lives on the "public" storage disk. The design points to it as "upload:{id}".
  10. *
  11. * @property int $id
  12. * @property int $store_id
  13. * @property string $path
  14. */
  15. #[Fillable(['path'])]
  16. class StoreImage extends Model
  17. {
  18. protected static function booted(): void
  19. {
  20. static::deleted(function (StoreImage $image): void {
  21. Storage::disk('public')->delete($image->path);
  22. });
  23. }
  24. /**
  25. * @return BelongsTo<Store, $this>
  26. */
  27. public function store(): BelongsTo
  28. {
  29. return $this->belongsTo(Store::class);
  30. }
  31. /**
  32. * Address of the photo, without the site name, so it works on any local port.
  33. */
  34. public function url(): string
  35. {
  36. return '/storage/'.$this->path;
  37. }
  38. public function reference(): string
  39. {
  40. return 'upload:'.$this->id;
  41. }
  42. }