dev-master
9999999-devCreate sql views with eloquent
MIT
The Requires
- php >=5.6.0
- illuminate/support >=5.3
by Jan Wytze Zuidema
1.0.0
1.0.0.0Create sql views with eloquent
MIT
The Requires
- php >=5.6.0
- illuminate/support >=5.3
by Jan Wytze Zuidema
Wallogit.com
2017 © Pedro Peláez
Create sql views with eloquent
With Eloquent view you can create a SQL view with the eloquent query builder. This will prevent huge SQL strings in your migrations., (*1)
Run composer require jwz104/eloquent-view., (*2)
Add the service provider to config/app.php:, (*3)
'providers' => [
Jwz104\EloquentView\EloquentViewServiceProvider::class,
]
Optionally add the facade:, (*4)
'aliases' => [
'EloquentView' => Jwz104\EloquentView\Facades\EloquentView::class,
]
Eloquent view is really easy to use.
Just parse a builder instance to the create method of the view builder., (*5)
Example migration:, (*6)
class CreateEmployeesView extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$builder = DB::table('employees')
->join('companies', 'employees.company_id', '=', 'companies.id')
->select('employees.*', 'companies.name');
EloquentView::create('employees_view', $builder);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
EloquentView::dropIfExists('employees_view');
}
}
Create sql views with eloquent
MIT
Create sql views with eloquent
MIT