Last active
August 27, 2017 02:16
-
-
Save ambrizals/0d66a3f73596c35b9c7547274ac9f233 to your computer and use it in GitHub Desktop.
AkunController : Part-Update
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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