Ejemplo n.º 1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     School::truncate();
     School::create(['name' => 'Boston']);
     School::create(['name' => 'Chicago']);
     School::create(['name' => 'NYC']);
     School::create(['name' => 'DC']);
     School::create(['name' => 'Los Angeles']);
 }
Ejemplo n.º 2
0
 public function addSchool($school_id)
 {
     if (!$school_id) {
         throw new \Exception('No school id provided');
     }
     $school = School::find($school_id);
     if (!$school) {
         throw new \Exception('School does not exist. Could not find school with that id.');
     }
     if (DB::table('school_student')->where('student_id', $this->id)->where('school_id', $school_id)->first()) {
         throw new \Exception('School has already been linked to student. Cannot be duplicated.');
     }
     DB::table('school_student')->insert(['student_id' => $this->id, 'school_id' => $school_id, 'created_at' => Carbon::now()->toDateTimeString(), 'updated_at' => Carbon::now()->toDateTimeString()]);
     $this->schools = DB::table('school_student')->where('student_id', $this->id)->lists('school_id');
     return $this;
 }
Ejemplo n.º 3
0
 public function studentsWithSummaries($school_id)
 {
     return Response::json(\Tsny\Models\School::find($school_id)->studentsWithSummary());
 }