Package Data | |
---|---|
Maintainer Username: | flynsarmy |
Maintainer Contact: | flynsarmy@gmail.com (Flyn San) |
Package Create Date: | 2013-12-28 |
Package Last Update: | 2024-02-05 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-18 03:03:32 |
Package Statistics | |
---|---|
Total Downloads: | 779,591 |
Monthly Downloads: | 7,726 |
Daily Downloads: | 117 |
Total Stars: | 170 |
Total Watchers: | 12 |
Total Forks: | 38 |
Total Open Issues: | 8 |
This package generates and returns a compiled view from a blade-syntax field in your Eloquent model.
Require this package in your composer.json and run composer update (or run composer require flynsarmy/db-blade-compiler:1.*
directly):
"flynsarmy/db-blade-compiler": "1.*"
After updating composer, add the ServiceProvider to the providers array in app/config/app.php
'Flynsarmy\DbBladeCompiler\DbBladeCompilerServiceProvider',
and the Facade to the aliases array in the same file
'DbView' => 'Flynsarmy\DbBladeCompiler\Facades\DbView',
You can also optionally publish the config-file
php artisan config:publish flynsarmy/db-blade-compiler
Require this package in your composer.json and run composer update (or run composer require flynsarmy/db-blade-compiler:2.*
directly):
"flynsarmy/db-blade-compiler": "*"
After updating composer, add the ServiceProvider to the providers array in app/config/app.php
'Flynsarmy\DbBladeCompiler\DbBladeCompilerServiceProvider',
and the Facade to the aliases array in the same file
'DbView' => 'Flynsarmy\DbBladeCompiler\Facades\DbView',
You have to also publish the config-file
php artisan vendor:publish
This package offers a DbView
facade with the same syntax as View
but accepts a Model instance instead of path to view.
$template = Template::first();
return DbView::make($template)->with(['foo' => 'Bar'])->render();
Because you're passing a model to DbView::make()
, db-blade-compiler needs to know which field to compile. By default this is content
however you can set the field used with either of the following methods:
return DbView::make($template, ['foo' => 'Bar'], [], 'excerpt')->render();
return DbView::make($template)->field('excerpt')->with(['foo' => 'Bar'])->render();
You may set the default column used in the package config. You can enable using cache in compiling view from a blade-syntax field in your Eloquent model operation by enabling cache config in package config. By default this option is disabled.
db-blade-compiler is open-sourced software licensed under the MIT license