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

Getting started

  • Introduction
  • Installation and setup
  • Quick start

Core concepts

  • Assignments and slots
  • Assigning and offering
  • Selection policies
  • Scopes and rotation
  • Profiles
  • The queue
  • Offer cascades

Operations

  • Expiry and scheduling
  • Reading assignments
  • Notifications
  • Events and listeners
  • Concurrency guarantees

Reference

  • Configuration
  • API reference
  • Console commands
  • Exceptions
  • Testing
  • Troubleshooting

Getting started

  • Introduction
  • Installation and setup
  • Quick start

Core concepts

  • Assignments and slots
  • Assigning and offering
  • Selection policies
  • Scopes and rotation
  • Profiles
  • The queue
  • Offer cascades

Operations

  • Expiry and scheduling
  • Reading assignments
  • Notifications
  • Events and listeners
  • Concurrency guarantees

Reference

  • Configuration
  • API reference
  • Console commands
  • Exceptions
  • Testing
  • Troubleshooting

byrcsc/laravel-assignment · 1.x

Console commands.

The package ships one command, which expires overdue offers and flushes the queue.

assignment:tick

php artisan assignment:tick

Advances expired assignment offers and flushes the assignment queue. It takes no arguments and no options.

Expired 3 offer(s) and assigned 1 queued item(s).

The command always exits 0. A run with nothing to do reports zeros.

What it does, in order

  1. Expiry. Finds every offer whose status is offered and whose expires_at has passed, reading them in batches of 100. Each one is ended with reason expired, dispatches OfferExpired, and has its cascade advanced to the next candidate.
  2. Flush. Runs the queue flush across every assignable type, in priority then arrival order.

The order matters: an offer that exhausts its cascade during step 1 is queued, and step 2 can pick it up in the same run with a fresh cascade.

Scheduling it

// routes/console.php
use Illuminate\Support\Facades\Schedule;

Schedule::command('assignment:tick')->everyMinute();

Every minute is a sensible default. Nothing about correctness depends on the cadence: an overdue offer stops holding its slot on its timestamp, whether or not the command has run. What the cadence controls is how long a declined or expired offer sits before moving on.

On a busy installation, add withoutOverlapping() so a slow run does not stack up behind itself. The work is safe to run concurrently either way, since expiry and the flush both claim rows before acting on them.

Schedule::command('assignment:tick')
    ->everyMinute()
    ->withoutOverlapping();

Running the halves separately

The flush half is available on its own:

use ByRcsc\LaravelAssignment\Facades\Assignment;

Assignment::flushQueue();
Assignment::flushQueue(Callout::class);

The expiry half has no public entry point other than this command, so schedule assignment:tick when you want expiry processed.

Splitting them is worth doing when you flush on your own domain events, such as a crew becoming available, and want expiry swept on a schedule without the immediate re-offer that a combined run can produce.

What the package does not ship

  • A scaffolding command. Profiles are ordinary classes; make:class is enough.
  • A status command. Read the models directly; see reading assignments.
  • A pruning command. Assignment rows are the history and nothing prunes them.
  • A health check. Publish and migrate, then assign in tinker.

What to read next

  • Expiry and scheduling for TTLs and delayed jobs.
  • The queue for what a flush actually does.
  • Offer cascades for what the expiry step advances.
PreviousAPI referenceNextExceptions
View source

On this page

  1. assignment:tick
  2. What it does, in order
  3. Scheduling it
  4. Running the halves separately
  5. What the package does not ship
  6. What to read next