Support the ongoing development of Laravel.io →
Views Database Packages
Last updated 2 years ago.
0

You can have multi categories by setting Eloquent relationship to Many To Many

Last updated 8 years ago.
0

yes i have made many to many relationship each other but i wanted show when i edit the post into checked related categories. when i inserting the post.

0

how to use pivot table data related two tables like posts and categories.

post-model.php

public function categories () { return $this->belongsToMany('App\Category', 'category_post', 'post_id', 'category_id'); } related above post. same as it category model, now what next.

  1. data inserting or editing it is smoothly done.
  2. when i am editing my post so categories checkbox are already checked show but checkbox are unchecked show.
  3. how can i solved this problem.
Last updated 8 years ago.
0

fanibig said:

how to use pivot table data related two tables like posts and categories.

post-model.php

public function categories () { return $this->belongsToMany('App\Category', 'category_post', 'post_id', 'category_id'); } related above post. same as it category model, now what next.

  1. data inserting or editing it is smoothly done.
  2. when i am editing my post so categories checkbox are already checked show but checkbox are unchecked show.
  3. how can i solved this problem.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

fanibig fanibig Joined 31 Oct 2016

Moderators

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

Your logo here?

Laravel.io

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

© 2024 Laravel.io - All rights reserved.