Skip to content

Commit fe96503

Browse files
Merge branch 'master' into master
2 parents bbfacfd + d24dfd2 commit fe96503

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/Html/Builder.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Contracts\Config\Repository;
66
use Illuminate\Contracts\View\Factory;
77
use Illuminate\Support\Collection;
8+
use Illuminate\Support\Facades\Gate;
89
use Illuminate\Support\HtmlString;
910
use Illuminate\Support\Traits\Macroable;
1011
use Yajra\DataTables\Utilities\Helper;
@@ -272,11 +273,34 @@ public function addScript(string $view): static
272273
return $this;
273274
}
274275

276+
public function addScriptIf(bool $condition, string $view): static
277+
{
278+
if ($condition) {
279+
$this->addScript($view);
280+
}
281+
282+
return $this;
283+
}
284+
285+
public function addScriptIfCannot(string $ability, string $view): static
286+
{
287+
if (Gate::denies($ability)) {
288+
$this->addScript($view);
289+
}
290+
291+
return $this;
292+
}
293+
275294
public function getTemplate(): string
276295
{
277296
return $this->template;
278297
}
279298

299+
public function getAdditionalScripts(): array
300+
{
301+
return $this->additionalScripts;
302+
}
303+
280304
public function setTemplateData(array|\Closure $data = []): static
281305
{
282306
if ($data instanceof \Closure) {

0 commit comments

Comments
 (0)