PHP code example of alejandrotrevi / laravel-ankal

1. Go to this page and download the library: Download alejandrotrevi/laravel-ankal 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/ */

    

alejandrotrevi / laravel-ankal example snippets


php artisan vendor:publish --provider="Alejandrotrevi\LaravelAnkal\LaravelAnkalServiceProvider" --tag="migrations"

use Alejandrotrevi\LaravelAnkal\HasStatuses;

class MyModel extends Model
{
    use HasStatuses;
}

Schema::create('my_table', function (Blueprint $table) {
    $table->statusColumns();
});

Schema::create('my_table', function (Blueprint $table) {
    $table->statusColumns('my_default_status');
});

$model->setStatus('status');
 
$model->setStatus('status', 'why this status changed?');

$model->status;
$model->reason;
$model->status_updated_at;

// All models with status "status"
Model::currentStatus('status');

// All models with status "status" or "other-status"
Model::currentStatus('status', 'other-status');
Model::currentStatus(['status', 'other-status']);

// All models except those with the "my-status" status
Model::exceptStatus('my-status');

// All models except those with the "my-status" or "other-status" statuses.
Model::exceptStatus('my-status', 'other-status');
Model::exceptStatus(['my-status', 'other-status']);