diff options
author | Marvin Borner | 2018-12-05 17:31:36 +0100 |
---|---|---|
committer | Marvin Borner | 2018-12-05 17:31:36 +0100 |
commit | 9d1a810fa983a045294e6d0b8ad761f5dbfb8939 (patch) | |
tree | 46c8796cd6747b3746478b4e3b8b29226f588ddb /routes/web.php |
Initial commit (actually already finished)
Diffstat (limited to 'routes/web.php')
-rw-r--r-- | routes/web.php | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/routes/web.php b/routes/web.php new file mode 100644 index 0000000..67ff691 --- /dev/null +++ b/routes/web.php @@ -0,0 +1,48 @@ +<?php + +/* +|-------------------------------------------------------------------------- +| Web Routes +|-------------------------------------------------------------------------- +| +| Here is where you can register web routes for your application. These +| routes are loaded by the RouteServiceProvider within a group which +| contains the "web" middleware group. Now create something great! +| +*/ + +use Illuminate\Http\Request; + +/** + * Display all quotes + */ +Route::get('/', function () { + $quotes = \App\Quote::orderBy('created_at', 'asc')->get(); + + return view('quotes', [ + 'quotes' => $quotes + ]); +}); + +/** + * Add a new quote + */ +Route::post('/quote', function (Request $request) { + $validator = Validator::make($request->all(), [ + 'quote' => 'required|max:1023', + 'quotist' => 'required|max:63', + ]); + + if ($validator->fails()) { + return redirect('/') + ->withInput() + ->withErrors($validator); + } + + $quote = new \App\Quote; + $quote->quote = $request->quote; + $quote->quotist = $request->quotist; + $quote->save(); + + //return redirect('/'); +}); |