Closed ekcltfrm closed 2 years ago
Hello and Happy New Year to all,
I am trying add my translations from request to my create method i'm getting this error
SQLSTATE[42S22]: Column not found: 1054 Unknown column '0' in 'field list'
How can i pass the translation collection i am creating with that foreach loop to my create method data;
$data = collect(); foreach ($locales as $locale) { $data[$locale->isocode] = [ 'name' => $request->input("name:$locale->isocode"), ]; } $item= Item::create([ $data, 'customer_id' => $customer->id, 'user_id' => $user->id, 'abc_id' => $abc->id, 'project_id' => $project->id, 'tax_rate' => $request->input('tax_rate'), 'quantity' => $request->input('quantity'), 'unitprice' => $request->input('unitprice'), ]);
What would be the correct way to save initial model data with translations (rather than first creating the data in a local then creating form to update translations, i am already doing that) ?
i was able to solve my issue with array_merge() function in my method.
Hello and Happy New Year to all,
I am trying add my translations from request to my create method i'm getting this error
SQLSTATE[42S22]: Column not found: 1054 Unknown column '0' in 'field list'
How can i pass the translation collection i am creating with that foreach loop to my create method data;
What would be the correct way to save initial model data with translations (rather than first creating the data in a local then creating form to update translations, i am already doing that) ?