Upload Photo
This commit is contained in:
parent
7c4ce06c82
commit
89f78b9fc3
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
@ -27,22 +28,22 @@ public function update(Request $request)
|
||||||
|
|
||||||
if ($request->hasFile('profile_image')) {
|
if ($request->hasFile('profile_image')) {
|
||||||
$image = $request->file('profile_image');
|
$image = $request->file('profile_image');
|
||||||
$imageName = time() . '.' . $image->getClientOriginalExtension();
|
$imagePath = $image->store('images', 'public');
|
||||||
$image->move(public_path('profile_images'), $imageName);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Auth::user()->update([
|
$user = User::findOrFail(auth()->user()->id);
|
||||||
'nama_lengkap' => $request->input('nama_lengkap'),
|
$user->nama_lengkap = $request->input('nama_lengkap');
|
||||||
'nim' => $request->input('nim'),
|
$user->nim = $request->input('nim');
|
||||||
'semester' => $request->input('semester'),
|
$user->semester = $request->input('semester');
|
||||||
'angkatan' => $request->input('angkatan'),
|
$user->angkatan = $request->input('angkatan');
|
||||||
]);
|
$user->foto = $imagePath;
|
||||||
|
$user->update();
|
||||||
|
|
||||||
return redirect('/dashboard')->with('success', 'Profile updated successfully');
|
return redirect('/dashboard')->with('success', 'Profile updated successfully1');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function changePassword(Request $request){
|
public function changePassword(Request $request)
|
||||||
|
{
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'current_password' => 'required',
|
'current_password' => 'required',
|
||||||
'new_password' => 'required|string|min:8|confirmed',
|
'new_password' => 'required|string|min:8|confirmed',
|
||||||
|
@ -63,5 +64,4 @@ public function changePassword(Request $request){
|
||||||
|
|
||||||
return redirect()->back()->with('success', 'Password changed successfully');
|
return redirect()->back()->with('success', 'Password changed successfully');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue