Ejemplo n.º 1
0
Archivo: Topic.php Proyecto: enhive/vev
        }
        return asset('img/default-topic.jpg');
    }
    public function posts()
    {
        return $this->hasMany(Post::class)->ordered();
    }
    public function followers()
    {
        return $this->belongsToMany(User::class)->withPivot(['role']);
    }
    public function followersPaginated()
    {
        return $this->followers()->paginate(30);
    }
    public function getPaginatedFollowers()
    {
        return $this->followers()->paginate(30);
    }
    public function isFollowed()
    {
        if ($this->followers()->find(Auth::user()->id)) {
            return true;
        }
        return false;
    }
}
Topic::saving(function ($model) {
    $model->slug = Str::slug($model->title);
    $model->user_id = Auth::user()->id;
});