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.

24 lines
523 B

  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Movim\Image;
  5. class Sticker extends Model
  6. {
  7. public function pack()
  8. {
  9. return $this->belongsTo(StickersPack::class, 'name', 'pack');
  10. }
  11. public function getImagePathAttribute(): string
  12. {
  13. return PUBLIC_STICKERS_PATH . '/' . $this->attributes['pack'] . '/' . $this->attributes['filename'];
  14. }
  15. public function getUrlAttribute(): string
  16. {
  17. return Image::getOrCreate($this->attributes['cache_hash']);
  18. }
  19. }