Exemplo n.º 1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     DB::table('locker_gewenst')->truncate();
     $aantal = Leerling::get()->count();
     //$aantal= 2;
     $lockersGewenst = factory(LockerGewenst::class, $aantal)->create();
     for ($i = 0; $i < $aantal; ++$i) {
         $lockersGewenst[$i]->leerling()->associate(Leerling::find($i + 1));
         $lockersGewenst[$i]->save();
     }
     Model::reguard();
 }
Exemplo n.º 2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     DB::table('locker_sleutel_verloren')->truncate();
     $aantal = Locker::get()->count();
     //$aantal=2;
     $sleutelsverloren = factory(LockerSleutelVerloren::class, $aantal)->create();
     $lockers = Locker::all();
     for ($i = 0; $i < $aantal; ++$i) {
         //$leerling=$lockers[$i]->leerling();
         $sleutelsverloren[$i]->locker()->associate($lockers[$i]);
         $sleutelsverloren[$i]->leerling()->associate(Leerling::find($lockers[$i]->leerling_id));
         //$sleutelsverloren[$i]->leerling()->associate($lockers[$i]->leerling());
         //if ($i==0) var_dump($lockers[$i]->leerling()->get());
         $sleutelsverloren[$i]->save();
     }
     DB::statement('SET FOREIGN_KEY_CHECKS = 1');
     Model::reguard();
 }
Exemplo n.º 3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     DB::table('locker')->truncate();
     $aantal = Leerling::get()->count();
     //$aantal= 2;
     $lockers = factory(Locker::class, $aantal)->create();
     $codes = array('A', 'B', 'C');
     $batch = floor($aantal / count($codes));
     $batcheinde = $batch;
     for ($j = 0; $j < count($codes); ++$j) {
         if ($j == count($codes) - 1) {
             $batcheinde = $aantal - (count($codes) - 1) * $batch;
         }
         for ($i = 0; $i < $batcheinde; ++$i) {
             $lockers[$j * $batch + $i]->code = $codes[$j] . sprintf('%03d', $i + 1);
             $lockers[$j * $batch + $i]->lockertype()->associate(LockerType::find(1));
             $lockers[$j * $batch + $i]->save();
         }
     }
     DB::statement('SET FOREIGN_KEY_CHECKS = 1');
     Model::reguard();
 }
Exemplo n.º 4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Leerling::destroy($id);
     return response()->json(array('success' => true));
 }