@shoaibali In that case, I would suggest you implement a many-to-many relationship where the foreign keys are user_id and post_id; whenever the User likes(/saves) a Post you attach across the relationship:
php artisan make:migration CreateSavedPostsTable --create=post_user
Implement then relationship
public function savedPosts()
{
return $this->belongsToMany(Post::class);
}
Define an endpoint for saving the Post; and corresponding Controller:
Route::post('posts/{post}/save', [SavedPostController::class, 'store'])->name('saved-posts.store');
Save the Post
public function store(Post $post)
{
auth()->user()->savedPosts()->attach($post->id);
return back();
}
Then you can get the saved posts from the relationship using the User instance:
@foreach(auth()->user()->savedPosts as $post)
// link and title, or something
@endforeach
Otherwise, consider any up-to-date favoriting package, e.g. https://github.com/overtrue/laravel-favorite