PHP code example of zoparga / laravel-model-status

1. Go to this page and download the library: Download zoparga/laravel-model-status library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

zoparga / laravel-model-status example snippets



$model = \App\Models\Model::find(1);

$model->modelStatuses()->create([
        'name' => 'Default',
        'order' => 1,
        'is_enabled' => 1,
]);

$modelStatusId = 1;

$model->updateModelStatus($modelStatusId, [
        'name' => 'Ongoing',
        'order' => 2,
        'is_enabled' => 0,
]);


Or you can limit it here
$model->getLatestModelStatuses()->get();

Or you can limit it here
$model->getLatestModelStatuses()->limit(3)->get();

Of course you can get last created model status
$model->getLastModelStatus();


bash
php artisan vendor:publish --provider="zoparga\ModelStatus\ModelStatusServiceProvider" --tag="model-status-migrations"
php artisan migrate