{"repo":"spatie/laravel-prefixed-ids","free":true,"listed":false,"github":"https://github.com/spatie/laravel-prefixed-ids","clone":"git clone https://github.com/spatie/laravel-prefixed-ids.git","description":"Friendly prefixed IDs for Laravel models","language":"PHP","stars":176,"topics":["eloquent","laravel","api","dx"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"Friendly prefixed IDs for Laravel models Prefixing an id will help users to recognize what kind of id it is. Stripe does this by default: customer ids are prefixed with cus , secret keys in production are prefixed with sk live , secret keys of a testing environment with sk test and so on.... This package can generate such friendly prefixed ids for Eloquent models. Here's how such generated ids could look like. The package can retrieve the model for a given prefixed id. Support us We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products. We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall. Installation You can install the package via composer: Preparing your models On each model that needs a prefixed id, you should use the Spatie\\PrefixedIds\\Models\\Concerns\\HasPrefixedId trait. Preparing the database For each model that needs a prefixed id, you'll need to write a migration to add a prefixed id column to its underlying table. If you wish to use another attribute name, you should publish the config file (see below) and set the prefixed id attribute name config value to the attribute name of your liking. Registering models with prefixed ids To register your models, you should pass the desired prefix and the class name of your model to ","default_branch":null,"files":null,"tree":[],"storefront":"/r/spatie","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/spatie/laravel-prefixed-ids/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}