File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 55use Illuminate \Contracts \Config \Repository ;
66use Illuminate \Contracts \View \Factory ;
77use Illuminate \Support \Collection ;
8+ use Illuminate \Support \Facades \Gate ;
89use Illuminate \Support \HtmlString ;
910use Illuminate \Support \Traits \Macroable ;
1011use 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) {
You can’t perform that action at this time.
0 commit comments