›
›
›
  1. docs
  2. ›
  3. byrcsc/laravel-checklist
1.x
Browse documentationOpenClose

Getting started

  • Introduction
  • Installation and setup
  • Quick start

Core concepts

  • Templates and versions
  • Items and sections
  • Checklist lifecycle
  • Answers and evidence
  • Conditional rules
  • Scoring
  • Recurring schedules
  • Audit history

Operations

  • Author a template
  • Run a checklist
  • Create a schedule
  • Customize notifications
  • Export and report
  • Verify audit history
  • Composing with sibling packages

Reference

  • Configuration
  • Builder API
  • Models and scopes
  • Events and notifications
  • Console commands
  • Enums and contracts
  • Testing
  • Troubleshooting

Getting started

  • Introduction
  • Installation and setup
  • Quick start

Core concepts

  • Templates and versions
  • Items and sections
  • Checklist lifecycle
  • Answers and evidence
  • Conditional rules
  • Scoring
  • Recurring schedules
  • Audit history

Operations

  • Author a template
  • Run a checklist
  • Create a schedule
  • Customize notifications
  • Export and report
  • Verify audit history
  • Composing with sibling packages

Reference

  • Configuration
  • Builder API
  • Models and scopes
  • Events and notifications
  • Console commands
  • Enums and contracts
  • Testing
  • Troubleshooting

byrcsc/laravel-checklist · 1.x

Composing with sibling packages.

Attach comments and multi-stage approval to checklists through polymorphic relations.

Laravel Checklist depends on no sibling package, and none of them depends on it. Sibling models reference a checklist, a version, or a single answer through polymorphic relations. Neither package needs to know about the other's models.

Attach from the sibling's side

The models in this package are final. You cannot add a sibling's trait to Checklist or Response, so the convenience methods those traits provide are not available on them.

Write the relation from the sibling's side instead, which is one or two extra lines. When you want the shorter syntax, put the trait on your own model, such as the vehicle, work order, or shift. Let that model carry the relation.

Discussion with byrcsc/laravel-comments

Create the comment against the morph keys:

use ByRcsc\LaravelComments\Models\Comment;

Comment::query()->create([
    'commentable_type' => $checklist->getMorphClass(),
    'commentable_id'   => $checklist->getKey(),
    'commentator_type' => $inspector->getMorphClass(),
    'commentator_id'   => $inspector->getKey(),
    'body'             => 'Tyre pressure looks low in the photo. Recheck before the run.',
]);

Reading them back is an ordinary morph query, and the sibling's own scopes apply unchanged:

Comment::query()
    ->where('commentable_type', $checklist->getMorphClass())
    ->where('commentable_id', $checklist->getKey())
    ->topLevel()
    ->with('replies')
    ->get();

Comment on a Response rather than the whole checklist when the discussion is about one answer. A comment can reference the response through the same polymorphic relation. The thread then survives the checklist being reopened and resubmitted.

Multi-stage sign-off with byrcsc/laravel-approval

The review() step in this package is deliberately lightweight: one reviewer, one outcome, one timestamp. When sign-off needs stages, quorums, delegation, or escalation, run the approval package over your own record and treat the checklist as the evidence:

use ByRcsc\LaravelApproval\Concerns\Approvable;

class SafetyRelease extends Model
{
    use Approvable;

    public function checklist(): BelongsTo
    {
        return $this->belongsTo(\ByRcsc\LaravelChecklist\Models\Checklist::class);
    }
}
$release = SafetyRelease::create(['checklist_id' => $checklist->id]);

$release->submitForApproval('safety-release');

Gate the submission on the checklist rather than duplicating its rules:

if (! $checklist->isClosed() || $checklist->passed !== true) {
    abort(422, 'The inspection has not passed.');
}

Wiring this to the checklist's own lifecycle takes one listener on ChecklistCompleted.

What to read next

  • Checklist lifecycle for what review() records and when isClosed() is true.
  • Events and notifications for the events that listeners can handle.
  • Models and scopes for the morph relations available on each model.
PreviousVerify audit historyNextConfiguration
View source

On this page

  1. Attach from the sibling's side
  2. Discussion with byrcsc/laravel-comments
  3. Multi-stage sign-off with byrcsc/laravel-approval
  4. What to read next