Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

realodix/urlhub

532 stars
3 code files
View realodix/urlhub on GitHub

app/Services/UserService.php

Open in GitHub
use Illuminate\Support\Facades\Hash;
 
class UserService
{
public function updateUserEmail(array $data, object $user)
{
$user->email = $data['email'];
$user->save();
 
return $user;
}
 
public function updateUserPassword(array $data, object $user)
{
$user->password = Hash::make($data['new-password']);
$user->save();
 
return $user;
}
}

app/Http/Controllers/Dashboard/User/UserController.php

Open in GitHub
use App\Http\Controllers\Controller;
use App\Http\Requests\UpdateUserEmail;
use App\Models\User;
use App\Services\UserService;
 
class UserController extends Controller
{
public function __construct(protected UserService $userSrvc)
{}
 
public function update(UpdateUserEmail $request, User $user)
{
$data = $request->only('email');
 
$this->userSrvc->updateUserEmail($data, $user);
 
return redirect()->back()
->withFlashSuccess(__('Profile updated.'));
}
}

app/Http/Controllers/Dashboard/User/ChangePasswordController.php

Open in GitHub
use App\Http\Controllers\Controller;
use App\Http\Requests\UpdateUserPassword;
use App\Models\User;
use App\Services\UserService;
 
class ChangePasswordController extends Controller
{
public function __construct(protected UserService $userSrvc)
{
//
}
public function update(UpdateUserPassword $request, User $user)
{
$data = $request->only('new-password');
 
$this->userSrvc->updateUserPassword($data, $user);
 
return redirect()->back()
->withFlashSuccess(__('Password changed successfully !'));
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.