Livewire Status Board


June 5th, 2020


Andrés Santibáñez has just released a new Livewire component to show records according to their current status. Here is a preview for how it works:


To use this component, you must create a new Livewire component that extends from

You can use make:livewire to create a new component. For example.

1php artisan make:livewire SalesOrdersStatusBoard

In the SalesOrdersStatusBoard class, instead of extending from the base Livewire Component class,
extend from LivewireStatusBoard. Also, remove the render method.
You’ll have a class similar to this snippet.

1class SalesOrdersStatusBoard extends LivewireCalendar
3 //

In this class, you must override the following methods to display data

1public function statuses() : Collection
3 //
6public function records() : Collection
8 //

As you may have noticed, both methods return a collection. statuses() refers to all the different status values
your data may have in different points of time. records() on the other hand, stand for the data you want to show
that could be in any of those previously defined statuses() collection.

To show how these two methods work together, let’s discuss an example of Sales Orders and their different status
along the sales process: Registered, Awaiting Confirmation, Confirmed, Delivered. Each Sales Order might be in a different
status at specific times. For this example, we might define the following collection for statuses()

1public function statuses() : Collection
3 return collect([
4 [
5 'id' => 'registered',
6 'title' => 'Registered',
7 ],
8 [
9 'id' => 'awaiting_confirmation',
10 'title' => 'Awaiting Confirmation',
11 ],
12 [
13 'id' => 'confirmed',
14 'title' => 'Confirmed',
15 ],
16 [
17 'id' => 'delivered',
18 'title' => 'Delivered',
19 ],
20 ]);

For each status we define, we must return an array with at least 2 keys: id and title.

Now, for records() we may define a list of Sales Orders that come from an Eloquent model in our project

1public function records() : Collection
3 return SalesOrder::query()
4 ->map(function (SalesOrder $salesOrder) {
5 return [
6 'id' => $salesOrder->id,
7 'title' => $salesOrder->client,
8 'status' => $salesOrder->status,
9 ];
10 });

As you might see in the above snippet, we must return a collection of array items where each item must have at least
3 keys: id, title and status. The last one is of most importance since it is going to be used to match to which
status the record belongs to. For this matter, the component matches status and records with the following

1$status['id'] === $record['status'];

To render the component in a view, just use the Livewire tag or include syntax

1<livewire:sales-orders-status-board />

The GitHub project readme covers all the details on how to use it, and if you’ve ever needed a quick way to create a UI around status, this is one to add to your arsenal.

Filed in:

Eric L. Barnes

Eric is the creator of Laravel News and has been covering Laravel since 2012.