Laravel - Creating tables dynamically (without migration)

前端 未结 2 1674
悲&欢浪女
悲&欢浪女 2021-02-07 11:50

I\'m trying to create a table dynamically upon an admin request, and while it seems all fun and dandy like in most of Laravel\'s documentation, I can\'t seem to create

2条回答
  •  忘掉有多难
    2021-02-07 12:23

    Ugh, never mind... I worked on it for long enough, and the solution as always was... Very simple.

    I just had to figure a connection for the database first, so instead of

    Schema::create('tableName', function($table)
    {           
        $table->increments('id');
    });
    

    It is

    Schema::connection('mysql')->create('tableName', function($table)
    {
        $table->increments('id');
    });
    

    Hope this helps someone someday in the future!

提交回复
热议问题