Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

there is no need to save the ids in both collections for a belongsToMany relation, or am I wrong? #2040

Copy link
Copy link
Open
@elfeffe

Description

@elfeffe
Issue body actions

I'm doing

$product = Product::where('sku', '0713XX3FF1')->where('store_id', 1)->first();
$category = Category::where('entity_id', 158)->first();
$product->categories()->attach( $category );

And this is saving the related ids on both collections, so if I have 1 category, with 10000 products, the category has an array of 10000 products inside.
What's the reason?
Saving the category inside the product will do the job, or I'm losing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.