6
How can I create a view
in the Mysql database through migrations
of Laravel? I found nothing in the documentation.
6
How can I create a view
in the Mysql database through migrations
of Laravel? I found nothing in the documentation.
4
There is a yes and viable way to create Views
with Database Migrations
, but, it’s a forma textual
:
Commando: DB::statement
, in place of Schema::create
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class Creditosativos extends Migration
{
public function up()
{
DB::statement("CREATE VIEW v_creditos_ativos AS
SELECT * from creditos where status = 1");
}
public function down()
{
DB::statement("DROP VIEW v_creditos_ativos");
}
}
Reference:
Thank you very much!
No reason @Amandalima, it’s nice to have someone from the Laravel here ...
Browser other questions tagged mysql laravel view migrations
You are not signed in. Login or sign up in order to post.
Laravel Migrations works as an ORM?
– Marco Souza
Yes, it works..
– Amanda Lima
do not create views in the database, if your Framework provides an option to do so. see here an example of that in the application.
– Marco Souza
Any specific reason not to create Views? What’s the downside?
– Amanda Lima
Maintenance, you wouldn’t need to tinker with the database only in the application.
– Marco Souza