Skip to content

Instantly share code, notes, and snippets.

@jeffandersen
Created December 13, 2018 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffandersen/386372f43a2914ff522865a9e63f4611 to your computer and use it in GitHub Desktop.
Save jeffandersen/386372f43a2914ff522865a9e63f4611 to your computer and use it in GitHub Desktop.
// ...
use Illuminate\Http\Request;
// Show Tasks
// ...
// Add New Task
Route::post('/task', function (Request $request) {
// Validate input
$validator = Validator::make($request->all(), [
'name' => 'required|max:255',
]);
if ($validator->fails()) {
return redirect('/')
->withInput()
->withErrors($validator);
}
// Create task
$task = new Task;
$task->name = $request->name;
$task->save();
return redirect('/');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment