lundi 21 mars 2016

Laravel - Query articles of a top category

So i have categories, as an example, like this:

News (top category)

Sports (sub category)
World (sub category)
Local (sub category)
etc.

The articles all belong to some of the SUB CATEGORIES (but dont have a record of belonging to the top category in the pivot).

article_id 23 -> category_id 8 (its a many to many, with a pivot table)

The articles also have published_at, status, hits fields.

Now I need to:

get Articles
that belong to any of the sub categories of the Top News category,
where('status', 1),
where('published_at', '<=', Carbon::now()),
orderBy('published_at', 'desc'),

I not sure if I am clear enough, i hope its enough.

Any suggestions?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire