mikehenken/laravel-db-blade-compiler
最新稳定版本:v1.0.2
Composer 安装命令:
composer require mikehenken/laravel-db-blade-compiler
包简介
Render Blade templates from Eloquent Model Fields
README 文档
README
Render Blade templates from Eloquent Model Fields
This package generates and returns a compiled view from a blade-syntax field in your Eloquent model.
Installation
Require this package in your composer.json and run composer update (or run composer require mikeheknen/laravel-db-blade-compiler:1.* directly):
"mikeheknen/laravel-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
Usage
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.
License
db-blade-compiler is open-sourced software licensed under the MIT license
统计信息
- 总下载量: 39
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-03-18