|
2 | 2 |
|
3 | 3 | namespace Ginkelsoft\DataTables; |
4 | 4 |
|
5 | | -/** |
6 | | - * Class representing an action that can be performed on a DataTable row. |
7 | | - */ |
8 | 5 | class Action |
9 | 6 | { |
10 | | - /** @var string The name of the action */ |
11 | 7 | public string $name; |
12 | | - |
13 | | - /** @var string The label displayed for the action */ |
14 | 8 | public string $label; |
15 | | - |
16 | | - /** @var string The route associated with the action */ |
17 | 9 | public string $route; |
| 10 | + public array $attributes = []; |
18 | 11 |
|
19 | 12 | /** |
20 | 13 | * Action constructor. |
21 | 14 | * |
22 | | - * @param string $name The action name |
23 | | - * @param string $label The action label |
24 | | - * @param string $route The route associated with the action |
| 15 | + * @param string $name Unique action name. |
| 16 | + * @param string $label Button label. |
| 17 | + * @param string $route Named route for the action. |
| 18 | + * @param array $attributes Additional HTML attributes (e.g., classes, styles). |
25 | 19 | */ |
26 | | - public function __construct(string $name, string $label, string $route) |
| 20 | + public function __construct(string $name, string $label, string $route, array $attributes = []) |
27 | 21 | { |
28 | 22 | $this->name = $name; |
29 | 23 | $this->label = $label; |
30 | 24 | $this->route = $route; |
| 25 | + $this->attributes = $attributes; |
31 | 26 | } |
32 | 27 |
|
33 | 28 | /** |
34 | | - * Static method to create a new action instance. |
| 29 | + * Factory method to create an action instance. |
35 | 30 | * |
36 | | - * @param string $name The action name |
37 | | - * @param string $label The action label |
38 | | - * @param string $route The route associated with the action |
39 | | - * @return self A new Action instance |
| 31 | + * @param string $name Unique action name. |
| 32 | + * @param string $label Button label. |
| 33 | + * @param string $route Named route for the action. |
| 34 | + * @param array $attributes Additional HTML attributes (e.g., classes, styles). |
| 35 | + * @return self |
40 | 36 | */ |
41 | | - public static function make(string $name, string $label, string $route): self |
| 37 | + public static function make(string $name, string $label, string $route, array $attributes = []): self |
42 | 38 | { |
43 | | - return new self($name, $label, $route); |
| 39 | + return new self($name, $label, $route, $attributes); |
44 | 40 | } |
45 | 41 | } |
0 commit comments