git add .
git commit "add profile image upload support"
This commit is contained in:
@@ -3,19 +3,54 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\ProfileUpdateRequest;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class ProfileController extends Controller
|
||||
{
|
||||
public function edite()
|
||||
{
|
||||
$withoutHero=true;
|
||||
$user=Auth::User();
|
||||
return view('users.profile.edit',compact('user'));
|
||||
return view('users.profile.edit',compact('user','withoutHero'));
|
||||
}
|
||||
|
||||
public function update(ProfileUpdateRequest $request)
|
||||
{
|
||||
$user=$request->user();
|
||||
$inputs=$request->validated();
|
||||
|
||||
}
|
||||
if (!empty($inputs['new_password'])){
|
||||
$user->password=Hash::make($inputs['new_password']);
|
||||
}
|
||||
|
||||
unset(
|
||||
$inputs['current_password'],
|
||||
$inputs['new_password'],
|
||||
$inputs['new_password_confirmation'],
|
||||
|
||||
);
|
||||
|
||||
if ($request->hasFile('profile_image')) {
|
||||
|
||||
$image = $request->file('profile_image');
|
||||
|
||||
$imageName = time() . '.' . $image->getClientOriginalExtension();
|
||||
|
||||
$image->move(
|
||||
public_path('uploads/users'),
|
||||
$imageName
|
||||
);
|
||||
|
||||
$inputs['profile_image'] = $imageName;
|
||||
}
|
||||
$user->update($inputs);
|
||||
|
||||
return back()->with([
|
||||
'success','اطلاعات کاربر با موفقیت ویرایش شد.'
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user