FleetCart/Modules/User/Http/Controllers/Admin/UserResetPasswordController.php
2023-12-03 14:07:47 +00:00

40 lines
1.0 KiB
PHP

<?php
namespace Modules\User\Http\Controllers\Admin;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Modules\User\Entities\User;
use Illuminate\Support\Facades\Mail;
use Modules\User\Mail\ResetPasswordEmail;
use Modules\User\Contracts\Authentication;
class UserResetPasswordController
{
/**
* Store a newly created resource in storage.
*
* @param Request $request
*
* @return Response
*/
public function store($id, Authentication $auth)
{
$user = User::findOrFail($id);
$code = $auth->createReminderCode($user);
Mail::to($user)
->send(new ResetPasswordEmail($user, $this->getResetCompleteURL($user, $code)));
return redirect()->route('admin.users.index')
->withSuccess(trans('user::messages.users.reset_password_email_sent'));
}
private function getResetCompleteURL($user, $code)
{
return route('admin.reset.complete', [$user->email, $code]);
}
}