alexdover/blade-set

A very simple blade extension which allows variables to be set.
57,981 22
Install
composer require alexdover/blade-set
Latest Version:v1.0.4
PHP:>=5.3.0
License:MIT
Last Updated:Oct 3, 2017
Links: GitHub  ·  Packagist
Maintainer: alexdover

Laravel 4 Blade @set operator

A very simple blade extension which allows variables to be set.

Current version is for Laravel 4.2.

If you wish to use with Laravel 4.1, please use v1.0.2

Example

@set('my_variable', $existing_variable)

You can then use the variable $my_variable in the template.

You might choose to fetch a bunch of models from your template, for example

@set('my_model_list', MyModel::where('something', '=', 1)->paginate(10))

Why?

Compare

<?php $my_model_list = MyModel::where('something', '=', 1)->paginate(10); ?>

to

@set('my_model_list', MyModel::where('something', '=', 1)->paginate(10))

I felt that the use of the @set was a more elegant solution in the context of blade templates.

Installation

Require this package in your composer.json and update composer. This will download the package.

"alexdover/blade-set": "1.*"

After updating composer, add the ServiceProvider to the providers array in app/config/app.php

'Alexdover\BladeSet\BladeSetServiceProvider',

All done!

Licence

You can use this package under the MIT license

Feedback

If you have any questions, feature requests or constructive ctritcism then please get in touch.

Twitter - @alexdover

Related Packages

spatie/laravel-blade-javascript

A Blade directive to export variables to JavaScript

966,893 619
philo/laravel-blade

Use the simple and yet powerful Laravel Blade templating engine as a standalone...

687,522 354
igaster/laravel-theme

Laravel Themes: Asset & Views folder per theme. Theme inheritance. Blade integra...

1,282,791 515
jeroennoten/laravel-adminlte

Easy AdminLTE v4 integration with Laravel

5,367,225 4,000
fitztrev/laravel-html-minify

Minifies the HTML output of Laravel 4 applications

216,611 413