mercredi 18 juillet 2018

Laravel 5 - how to display data from database for a specific user from other table

i am writing to you with small problem. How can i display data from database for a specific user?

I have 2 tables: Users and Tasks. Table Users is installed from php artisan make:Auth. In Table Tasks I have user_id, and its foreign key.

In controller i have got methods:

  public function index(TaskRepository $taskRepo)
    {
        $tasks = $taskRepo->getAll();
        return view('tasks.list', [
            "taskList" => $tasks
        ]);
    }

    public function show(TaskRepository $taskRepo, $id)
    {
        $task = $taskRepo->find($id);
        return view('tasks.show', [
            "task" => $task
        ]);
    }

Can someone help me with next method getTaskByUserId, and how to display it in view?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire