dimanche 25 décembre 2016

How to count how many articles belongs which category?

I have this relationships:

ARTICLES

 public function category()
    {
      return $this->belongsTo('App\Models\Categories');
    }

CATEGORY have translations

public function c_translations()
  {
    return $this->hasMany('App\Models\CategoryTranslations', 'category_id');
  }

In articles i have category id, also in translations i have category_id. So how can i count how many articles have each category. Any suggestion?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire