mardi 30 octobre 2018

How to implement Laravel Middleware to protect task if previous is not completed

I'm building task application. It has tasks table:

tasks
--------
id
title
description

and also has user_tasks table which shows users who have completed task

user_tasks
--------
id
task_id
user_id

Task model has method which show is task completed by user

public function answered()
{
   return $this->hasOne('App\UserTask')->where('user_id', Auth::id());
}

So my goal is to make middleware which protects next task if previous isn't done for particular user. If user didn't complete task with id - 1, he can't start task with id - 2 and so one.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire