thibaud-dauce / sql-view
此包已被废弃,不再维护。未建议替代包。
创建SQL视图
v0.1
2014-07-30 15:36 UTC
Requires
- php: >=5.4.0
- illuminate/database: 4.2.*
- illuminate/support: 4.2.*
Requires (Dev)
- phpunit/phpunit: ~4.0
This package is auto-updated.
Last update: 2022-02-01 12:37:40 UTC
README
介绍
SQLView包允许您轻松为数据库创建视图。
安装
需要PHP 5.4+ 和 Laravel 4.2+。
要获取SQLView的最新版本,只需在您的composer.json
文件中包含"thibaud-dauce/sqsl-view": "0.*"
。然后,您需要运行composer install
或composer update
以下载它并更新自动加载器。
一旦安装了SQLView,您需要注册服务提供者。打开app/config/app.php
并在providers
键中添加以下内容。
'ThibaudDauce\SQLView\SQLViewServiceProvider'
如果您喜欢,可以在app/config/app.php
文件的aliases
键中注册SQLView
外观。
'SQLView' => 'ThibaudDauce\SQLView\Facades\SQLView'
使用方法
使用Artisan通常创建迁移文件:php artisan migrate:make add_user_view
然后填充如下
<?php use ThibaudDauce\SQLView\Blueprint; use Illuminate\Database\Query\Expression; use Illuminate\Database\Migrations\Migration; class AddUserView extends Migration { /** * Run the migrations. * * @return void */ public function up() { SQLView::create('user-view', function($view) { $query = $view->newQuery('table')->where('id', new Expression(3)); $view->setQuery($query); }); } /** * Reverse the migrations. * * @return void */ public function down() { SQLView::drop('user-view'); } }
待办:添加Artisan命令。