PHP code example of byrcsc / laravel-checklist

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

    

byrcsc / laravel-checklist example snippets


use ByRcsc\LaravelChecklist\Authoring\TemplateBuilder;

$version = TemplateBuilder::make('Vehicle pre-trip inspection')
    ->passThreshold(80)
    ->section('Exterior', function (TemplateBuilder $builder): void {
        $builder->passFail('Tires are roadworthy')->critical()->weight(2);
        $builder->passFail('No fluid leaks underneath')
            ->

$draft = $version->newDraft();   // deep copy as version N+1, lineage carried
$draft->items()->where(...)->first()->update(['label' => 'Reworded']);
$v2 = $draft->publish();         // version N is left exactly as it was

use ByRcsc\LaravelChecklist\Concerns\HasChecklists;

class Vehicle extends Model
{
    use HasChecklists;
}

$checklist = $version->start(subject: $vehicle, assignedTo: $driver);

$checklist->answer($item, 'fail');   // validated and cast by the item's type,
                                     // and auto-transitions to in_progress

$checklist->addEvidence($response, $uploadedFile, 'photo');  // via Storage

$checklist->submit();   // refuses while anything 

Schedule::command('checklist:generate-due')->everyFifteenMinutes();
bash
composer vendor:publish --tag="checklist-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="checklist-config"
bash
php artisan vendor:publish --tag="checklist-translations"