add backWithErrors() to controller

pull/26/head
Ondřej Hruška 7 years ago
parent b9ccdb6f27
commit 75afc67f31
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 5
      app/Http/Controllers/Controller.php
  2. 7
      app/Http/Controllers/TableController.php

@ -10,4 +10,9 @@ use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
protected function backWithErrors($errors)
{
return back()->withInput()->withErrors($errors);
}
}

@ -46,14 +46,17 @@ class TableController extends Controller
// Check if table name is unique for user
$name = $request->get('name');
if ($u->tables()->where('name', $name)->exists()) {
return back()->withErrors([
'title' => "A table called \"$name\" already exists in your account.",
return $this->backWithErrors([
'name' => "A table called \"$name\" already exists in your account.",
]);
}
// Parse and validate the columns specification
// Now we create rows, a revision pointing to them, and the table using it.
return "Ok.";
}
}

Loading…
Cancel
Save