table deleting

This commit is contained in:
2018-07-29 19:11:55 +02:00
parent 8ff10904ce
commit 3bf9b68503
9 changed files with 67 additions and 5 deletions
+16
View File
@@ -43,6 +43,22 @@ class TableController extends Controller
]);
}
public function delete(Request $request, User $user, string $table)
{
/** @var Table $tableModel */
$tableModel = $user->tables()->where('name', $table)->first();
if ($tableModel === null) abort(404, "No such table.");
$this->authorize('delete', $tableModel);
if ($request->get('table-name', null) !== $table) {
return $this->backWithErrors(['table-name' => 'Fill table name']);
}
$tableModel->delete();
return redirect(route('profile.view', $user->name));
}
/**
* SHow a form for creating a new table
*
+1 -1
View File
@@ -28,7 +28,7 @@ class Kernel extends HttpKernel
*/
protected $middlewareGroups = [
'web' => [
'throttle:60,15', // try to prevent people refresh-spamming the server to game table visit counts
'throttle:120,15', // try to prevent people refresh-spamming the server to game table visit counts
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,