Level 122
$thing = Thing::create(['fname' => $request->firstname, 'lname' => $request->lastname]);
but honestly, I would just fix the form or the database so that you are using the same field names
2 likes
Suppose I have 2 columns in My Table "fname" and "lname" and I am sending POSt request as { "firstname" : "BOB" , "lastname" : "Kylene"} , I gopt the data in $request variable in called function of controller. How could i store this values in table as column name are different. How Can I copy this request data in Other Object ,SO I can insert it in table.
$thing = Thing::create(['fname' => $request->firstname, 'lname' => $request->lastname]);
but honestly, I would just fix the form or the database so that you are using the same field names
Please or to participate in this conversation.