Chron
204
7
Laravel

Is there a way to make the chain dynamic?

Posted 2 months ago by Chron

I want to make it like this..

$user = strtolower($request['acc_type']).'()';

That will determine where the registered user will go.

Account::create([
            'email' => $request['email'],
            'password' => Hash::make($request['password']),
            'acc_type' => $request['acc_type'], //----->> It can be "Admin", "Customer", "Company"
        ])->$user->create([
            'firstname' => $request['firstname'],
        ]);

But I got this error..

Call to a member function create() on null

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

Reply to

Use Markdown with GitHub-flavored code blocks.