Skip to content

Commit bfd5db4

Browse files
authored
Merge pull request #248 from hpacleb/feat-add-script-if-can-method
feat: Add addScriptIfCan method
2 parents b5bde2b + f0e9eb6 commit bfd5db4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Html/Builder.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,15 @@ public function addScript(string $view): static
273273
return $this;
274274
}
275275

276+
public function addScriptIfCan(string $ability, string $view): static
277+
{
278+
if (Gate::allows($ability)) {
279+
$this->addScript($view);
280+
}
281+
282+
return $this;
283+
}
284+
276285
public function addScriptIf(bool $condition, string $view): static
277286
{
278287
if ($condition) {

0 commit comments

Comments
 (0)