›
byrcsc/laravel-assignment · 1.x
This page lists each key in config/assignment.php with its default and the effect of changing it.
php artisan vendor:publish --tag="assignment-config"config/assignment.php holds infrastructure and wiring: table names, key
types, which profile serves which model, and which notifications go out.
Selection behaviour belongs on a profile or at the call site.
return [
'tables' => [
'assignments' => 'assignments',
'scopes' => 'assignment_scopes',
'queue' => 'assignment_queue',
],
'assignable_key_type' => env('ASSIGNMENT_ASSIGNABLE_KEY_TYPE', 'id'),
'assignee_key_type' => env('ASSIGNMENT_ASSIGNEE_KEY_TYPE', 'id'),
'profiles' => [],
'notifications' => [
'offered' => ByRcsc\LaravelAssignment\Notifications\OfferReceived::class,
'offer_expired' => ByRcsc\LaravelAssignment\Notifications\OfferExpired::class,
'assigned' => ByRcsc\LaravelAssignment\Notifications\AssignmentReceived::class,
'unassigned' => ByRcsc\LaravelAssignment\Notifications\AssignmentRemoved::class,
],
'notification_channels' => ['mail'],
'dispatch_expiry_jobs' => false,
];| Key | Default | Purpose |
|---|---|---|
tables.assignments | assignments | The history table |
tables.scopes | assignment_scopes | Rotation state, one row per scope string |
tables.queue | assignment_queue | Assignables waiting for a candidate |
assignable_key_type | id | Column type for assignable_id |
assignee_key_type | id | Column type for assignee_id |
profiles | [] | Assignable class to profile class |
notifications.offered | OfferReceived::class | Sent when an offer is made |
notifications.offer_expired | OfferExpired::class | Sent when an offer lapses |
notifications.assigned | AssignmentReceived::class | Sent when an assignment becomes active |
notifications.unassigned | AssignmentRemoved::class | Sent when an assignment is taken away |
notification_channels | ['mail'] | Channels for every notification |
dispatch_expiry_jobs | false | Queue a delayed job per expiring cascade offer |
Renaming a table changes both the migration and the models, so publish the config before migrating. If you change a name after migrating, rename the table by hand.
'tables' => [
'assignments' => 'work_assignments',
'scopes' => 'work_assignment_scopes',
'queue' => 'work_assignment_queue',
],The models read table names from config at runtime, not from a hardcoded string.
The assignments and assignment_queue tables store polymorphic keys. Their
column types must match your models' key types.
ASSIGNMENT_ASSIGNABLE_KEY_TYPE=uuid
ASSIGNMENT_ASSIGNEE_KEY_TYPE=ulid| Value | Column |
|---|---|
id | Unsigned big integer |
uuid | UUID |
ulid | ULID |
string | String |
Any other value throws an InvalidArgumentException when the migration runs.
Know these constraints before you choose key types:
string.'profiles' => [
App\Models\Enquiry::class => App\Assignment\EnquiryProfile::class,
App\Models\Callout::class => App\Assignment\CalloutProfile::class,
],The key is the assignable class and the value is the profile class name. The container resolves profiles.
The lookup checks the assignable's class and then its parent classes, so a
profile registered against a base class serves subclasses that have none of
their own. autoAssign() throws NoProfile for a model with no match.
A value that is not a string, or a class that does not extend
AssignmentProfile, throws an UnexpectedValueException at resolution time.
Each key names the class sent at that moment, and null silences it:
'notifications' => [
'offered' => App\Notifications\CrewOfferReceived::class,
'offer_expired' => null,
'assigned' => ByRcsc\LaravelAssignment\Notifications\AssignmentReceived::class,
'unassigned' => ByRcsc\LaravelAssignment\Notifications\AssignmentRemoved::class,
],The container builds the class and passes the assignment as assignment. See
notifications.
'notification_channels' => ['mail', 'database'],The list applies to every notification. database needs Laravel's
notifications table, so the default leaves it off. Override via() on a
replacement class when one notification needs different channels from the
rest.
'dispatch_expiry_jobs' => true,With this on, creating a cascade offer that has an expires_at also queues a
delayed job for that moment. The job expires the offer and advances the cascade
with second-level precision.
The setting does not change correctness. An overdue offer stops holding its
slot at its timestamp either way. Keep assignment:tick scheduled to catch
jobs that fail or go missing. See
expiry and scheduling.