Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use custom TeamInvitation model in TeamInvitationController #897

Merged
merged 1 commit into from
Oct 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions src/Http/Controllers/TeamInvitationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,23 @@
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Gate;
use Laravel\Jetstream\Contracts\AddsTeamMembers;
use Laravel\Jetstream\TeamInvitation;
use Laravel\Jetstream\Jetstream;

class TeamInvitationController extends Controller
{
/**
* Accept a team invitation.
*
* @param \Illuminate\Http\Request $request
* @param \Laravel\Jetstream\TeamInvitation $invitation
* @param int $invitationId
* @return \Illuminate\Http\RedirectResponse
*/
public function accept(Request $request, TeamInvitation $invitation)
public function accept(Request $request, $invitationId)
{
$model = Jetstream::teamInvitationModel();

$invitation = $model::whereKey($invitationId)->firstOrFail();

app(AddsTeamMembers::class)->add(
$invitation->team->owner,
$invitation->team,
Expand All @@ -38,11 +42,15 @@ public function accept(Request $request, TeamInvitation $invitation)
* Cancel the given team invitation.
*
* @param \Illuminate\Http\Request $request
* @param \Laravel\Jetstream\TeamInvitation $invitation
* @param int $invitationId
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy(Request $request, TeamInvitation $invitation)
public function destroy(Request $request, $invitationId)
{
$model = Jetstream::teamInvitationModel();

$invitation = $model::whereKey($invitationId)->firstOrFail();

if (! Gate::forUser($request->user())->check('removeTeamMember', $invitation->team)) {
throw new AuthorizationException;
}
Expand Down