thibaud-dauce/sql-view

This package is abandoned and no longer maintained. No replacement package was suggested.

Create SQL view

v0.1 2014-07-30 15:36 UTC

This package is auto-updated.

Last update: 2022-02-01 12:37:40 UTC


README

Build Status Software License

Introduction

SQLView package allows you to easily create view for your database.

Installation

PHP 5.4+ and Laravel 4.2+ are required.

To get the latest version of SQLView, simply require "thibaud-dauce/sqsl-view": "0.*" in your composer.json file. You'll then need to run composer install or composer update to download it and have the autoloader updated.

Once SQLView is installed, you need to register the service provider. Open up app/config/app.php and add the following to the providers key.

  • 'ThibaudDauce\SQLView\SQLViewServiceProvider'

You can register the SQLView facade in the aliases key of your app/config/app.php file if you like.

  • 'SQLView' => 'ThibaudDauce\SQLView\Facades\SQLView'

Usage

Create a migration file as usual with artisan: php artisan migrate:make add_user_view

And then fill it like this:

<?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');
  }

}

TODO: Add artisan command.