Skip to content

Commit

Permalink
fix: task policy
Browse files Browse the repository at this point in the history
  • Loading branch information
hekmatinasser committed Feb 22, 2024
1 parent 7ea194b commit c915a87
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/Policies/TaskPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function create(User $user): bool
*/
public function update(User $user, Task $task): bool
{
return $user->id == $task->user_id;
return $user->id == $task->user_id && $task->completed_at == null;
}

/**
Expand All @@ -47,4 +47,12 @@ public function delete(User $user, Task $task): bool
{
return $user->id == $task->user_id;
}

/**
* Determine whether the user can delete the model.
*/
public function complete(User $user, Task $task): bool
{
return $user->id == $task->user_id && $task->completed_at == null;
}
}

0 comments on commit c915a87

Please sign in to comment.