Apologies if this have been asked, but I don't seem to find the right answer.
I need to create a table in the DB from a Controller.
I was naive enough to believe the below would work:
Schema::connection('mysql')->create('mytable_'.$id, function($table)
{
$table->increments('id');
$table->timestamps();
});
Where $id
is a dynamic value passed into the controller's function.
I've placed the below on the top:
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
No luck - How can a DB table be created from the controller then? Any ideas?
Solution
As Ben Swinburne has said in the first comment, the use Schema
was missing!