List

Empower your users with the versatile ListComponent
. This dynamic feature allows for effortless creation and management of item lists. Set boundaries with min/max item constraints and customize the admin view with configurable columns. If you want, enable drag-and-drop reordering to give your audience full control over their list.
@foreach($homepage->list('banner')->sortable()->get() as $banner)
<span>{{ $banner->text('title') }}<\span>
{!! $banner->image('image')->getPicture() !!}
@endforeach
label(string $label)
Set the label of the list to show in the admin
$homepage->list('banner')->label('Banner')->get();
`labelPlural(string $labelPlural) Set the plural version of the label. Needed for the list in the admin.
$homepage->list('banner')->label('Banner')->labelPlural('Banners')->get();
min(int $min)
Validate the minimum number of items that can be added to the list.
$homepage->list('banner')->min(1)->get();
max(int $max)
Validate the maximum number of items that can be added to the list.
$homepage->list('banner')->max(5)->get();
columns(array $columns)
Customize the columns displayed in the admin panel when rendering your list. In this example, we focus solely on showcasing the image preview in the list. By default, the first 4 components are displayed.
@foreach($homepage->list('banner')->columns(['image'])->get() as $banner)
<span>{{ $banner->text('title') }}<\span>
{!! $banner->image('image')->getPicture() !!}
@endforeach
Keep in mind: On mobile, only the first component will be shown
sortable()
Enable sorting functionality for the list, allowing users to easily rearrange items according to their preferences.
@foreach($homepage->list('banner')->sortable()->get() as $banner)
Easily create and retrieve lists of items with straightforward syntax:
$homepage = newRoot(new \model\homepage);
$banners = $homepage->list('banner')->get();
You can access these items throughout your application:
$banners = \model\homepage\banner_list::query()->get();
Confetti’s intelligent understanding of components allows it to load an entire page, including hundreds of values, in a single query. This completely eliminates n+1 problems, delivering a significant performance boost compared to traditional data-loading methods. To achieve this, Confetti has developed its own specialized database.
first()
Retrieve the first item in the list.
$firstBanner = $homepage->list('banner')->first();
where(string|ComponentStandard $key, string $operator, mixed $value)
Filter the list based on a specified condition.
$banners = $homepage->list('banner')->where('is_active', '=', true)->get();
Alternatively, use the automatically generated banner is_active class:
use \model\homepage\banner_list\is_active;
$banners = $homepage->list('banner')->where(new is_active, '=', true)->get();
orderAscBy(string|ComponentStandard $key)
Sort the list in ascending or descending order. Ascending is the default.
$homepage->list('banner')->orderAscBy('title')->get();
$homepage->list('banner')->orderDescBy('title')->get();
Use ->sortable()
to enable user-driven sorting in the admin panel. Default order is descending.
limit(int $limit)
Restrict the number of items returned.
$homepage->list('banner')->limit(5)->get();
offset(int $offset)
Skip a specified number of items before returning results.
$homepage->list('banner')->offset(5)->get();