public function verifyInformation($id)
{
if($id)
{
$getRequest = request::all()->toArray();
$user = User::where('id', $id)->first()->toArray();
foreach($getRequest as $row=>$value)
{
foreach($value as $rowKey => $result)
{
$array_key = array_keys($user);
$arrayDiff = array_diff($value, $user);
$find = $arrayDiff['field_name'];
if(in_array($find, $array_key))
{
foreach($array_key as $k => $v)
{
if($v == $find)
{
$fieldKey = $v;
$fieldValue = $arrayDiff['value'];
if($fieldValue){
$user = new User;
$user->$fieldKey = $fieldValue;
$user->save();
return redirect()->back()->with("status", "Well done!! Chef profile updated successfully");
}
}
}
}
}
}
}
}
Request has the arrayArray (
[0] => Array ( [id] => 1 [sm_id] => 1 [field_name] => first_name [value] => Sa [created_at] => 2017-02-27 14:17:35 [updated_at] => 2017-02-24 11:05:03 [deleted_at] => )
[1] => Array ( [id] => 2 [sm_id] => 4 [field_name] => phone [value] => 123467890 [created_at] => 2017-02-27 16:55:48 [updated_at] => 2017-02-27 11:02:27 [deleted_at] => )
[2] => Array ( [id] => 3 [sm_id] => 4 [field_name] => first_name [value] => Ak [created_at] => 2017-02-27 16:55:48 [updated_at] => 2017-02-27 11:02:27 [deleted_at] => )
[3] => Array ( [id] => 4 [sm_id] => 4 [field_name] => last_name [value] => Kumar [created_at] => 2017-02-27 16:55:48 [updated_at] => 2017-02-27 11:02:27 [deleted_at] => ) )
Here is users arrayArray (
[id] => 4 [social_id] => [role_id] => 0 [name] => [first_name] => mn [last_name] => jk [gender] => male [dob] => 02-02-2017 [language] => english [location] => London [address] => ABCD [email] => ma.ja@sxyz.com [phone] => 7894561230 [provider] => website [biography] => Here is about [created_at] => 2017-02-22 12:16:56 [updated_at] => 2017-02-22 12:16:56 [deleted_at] => )
from Latest question asked on Laravel tag.
via Developer Account