A simple way of implementing user bookmarks in Laravel · vanrossum.dev    

       vanrossum.dev 

 Article

A simple way of implementing user bookmarks in Laravel
======================================================

 ![](https://vanrossum.dev/images/jeffrey-portrait.webp) By Jeffrey van Rossum

  vanrossum.dev  

  [      vanrossum.dev ](https://vanrossum.dev)                      

  [ ← Writing ](https://vanrossum.dev/posts)   [ ← Writing ](https://vanrossum.dev/posts) [ How it works ](#how-it-works) [ Creating the bookmarks table ](#creating-the-bookmarks-table) [ Creating the Bookmark model ](#creating-the-bookmark-model) [ Expanding the User model ](#expanding-the-user-model) [ In closing ](#in-closing) 

For a recent project, I needed a way for users to bookmark posts. Other than posts, I imagine the application to have other objects in the future too. So, with this in mind, I decided to build a solution which can handle other objects as well.

In this post I'd like to share what I did.

How it works
------------

Ideally, I would like the API to work something like this:

```php
