Skip to content

PHP code snippet – How to display all posts assocatied to user in laravel?

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}}
See also  How to make the select box font size small in CSS?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.