@@ -46,7 +46,7 @@ public function text(Closure|string $value): static
4646 /**
4747 * Set the download attribute.
4848 */
49- public function download (string $ filename = '' ): static
49+ public function download (string | Closure $ filename = '' ): static
5050 {
5151 $ this ->linkAttributes ['download ' ] = $ filename ;
5252
@@ -56,7 +56,7 @@ public function download(string $filename = ''): static
5656 /**
5757 * Set the target attribute.
5858 */
59- public function target (string $ target ): static
59+ public function target (string | Closure $ target ): static
6060 {
6161 $ this ->linkAttributes ['target ' ] = $ target ;
6262
@@ -66,7 +66,7 @@ public function target(string $target): static
6666 /**
6767 * Set the rel attribute.
6868 */
69- public function rel (string $ rel ): mixed
69+ public function rel (string | Closure $ rel ): mixed
7070 {
7171 $ this ->linkAttributes ['rel ' ] = $ rel ;
7272
@@ -92,7 +92,12 @@ public function resolveFormat(Request $request, Model $model): ?string
9292 ]);
9393
9494 $ attributes = array_map (
95- fn (?string $ value , string $ key ): string => sprintf ('%s="%s" ' , $ key , $ value ),
95+ static function (string |Closure |null $ attribute , string $ name ) use ($ request , $ model , $ value ): string {
96+ return match (true ) {
97+ $ attribute instanceof Closure => call_user_func_array ($ attribute , [$ request , $ model , $ value ]),
98+ default => sprintf ('%s="%s" ' , $ name , (string ) $ attribute ),
99+ };
100+ },
96101 array_values ($ attributes ),
97102 array_keys ($ attributes )
98103 );
0 commit comments