Hashtag.php 465 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. class Hashtag extends Model
  5. {
  6. public $fillable = ['name', 'slug'];
  7. public function posts()
  8. {
  9. return $this->hasManyThrough(
  10. Status::class,
  11. StatusHashtag::class,
  12. 'hashtag_id',
  13. 'id',
  14. 'id',
  15. 'status_id'
  16. );
  17. }
  18. public function url($suffix = '')
  19. {
  20. return config('routes.hashtag.base').$this->slug.$suffix;
  21. }
  22. }