-
-
Save jeffandersen/386372f43a2914ff522865a9e63f4611 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
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