Support the ongoing development of Laravel.io →
Eloquent
Last updated 2 years ago.
0

If I understand correctly, what you would probably want instead of a category column in your posts table is a 3rd table that links a post id to a category id. Call it something like "post_categories"

| id | post_id | category_id |
|----|---------|-------------|
| 1  | 23      | 15          |
| 2  | 23      | 11          |

Then you can use Eloquent to link the items together (check out the Many to Many relationship):

http://laravel.com/docs/5.0/eloquent#relationships

Having the cat id's as a string in your post table is going to be a nightmare to manage

Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

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.