Download the PHP package byrcsc/laravel-assignment without Composer

On this page you can find all versions of the php package byrcsc/laravel-assignment. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-assignment

Laravel Assignment

Latest Version on Packagist GitHub Tests Action Status GitHub PHPStan Action Status Total Downloads

Assignment routing for Eloquent models: any model can be assigned, any model can be an assignee, with atomic slot claims, an offer and accept handshake, pluggable selection policies, fair per-scope rotation, a priority queue for work nobody can take yet, and offer cascades that pass unanswered offers to the next candidate.

The package provides the assignment engine. Your application owns its UI, users, teams, eligibility rules, and what an assignment means. You pass the candidates. The engine picks one and writes the assignment atomically. It fires Laravel events when the state changes.

Laravel Tested PHP versions
12.x 8.3, 8.4
13.x 8.3, 8.4

Atomic on MySQL, PostgreSQL, and SQLite. Two concurrent calls cannot both fill the same slot, and round robin cursors cannot skip or repeat a candidate under load.

Installation

Install the package and publish its migrations:

Schedule the tick. An offer stops holding its slot at its expires_at, whether or not the tick has run. The tick advances cascades and flushes the queue.

What an assignment is

An assignment binds one assignee (any model: a user, a crew, a team) to one assignable (any model: an enquiry, an order, a ticket, a callout), optionally under a role.

At most one open assignment exists per assignable and role. Open means offered or active. A unique index enforces this, not application code. assign() creates an active assignment. offer() creates an assignment that the assignee must accept or decline, and the offer holds the slot until it is answered or expires. Assignments end instead of being deleted. An ended row records ended_at and ended_reason, so the rows are the history.

Quick start

Add Assignable to the models that get assigned and Assignee to the models that take assignments:

Assign manually, read state, and end assignments:

Auto-assign with the fluent builder. You bring the candidates, a policy picks one:

Every enquiry from that trade rotates through the same cursor, so tradies take turns even though you rebuild the candidate list on every call. Call offer() instead of assign() to let the candidate accept or decline. Offers from the builder do not cascade. To pass a declined or expired offer to the next candidate, use autoAssign() with an offer-mode profile. See offer cascades.

The builder is the same for both modes:

Method Does
Assignment::for($assignable) Starts the chain
among($candidates) The candidates: a collection, an array, or a closure returning either
role($role) Which slot to fill
scope($scope) The state key stateful policies rotate on
using($policy) A policy class name, an instance, or a closure
by($actor) Records the actor in assigned_by
expiresIn($seconds) Puts an expires_at on an offer
assign() Creates the assignment, active
offer() Creates the offer, pending an answer
queue($priority) Parks the assignable in the queue instead

A role is a non-empty string, or null for the default slot. expiresIn() takes at least one second, or null for an offer that never expires. assign() and offer() return null when the candidate list is empty or the policy picks nobody. Every other failure throws.

Eligibility is yours, selection is the engine's

The policy list contains no territory policy and no skill policy. Who can take an assignment (territory, skills, shift, capacity) is a query on data your application already owns. Who gets it, among the eligible, is what the engine decides. Routing by suburb is therefore a query plus a scope, not a feature:

Per-assignee capacity caps work the same way: filter candidates by $crew->workload() < 3 before passing them in.

Selection policies

Policy Picks State
RoundRobin The next candidate after the last one this scope picked Cursor per scope
LeastWorkload The candidate with the fewest open assignments None
Random Any candidate None
FirstAvailable The first candidate in the order you passed them None
Any closure Whatever you return Yours

LeastWorkload counts active plus offered, so ten unanswered offers cannot pile onto one idle crew. FirstAvailable makes your query order the priority order. A closure receives the assignable and the candidates, and returns one candidate:

Return null to select nobody. Returning a model that is not in $candidates throws, so a policy cannot pick an ineligible assignee. Reusable policies implement SelectionPolicy.

Documentation

The versioned documentation contains the complete setup, guides, operations advice, and API reference:

Out of scope

The package does not provide the following:

Versioning

The package follows semantic versioning.

Bug fixes go into the newest version only. To get a fix, upgrade to it.

Questions and issues

This package is maintained by one person, so replies can take a while. Everything gets read.

License

MIT. See CHANGELOG.md.


All versions of laravel-assignment with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/bus Version ^12.0||^13.0
illuminate/console Version ^12.0||^13.0
illuminate/contracts Version ^12.0||^13.0
illuminate/database Version ^12.0||^13.0
illuminate/events Version ^12.0||^13.0
illuminate/notifications Version ^12.0||^13.0
illuminate/support Version ^12.0||^13.0
spatie/laravel-package-tools Version ^1.16
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package byrcsc/laravel-assignment contains the following files

Loading the files please wait ...