I am using Laravel-5.8 for my project. When creating new employee, I want the user to only enter the email address. Then, the application will extract the emailid from the email and save it as username.
Already I have this code:
$employee = Employee::create([ 'fname' => $request->fname, 'lname' => $request->lname, 'email' => $request->email, 'usename' => ]);
So, from the code above how do I get emailid from email entered and save it as username. For example, if email is email@example.com, the username should be david2000.
How do I adjust my code to achive this.