noblemfd
1 month ago
149
3
Laravel

How to extract emailid from email before saving it

Posted 1 month ago by noblemfd

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 david2000@gmail.com, the username should be david2000.

How do I adjust my code to achive this.

Please sign in or create an account to participate in this conversation.