Skip to content

Commit

Permalink
Add ability to delete one player
Browse files Browse the repository at this point in the history
  • Loading branch information
Xinecraft committed Mar 14, 2024
1 parent 08baecc commit 65d25a9
Show file tree
Hide file tree
Showing 167 changed files with 1,323 additions and 1,258 deletions.
25 changes: 25 additions & 0 deletions app/Http/Controllers/Admin/PlayerController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\MinecraftPlayerSession;
use App\Models\Player;
use DB;

class PlayerController extends Controller
{
public function destroy(Player $player)
{
$this->authorize('destroy', $player);

DB::transaction(function () use ($player) {
MinecraftPlayerSession::where('player_uuid', $player->uuid)->delete();
$player->minecraftPlayers()->delete();
$player->delete();
});

return redirect()->back()
->with(['toast' => ['type' => 'success', 'title' => __('Player Deleted!'), 'body' => __('All intel data related to the player is deleted.')]]);
}
}
5 changes: 5 additions & 0 deletions app/Policies/PlayerPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,9 @@ public function changeSkin(User $user, Player $player)

return $user->players()->where('players.id', $player->id)->exists();
}

public function destroy(User $user, Player $player)
{
return $user->can('delete players');
}
}
2 changes: 2 additions & 0 deletions database/seeders/PermissionSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,7 @@ public function run()
Permission::findOrCreate('view pulse_admin_dashboard');

Permission::findOrCreate('change any_player_skin');

Permission::findOrCreate('delete players');
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 65d25a9

Please sign in to comment.