Skip to content

Instantly share code, notes, and snippets.

@ambrizals
Last active August 27, 2017 02:16
Show Gist options
  • Save ambrizals/0d66a3f73596c35b9c7547274ac9f233 to your computer and use it in GitHub Desktop.
Save ambrizals/0d66a3f73596c35b9c7547274ac9f233 to your computer and use it in GitHub Desktop.
AkunController : Part-Update
public function update(Request $request) {
$akunid = Auth::user()->id;
if ($request->hasFile('fotoprofil')) {
$fotoprofil = $request->file('fotoprofil');
$namafoto = 'profil-'.$akunid.'.'.$fotoprofil->getClientOriginalExtension();
$destinationPath = ('img/profil');
$ubah_foto = Image::make($fotoprofil->getRealPath())->resize(150,150);
$ubah_foto->save($destinationPath.'/'.$namafoto,80);
}else {
$namafoto = Auth::user()->fotoprofil;
}
Auth::user()->update([
'name' => $request->name,
'email' => $request->email,
'biodata' => $request->biodata,
'fotoprofil' => $namafoto,
]);
return redirect('akun')->with('pesan','Profil berhasil dirubah');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment