mardi 2 mai 2017

Laravel how to get values from a table with an id from another table

i am having some trouble getting results from a query. it's the following. I have two tables, tasks and task_interactions. the table tasks stores the tasks, and the table task_interactions stores the history of the tasks, like a change of status, comments... The column task_id in the task_interactions table is the id in the table tasks. The table tasks has the following columns: id | project_id | task_type_id | related_block | created_by | assigned_to | start_date | due_date | task_priority | comments | status | created_at |updated_at The status in this table will be deleted.

The table taskinteractions has the following columns: id,task_id,status,comments,created_at

In the models i have created the following relationships:

Task Model:

public function taskinteractions()
{
    return $this->hasMany('App\Taskinteraction');
}

Taskinteraction Model:

public function tasks()
{
    return $this->belongsTo('App\Task');
}

And now the question: I want to get all the tasks assigned to the authenticated user with status (in the table taskinteractions) equal to "In Progress". I have tried a lot of different approaches with no good results. I am a newbie and so i believe that the solution might be simple, but i no idea how to do it.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire