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.
1 parent 869b050 commit ed39d32Copy full SHA for ed39d32
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;
@@ -263,4 +264,13 @@ public function addScript(string $view): static
263
264
265
return $this;
266
}
267
+
268
+ public function addScriptIfCan(string $permission, string $view): static
269
+ {
270
+ if (Gate::allows($permission)) {
271
+ $this->addScript($view);
272
+ }
273
274
+ return $this;
275
276
0 commit comments