/** * Run the database seeds. * * @return void */ public function run() { //create lab submissions for ($i = 1; $i <= 10; $i++) { App\Submission::create(['name' => 'Lab ' . $i, 'due_date' => Carbon\Carbon::createFromDate(2016, rand(8, 12), rand(1, 30)), 'total' => rand(10, 30), 'evaluation_id' => 3, 'active' => true, 'bonus' => false]); } }
<?php /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ Route::get('/{form}', function ($form) { return view($form); }); Route::post('/{form}', function ($form) { $json = json_encode(Input::all()); App\Submission::create(compact('form', 'json')); return view('thanks'); }); Route::get('/{form}/report/{pass}', function ($form, $pass) { if ($pass == env('FORMS_PASSWORD')) { $submissions = App\Submission::where(compact('form'))->get(); $results = []; foreach ($submissions as $submission) { array_push($results, json_decode($submission->json)); } return response()->json($results); } });