table deleting
This commit is contained in:
@@ -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
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user