2018-05-20 02:57:55 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
|
|
|
class Hashtag extends Model
|
|
|
|
{
|
2018-08-28 03:07:36 +00:00
|
|
|
public $fillable = ['name', 'slug'];
|
2018-05-20 02:57:55 +00:00
|
|
|
|
|
|
|
public function posts()
|
|
|
|
{
|
2018-08-28 03:07:36 +00:00
|
|
|
return $this->hasManyThrough(
|
2018-05-20 02:57:55 +00:00
|
|
|
Status::class,
|
|
|
|
StatusHashtag::class,
|
|
|
|
'hashtag_id',
|
|
|
|
'id',
|
|
|
|
'id',
|
|
|
|
'status_id'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-07-11 03:26:05 +00:00
|
|
|
public function url($suffix = '')
|
2018-05-20 02:57:55 +00:00
|
|
|
{
|
2019-07-11 03:26:05 +00:00
|
|
|
return config('routes.hashtag.base').$this->slug.$suffix;
|
2018-05-20 02:57:55 +00:00
|
|
|
}
|
|
|
|
}
|