Inheritance: extends Domain\BaseModel
 public function test_index_returns_lessons_by_get()
 {
     Lesson::where('id', '>=', 1)->delete();
     $lessons = factory(Lesson::class, 3)->create();
     $this->get('api/v1/lesson');
     $this->seeStatusCode(200);
     foreach ($lessons as $lesson) {
         $this->seeJson(['name' => $lesson->name]);
     }
 }
Esempio n. 2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     Schedule::truncate();
     Billet::truncate();
     BilletAssignor::truncate();
     Classroom::truncate();
     ClassroomMatter::truncate();
     Config::truncate();
     Employee::truncate();
     Lesson::truncate();
     Matter::truncate();
     Schedule::truncate();
     Student::truncate();
     Teacher::truncate();
     factory(BilletAssignor::class, 1)->create();
     factory(Billet::class, 5)->create();
     $allClassrooms = factory(Classroom::class, 10)->create();
     factory(ClassroomMatter::class, 10)->create();
     factory(Config::class, 10)->create();
     $employee = factory(Employee::class)->create();
     factory(Lesson::class, 40)->create();
     $matters = factory(Matter::class, 10)->create();
     factory(Schedule::class, 3)->create();
     $student = factory(Student::class)->create();
     $teacher = factory(Teacher::class)->create();
     factory(User::class, 1)->create(['username' => 'funcionario', 'password' => bcrypt('funcionario123'), 'owner_type' => Employee::class, 'owner_id' => $employee->id]);
     factory(User::class, 1)->create(['username' => 'aluno', 'password' => bcrypt('aluno123'), 'owner_type' => Student::class, 'owner_id' => $student->id]);
     factory(User::class, 1)->create(['username' => 'professor', 'password' => bcrypt('professor123'), 'owner_type' => Teacher::class, 'owner_id' => $teacher->id]);
     $classrooms = factory(Classroom::class, 3)->create(['teacher_id' => $teacher->id]);
     $classrooms->each(function ($classroom) use($student, $matters) {
         $classroom->students()->attach($student);
         $matters->random(3)->each(function ($matter) use($classroom) {
             $classroom->matters()->attach($matter);
         });
     });
     $allClassrooms->random(3)->each(function ($classroom) use($student, $matters, $teacher) {
         $classroom->teacher()->associate($teacher);
         $classroom->students()->attach($student);
         $matters->random(3)->each(function ($matter) use($classroom) {
             $classroom->matters()->attach($matter);
         });
     });
     factory(User::class, 30)->create();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
 }
Esempio n. 3
0
 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     $id = $this->route('lesson');
     return Lesson::where('id', $id)->exists();
 }