/** * Run the database seeds. * * @return void */ public function run() { App\Mission::all()->each(function ($m) { $m->attempts()->save(factory(App\Attempt::class)->make()); $m->attempts()->save(factory(App\Attempt::class)->make()); $m->attempts()->save(factory(App\Attempt::class)->make()); }); }
|-------------------------------------------------------------------------- | 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('/', 'WelcomeController@index'); Route::get('home', 'HomeController@index'); Route::get('tasks/{id}', function ($id) { return json_encode(App\Mission::find($id)); }); Route::get('tasks', function () { $fetchTasks = App\Mission::all(); $fetchedModels = array(); foreach ($fetchTasks as $model) { $fetchedModels[] = $model; } return json_encode($fetchedModels); }); Route::put('tasks/{id}', function ($id) { $task = App\Mission::find($id); $task->title = Input::get('title'); $task->complete = Input::get('complete'); $task->save(); }); Route::delete('tasks/{id}', function ($id) { App\Mission::find($id)->delete(); });