Skip to content

Commit

Permalink
update policy equality (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
joseederangojr authored Oct 30, 2023
2 parents 41f2966 + f2635a7 commit c7a9638
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
14 changes: 7 additions & 7 deletions app/Policies/SpacePolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,54 +12,54 @@ class SpacePolicy
*/
public function viewAny(?User $user): bool
{
return $user !== null;
return $user != null;
}

/**
* Determine whether the user can view the model.
*/
public function view(User $user, Space $space): bool
{
return $space->created_by_id === $user->id;
return $space->created_by_id == $user->id;
}

/**
* Determine whether the user can create models.
*/
public function create(?User $user): bool
{
return $user !== null;
return $user != null;
}

/**
* Determine whether the user can update the model.
*/
public function update(User $user, Space $space): bool
{
return $user->id === $space->created_by_id;
return $user->id == $space->created_by_id;
}

/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Space $space): bool
{
return $space->created_by_id === $user->id;
return $space->created_by_id == $user->id;
}

/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Space $space): bool
{
return $space->created_by_id === $user->id;
return $space->created_by_id == $user->id;
}

/**
* Determine whether the user can permanently delete the model.
*/
public function forceDelete(User $user, Space $space): bool
{
return $space->created_by_id === $user->id;
return $space->created_by_id == $user->id;
}
}
18 changes: 9 additions & 9 deletions app/Policies/TaskPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,49 +13,49 @@ class TaskPolicy
*/
public function viewAny(User $user, Space $space): bool
{
return $user->id === $space->created_by_id;
return $user->id == $space->created_by_id;
}

/**
* Determine whether the user can view the model.
*/
public function view(User $user, Task $task, Space $space): bool
{
return $user->id === $space->created_by_id && $task->space_id === $space->id;
return $user->id == $space->created_by_id && $task->space_id == $space->id;
}

/**
* Determine whether the user can create models.
*/
public function create(User $user, Space $space): bool
{
return $user->id === $space->created_by_id;
return $user->id == $space->created_by_id;
}

/**
* Determine whether the user can update the model.
*/
public function update(User $user, Task $task, Space $space): bool
{
return $task->space_id === $space->id &&
($user->id === $task->created_by_id || $user->id === $task->assigned_to_id);
return $task->space_id == $space->id &&
($user->id == $task->created_by_id || $user->id == $task->assigned_to_id);
}

/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Task $task, Space $space): bool
{
return $task->space_id === $space->id &&
($user->id === $task->created_by_id || $user->id === $task->assigned_to_id);
return $task->space_id == $space->id &&
($user->id == $task->created_by_id || $user->id == $task->assigned_to_id);
}

/**
* Determine whether the user can restore the model.
*/
public function restore(User $user, Task $task, Space $space): bool
{
return $task->space_id === $space->id &&
($user->id === $task->created_by_id || $user->id === $task->assigned_to_id);
return $task->space_id == $space->id &&
($user->id == $task->created_by_id || $user->id == $task->assigned_to_id);
}
}

0 comments on commit c7a9638

Please sign in to comment.