-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating a Product Category #21
Comments
Hello! Your last line of code should look like this: $product->categories()->sync($category); or like this, if you want to leave previously added categories untouched: $product->categories()->attach($category); |
Hello @Dartui However, I have tried this and I am getting this error:
Do you have any suggestions please? |
Column for category name is $category = ProductCategory::create([
'name' => 'Test'
]); Also you should set category slug name while creating new category: $category = ProductCategory::create([
'name' => 'Test',
'slug' => 'test',
]); |
@Dartui Thank you for your reply, again I have tried this and I am getting the same error:
I definitely think I am missing something somewhere. A really silly question, but do I need to publish the migrations from Thank you so much for your help! So sorry! |
[SOLVED] Hello I am facing a similar issue. I am trying to create a product with an associated image, but I couldn't. This is the code $data = request()->validate([
but I couldn't associate the image Does anyone have an idea of how to face this? |
How can I detach the category from the product? |
Hello,
I am trying to create a product with a product category and thumbnail (not worked on this yet).
I am hoping you can help. How would you recommend doing this please?
How can I create a product and attach a category to it, please?
The text was updated successfully, but these errors were encountered: