I have a table tasks
and users
that have tasks_ids
from the tasks
table. I would like to show only the tasks data that users have based on his tasks_ids
. Please see illustration below.
tasks
table
---------------
-- id | name --
-- 1 | task1 --
-- 2 | task2 --
-- 3 | task3 --
---------------
users
table
----------------------------
-- id | name | tasks_ids --
-- 1 | Ryan | 1 --
-- 2 | Joe | 1, 2 --
-- 3 | Mark | 1, 2, 3 --
----------------------------
Below is my code but it only shows if user has only 1 task.
<table>
<tr>
<td>Task Name</td>
</tr>
@foreach($tasks as $task)
@if($task->id == Auth::user()->tasks_id)
<tr>
<td>{{$task->name}}</td>
</tr>
@endif
@endforeach
</table>
If I logged in as Joe the excepted output should be:
---------------
-- Task Name --
-- task1 --
-- task2 --
---------------