Skip to content

Instantly share code, notes, and snippets.

@adilshahzad
Created November 18, 2015 09:34
Show Gist options
  • Save adilshahzad/5635c466756c926d1105 to your computer and use it in GitHub Desktop.
Save adilshahzad/5635c466756c926d1105 to your computer and use it in GitHub Desktop.
/**
* Add a new Task
*/
Route::post('/task', function (Request $request){
$validator = Validator::make($request->all(), [
'name' => 'required|max:255',
]);
if ($validator->fails()) {
return redirect('/')
->withInput()
->withErrors($validator);
}
// Create The 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