{"repo":"spatie/laravel-model-status","free":true,"listed":false,"github":"https://github.com/spatie/laravel-model-status","clone":"git clone https://github.com/spatie/laravel-model-status.git","description":"Easily add statuses to your models","language":"PHP","stars":1058,"topics":["laravel","eloquent","model","status","php"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"Assign statuses to Eloquent models Imagine you want to have an Eloquent model hold a status. It's easily solved by just adding a status field to that model and be done with it. But in case you need a history of status changes or need to store some extra info on why a status changed, just adding a single field won't cut it. This package provides a HasStatuses trait that, once installed on a model, allows you to do things like this: 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 must publish the migration with: Migrate the statuses table: Optionally you can publish the config-file with: This is the contents of the file which will be published at config/model-status.php Usage Add the HasStatuses trait to a model you like to use statuses on. Set a new status You can set a new status like this: A reason for the status change can be passed as a second argument. setStatus and forceSetStatus also accept enums: Backed enums are stored using their value. Unit enums are stored using their case name. Restrict statuses to an enum You can restrict which statuses a model accepts by overriding the statusEnumClass me","default_branch":null,"files":null,"tree":[],"storefront":"/r/spatie","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/spatie/laravel-model-status/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."}