Tuesday, May 23, 2017

Laravel fromTable not working on model updateOrCreate function

I am trying to change the model's table when using the update or create function, but it always uses the default database table which would be "Payouts" I am trying to change the table to "skyrim" by using the fromTable function.

$cluster_payout = 'skyrim';
    $user_payout = Payout::fromTable($cluster_payout)->updateOrCreate(
    ['user_id' => 1],
    ['game_id' => 1, 'locked' => 1]);

After executing the code, it uses the Payout Database and Payouts Table.

If I do

Payout::fromTable($cluster_payout)->first();

It'll use the Payout database with the Skyrim table. Any ideas?



via rebirth1078

Advertisement