{$key})): \$__env->{$key} = 1; \$__env->startPush('{$pushName}'); ?>"; }); Blade::directive('endPushOnce', function ($expression) { return 'stopPush(); endif; ?>'; }); Blade::directive('styles', function ($expression) { $style_path = $expression; // remove single quotes $style_path = str_replace("'", "", $style_path); // remove double quotes $style_path = str_replace('"', "", $style_path); if (Str::is('http*', $style_path)) { $asset = false; } else { $asset = true; } $key = '__pushonce_styles_' . str_replace(['-', '.'], '_', pathinfo($style_path, PATHINFO_FILENAME)); $string = "{$key})): \$__env->{$key} = 1; \$__env->startPush('styles'); ?>"; if ($asset) { $string .= ''; } else { $string .= ''; } $string .= 'stopPush(); endif; ?>'; return $string; }); Blade::directive('scripts', function ($expression) { $script_path = $expression; // remove single quotes $script_path = str_replace("'", "", $script_path); // remove double quotes $script_path = str_replace('"', "", $script_path); if (Str::is('http*', $script_path)) { $asset = false; } else { $asset = true; } $key = '__pushonce_scripts_' . str_replace(['-','.'], '_', pathinfo($script_path, PATHINFO_FILENAME)); $string = "{$key})): \$__env->{$key} = 1; \$__env->startPush('scripts'); ?>"; if ($asset) { $string .= ''; } else { $string .= ''; } $string .= 'stopPush(); endif; ?>'; return $string; }); } }