Support the ongoing development of →
Eloquent Architecture Database
Last updated 2 years ago.

In your code, there's no condition that checks if the user is farmer or buyer.


You need to make a condition for identity user is farmer or buyer.

Please try below code. Hope its work for you.

$user = User::create([
            'username' => $data['username'],
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => Hash::make($data['password']),
            'group' => $data['group'],

if( $data['group'] == 'farmer'){
	$farmer = Farmer::make([
				'user_id' => $user->id,

	$buyer = Buyer::make([
			'user_id' => $user->id,
return $user;
Last updated 4 years ago.

Sign in to participate in this thread!


Your banner here too?

Heru Gunawan bnhr Joined 4 Jul 2019


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.