I have written a model function which has to give me all the posts with user's id, but it returns a model object instead. My model:
public static function my_posts(){
$userId = Auth::id();
$getPosts = DB::table('posts')->where('user_id',$userId)->get();
return $getPosts;
}
My Controller function:
public function myPosts(){
$getPosts = new posts_model();
$getPosts->my_posts();
return view("myposts",["posts" => $getPosts]);
}
How can I fix this error?