Push to stack

March 8, 2017 ยท View on GitHub

Pragmatically push content to a stack inside blade views.

How this works

todo...

Example

layout.blade.php

<html>
<head>
@stack('head')
</head>
<body>
@section('body')
@stack('scripts')
</body>
</html>

Somewhere in your PHP Code (a Service Provider boot method, a Controller method, whatever)

$be = app('blade-extensions');
$be->pushToStack('scripts', 'layout', '<script src="' . asset('my-script.js') . '">');

Parameters

ParameterTypeDescription
$stackNamestringThe name of the stack
$targetViews`stringstring[]`
$content`stringClosure`