profile controller change

Cette révision appartient à :
shariful Islam 2023-12-09 13:26:45 +06:00
Parent c5721041e7
révision 914f4ceb36

Voir le fichier

@ -35,13 +35,26 @@ public function save_profile(Request $request)
$request->image->move(public_path('uploads/students'), $imageName);
$data->image = $imageName;
}
if ($data->save())
if ($data->save()){
$this->setSession($data);
return redirect()->back()->with('success', 'Data Saved');
else
return redirect()->back()->withInput()->with('error', 'Please try again');
}
} catch (Exception $e) {
// dd($e);
return redirect()->back()->withInput()->with('error', 'Please try again');
}
}
public function setSession($student)
{
return request()->session()->put(
[
'userId' => encryptor('encrypt', $student->id),
'userName' => encryptor('encrypt', $student->name_en),
'emailAddress' => encryptor('encrypt', $student->email),
'studentLogin' => 1,
'image' => $student->image ?? 'No Image Found'
]
);
}
}