mardi 18 février 2020

How can you create a user and assign a company_id to it? Laravel

I have a simple register account form on my front page, and I want that when a user is created, a company model is created in the same instence with a user model, but I don't know how to properly define it.

public function create(Request $request) {

    $create = User::create([
        'email' => $request['email'],
        'paypal_email' => $request['paypal_email'],
        'password' => Hash::make($request['password']),
    ]);
    if($create){

        return redirect('/dashboard');
    }
}
}

create_companies_table values are all nullable, the logic is, that you can update all info later, but when you create a user, a company model is created also, the data in the tables you can fill later.

How can I properly define the create function?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire