You can have multi categories by setting Eloquent relationship to Many To Many
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.
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.
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.
- data inserting or editing it is smoothly done.
- when i am editing my post so categories checkbox are already checked show but checkbox are unchecked show.
- how can i solved this problem.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community