public function test_index_returns_schedules_by_get() { DB::statement('SET FOREIGN_KEY_CHECKS=0;'); Schedule::where('id', '>=', 1)->delete(); DB::statement('SET FOREIGN_KEY_CHECKS=1;'); $schedules = factory(Schedule::class, 3)->create(); $this->get('api/v1/schedule'); $this->seeStatusCode(200); foreach ($schedules as $schedule) { $this->seeJson(['name' => $schedule->name]); } }
/** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { $id = $this->route('schedule'); return Schedule::where('id', $id)->exists(); }