summaryrefslogtreecommitdiff
path: root/src/Toolbar/Dropdown.php
blob: 45bdbeecd8ce601edbfac742a3d4a5a56b472a33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php

declare(strict_types=1);

namespace Lightscale\LaralightTables\Toolbar;

use Illuminate\Support\Collection;
use Illuminate\View\View;
use Lightscale\LaralightTables\Toolbar\Concerns\WithAttributes;
use Lightscale\LaralightTables\Toolbar\Concerns\WithSlot;
use Lightscale\LaralightTables\Toolbar\Dropdown\Item as DropdownItem;

class Dropdown extends Item
{
    use WithAttributes;
    use WithSlot;

    /**
     * @var Collection<int, DropdownItem>
     */
    protected Collection $items;

    /**
     * @param  iterable<int, DropdownItem>  $items
     */
    public function items(iterable $items): static
    {
        $this->items = Collection::wrap($items);

        return $this;
    }

    public function render(): View
    {
        return view(
            'laralight-tables::toolbar.dropdown',
            [
                'attributes' => $this->getAttributes(),
                'slot' => $this->slot,
                'items' => $this->items,
            ]
        );
    }
}