📜  如何在 laravel 中显示与用户相关的所有帖子 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:35.331000             🧑  作者: Mango

代码示例1
class User extends Eloquent {

    public function posts() {
        return $this->hasMany('Post');
    }

}

// in order to show it you need to do that in your blade file
{{Auth::user()->posts}}