I’m developing an application where the admin section is accessible via a subdomain like admin.mysite.test.
Everything works fine except sending emails with login credentials for users manually added by the administrator.
The email is sent correctly and is visible with services like Mailtrap, but when redirecting after sending, a 404 is generated, and the debugbar reports that the users route doesn’t exist.
If I make the admin area accessible via mysite.test/admin instead of the subdomain, everything works.
Any ideas?
Below is the resource method for inserting into the database.
/**
* Store a newly created resource in storage.
*/
public function store(UserFormRequest $request)
{
$user = new User($request->validated());
if ($file = $request->validated('image')) {
$path = $this->upload($file, $this->folder, $this->width, $this->height);
$user->image = $path;
}
$save = $user->save();
if ($save) {
$user->generated_password = $request->validated('password');
Mail::to($user->email)->send(new NewUserCreated($user));
return redirect()->route('admin.users.index')->with('success-message', 'Record inserito con successo.');
} else {
return back()->withInput()->with('error-message', 'Qualcosa è andato storto.');
}
}