@narares can you use 3 ` before and after your code so that your code will be readable.
Nov 13, 2020
3
Level 1
How to custom the RegisterController to save multiple data when user selected
Dear all,
I am a newbie in Laravel and I need your help.
I'm using the Laravel 7. I have 3 tables in my database.
- User to save the registered users
- Categories to show in the front-end that I provided for them to choose (multiple)
- Vendor_Cat that I collecting the user_id and category_id after the user registered
Here are my Models
public function users(){
return $this->BelongsToMany(User::class);
}
public function categories(){
return $this->BelongsToMany(Categories::class);
}
And this is the Laravel RegisterController
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
'tel' => $data['tel'],
'lineid'=> isset($data['lineid']) ? $data['lineid'] : null,
]);
If I want to save the category Ids that I use @foreach to show in the Register Form after the users selected. What should I do?
Here is the explanation image https://ibb.co/vQpfxxH
p.s. sorry for my bad English.
Level 70
6 likes
Please or to participate in this conversation.