{"repo":"spatie/laravel-model-states","free":true,"listed":false,"github":"https://github.com/spatie/laravel-model-states","clone":"git clone https://github.com/spatie/laravel-model-states.git","description":"State support for models","language":"PHP","stars":1301,"topics":["laravel","eloquent","states"],"license":"MIT","category":"databases-storage","readme_excerpt":"Adding state behaviour to Eloquent models This package adds state support to models. It combines concepts from the state pattern and state machines. It is recommended that you're familiar with both patterns if you're going to use this package. To give you a feel about how this package can be used, let's look at a quick example. Imagine a model Payment , which has three possible states: Pending , Paid and Failed . This package allows you to represent each state as a separate class, handles serialization of states to the database behind the scenes, and allows for easy state transitions. For the sake of our example, let's say that, depending on the state, the color of a payment should differ. Here's what the Payment model would look like: This is what the abstract PaymentState class would look like: Here's a concrete implementation of one state, the Paid state: And here's how it is used: 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: You can publish the config file with: This is the content of the published config file: Usage Please refer to the docs to learn how to use this package. Testing Changelog Pleas","default_branch":null,"files":null,"tree":[],"storefront":"/r/spatie","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/spatie/laravel-model-states/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."}