We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents f9f0951 + 48788ea commit 252eadaCopy full SHA for 252eada
src/Html/Builder.php
@@ -5,6 +5,7 @@
5
use Illuminate\Contracts\Config\Repository;
6
use Illuminate\Contracts\View\Factory;
7
use Illuminate\Support\Collection;
8
+use Illuminate\Support\Facades\Gate;
9
use Illuminate\Support\HtmlString;
10
use Illuminate\Support\Traits\Macroable;
11
use Yajra\DataTables\Utilities\Helper;
@@ -264,6 +265,15 @@ public function addScript(string $view): static
264
265
return $this;
266
}
267
268
+ public function addScriptIfCannot(string $ability, string $view): static
269
+ {
270
+ if (! (Gate::allows($ability))) {
271
+ $this->addScript($view);
272
+ }
273
+
274
+ return $this;
275
276
277
public function getTemplate(): string
278
{
279
return $this->template;
0 commit comments