tmp: pc change
This commit is contained in:
@@ -12,18 +12,31 @@ class GamePolicy
|
||||
*/
|
||||
public function viewAny(User $user): bool
|
||||
{
|
||||
if ($user->type === 'A' || $user->blocked === 1 ) {
|
||||
return true;
|
||||
if ($user->blocked === 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
/**2
|
||||
* Determine whether the user can view the model.
|
||||
*/
|
||||
public function view(User $user, Game $game): bool
|
||||
{
|
||||
if ($user->type === "A") {
|
||||
return true;
|
||||
}
|
||||
if ($user->blocked === 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
$game->player1_user_id === $user->id ||
|
||||
$game->player2_user_id === $user->id
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -32,7 +45,7 @@ class GamePolicy
|
||||
*/
|
||||
public function create(User $user): bool
|
||||
{
|
||||
if ($user->type === 'A' || $user->blocked === 1) {
|
||||
if ($user->type === "A" || $user->blocked === 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -41,11 +54,14 @@ class GamePolicy
|
||||
|
||||
public function join(User $user, Game $game): bool
|
||||
{
|
||||
if ($user->type === 'A' || $user->blocked === 1) {
|
||||
if ($user->type === "A" || $user->blocked === 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($game->status !== 'waiting' || $game->player1_user_id === $user->id) {
|
||||
if (
|
||||
$game->status !== "waiting" ||
|
||||
$game->player1_user_id === $user->id
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -54,12 +70,12 @@ class GamePolicy
|
||||
|
||||
public function resign(User $user, Game $game): bool
|
||||
{
|
||||
if ($user->type === 'A' || $user->blocked === 1) {
|
||||
if ($user->type === "A" || $user->blocked === 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
$game->status !== 'ongoing' ||
|
||||
$game->status !== "ongoing" ||
|
||||
($game->player1_user_id !== $user->id &&
|
||||
$game->player2_user_id !== $user->id)
|
||||
) {
|
||||
@@ -74,9 +90,19 @@ class GamePolicy
|
||||
*/
|
||||
public function update(User $user, Game $game): bool
|
||||
{
|
||||
if ($user->type === 'A' || $user->blocked === 1) {
|
||||
if ($user->type === "A" || $user->blocked === 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
$game->status !== "ongoing" ||
|
||||
($game->player1_user_id !== $user->id &&
|
||||
$game->player2_user_id !== $user->id)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user