1

i have 3 tables :

  1. Table 1 courses :

    • id_cours
    • field_cours
  2. Table 2 Question :

    • id_quest
    • field_quest
    • id_cours
    • id_user
  3. Table 3 Users : -id -nom

The question is i want to Count all question just added by the user logged .

i try with this one in the Model Courses : but i want to add where id_user = id

 public function answers()
    {
        return $this->hasMany('App\QuestionUsers','idcours', 'id_cours');

    }

but this returns count of all question added by all users . Please need Help

MADI
  • 19
  • 1
  • 10
  • Possible duplicate of [Counting total posts by a user in the blade view](https://stackoverflow.com/questions/48721466/counting-total-posts-by-a-user-in-the-blade-view) – sh1hab Oct 01 '19 at 07:11

1 Answers1

0

i found solution just i call the Auth and add where


 public function answers()
    {
        return $this->hasMany('App\QuestionUsers','idcours', 'id_cours')->where('idusers',Auth::id());

    }
MADI
  • 19
  • 1
  • 10