Inheritance: extends Domain\BaseModel
Ejemplo n.º 1
0
 /**
  * Associate lessons.
  * @param  Matter $matter
  * @param  array     $lessons
  */
 public function associateLessons(Matter $matter, array $lessons)
 {
     $ids = [];
     foreach ($lessons['lessons'] as $lesson) {
         $ids[] = $lesson['id'];
     }
     $matter->lessons()->sync($ids);
 }
Ejemplo n.º 2
0
 public function test_index_returns_matters_by_get()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     Matter::where('id', '>=', 1)->delete();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     $matters = factory(Matter::class, 3)->create();
     $this->get('api/v1/matter');
     $this->seeStatusCode(200);
     foreach ($matters as $matter) {
         $this->seeJson(['name' => $matter->name]);
     }
 }
Ejemplo n.º 3
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;');
 }
Ejemplo n.º 4
0
 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     $id = $this->route('matter');
     return Matter::where('id', $id)->exists();
 }
 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     return Matter::where('id', $this->route('matter_id'))->exists();
 }