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.

36 lines
826 B

  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Movim\Image;
  5. class Emoji extends Model
  6. {
  7. protected $table = 'emojis';
  8. public function users()
  9. {
  10. return $this->belongsToMany('App\Users')->withTimestamps();
  11. }
  12. public function pack()
  13. {
  14. return $this->belongsTo('App\EmojisPack', 'name', 'pack');
  15. }
  16. public function getImagePathAttribute(): string
  17. {
  18. return PUBLIC_EMOJIS_PATH . '/' . $this->attributes['pack'] . '/' . $this->attributes['filename'];
  19. }
  20. public function getUrlAttribute(): string
  21. {
  22. return Image::getOrCreate($this->attributes['cache_hash']);
  23. }
  24. public function getAliasPlaceholderAttribute(): string
  25. {
  26. return slugify(str_replace($this->attributes['pack'], '', $this->attributes['name']));
  27. }
  28. }