first commit
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (8.3) (push) Has been cancelled
tests / ci (8.4) (push) Has been cancelled
tests / ci (8.5) (push) Has been cancelled

This commit is contained in:
brusnitsyn
2026-04-06 00:06:00 +09:00
commit fb2e6c58e3
409 changed files with 42953 additions and 0 deletions

View File

@@ -0,0 +1,90 @@
<?php
namespace App\Policies;
use App\Enums\TeamPermission;
use App\Models\Team;
use App\Models\User;
class TeamPolicy
{
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return true;
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, Team $team): bool
{
return $user->belongsToTeam($team);
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return true;
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, Team $team): bool
{
return $user->hasTeamPermission($team, TeamPermission::UpdateTeam);
}
/**
* Determine whether the user can add a member to the team.
*/
public function addMember(User $user, Team $team): bool
{
return $user->hasTeamPermission($team, TeamPermission::AddMember);
}
/**
* Determine whether the user can update a member's role in the team.
*/
public function updateMember(User $user, Team $team): bool
{
return $user->hasTeamPermission($team, TeamPermission::UpdateMember);
}
/**
* Determine whether the user can remove a member from the team.
*/
public function removeMember(User $user, Team $team): bool
{
return $user->hasTeamPermission($team, TeamPermission::RemoveMember);
}
/**
* Determine whether the user can invite members to the team.
*/
public function inviteMember(User $user, Team $team): bool
{
return $user->hasTeamPermission($team, TeamPermission::CreateInvitation);
}
/**
* Determine whether the user can cancel invitations.
*/
public function cancelInvitation(User $user, Team $team): bool
{
return $user->hasTeamPermission($team, TeamPermission::CancelInvitation);
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, Team $team): bool
{
return ! $team->is_personal && $user->hasTeamPermission($team, TeamPermission::DeleteTeam);
}
}