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
*