/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $r = new \App\Restriction();
     $r->display_name = "Nut Allergy";
     $r->save();
     $r = new \App\Restriction();
     $r->display_name = "Seafood Allergy";
     $r->save();
     $r = new \App\Restriction();
     $r->display_name = "Dairy Allergy";
     $r->save();
     $r = new \App\Restriction();
     $r->display_name = "Lactose Intolerance";
     $r->save();
     $r = new \App\Restriction();
     $r->display_name = "Chocolate Allergy";
     $r->save();
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $seafoods = ['fish', 'anchovy', 'basa', 'bass', 'cod', 'bream', 'brill', 'eel', 'herring', 'pike', 'pollock', 'salmon', 'sardine', 'shark', 'snapper', 'tilapia', 'trout', 'tuna', 'whiting', 'caviar', 'crab', 'lobster', 'shrimp', 'mollusc', 'conch', 'mussel', 'octopus', 'oyster', 'scallop', 'squid', 'sea'];
     $seaFoodsArray = array();
     //Retrieve all foods with nut in the name. Super rudimentary way to filter, but this will just show that the API works.
     foreach ($seafoods as $seafood) {
         $seaFoodsArray = array_merge($seaFoodsArray, \App\Food::GetNameSimilarTo($seafood)->lists('id')->toArray());
     }
     $seaFoodsArray = array_unique($seaFoodsArray);
     $restriction = App\Restriction::find(2);
     $restriction->restrictedFoods()->attach($seaFoodsArray);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $dairys = ['milk', 'dairy', 'yogurt', 'butter', 'cheese', 'casein', 'clabber', 'gelato', 'cream', 'custard', 'brick', 'brie', 'camembert', 'cheddar', 'chesire', 'colby', 'coldpack', 'edam', 'feta'];
     $dairysArray = array();
     //Retrieve all foods with nut in the name. Super rudimentary way to filter, but this will just show that the API works.
     foreach ($dairys as $dairy) {
         $dairysArray = array_merge($dairysArray, \App\Food::GetNameSimilarTo($dairy)->lists('id')->toArray());
     }
     $dairysArray = array_unique($dairysArray);
     $restriction = App\Restriction::find(3);
     $restriction->restrictedFoods()->attach($dairysArray);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $nuts = ['acorn', 'cashew', 'pecan', 'nut', 'almond', 'pistachio'];
     $nutFoodsArray = array();
     //Retrieve all foods with nut in the name. Super rudimentary way to filter, but this will just show that the API works.
     foreach ($nuts as $nut) {
         $nutFoodsArray = array_merge($nutFoodsArray, \App\Food::GetNameSimilarTo($nut)->lists('id')->toArray());
     }
     $nutFoodsArray = array_unique($nutFoodsArray);
     $restriction = App\Restriction::find(1);
     $restriction->restrictedFoods()->attach($nutFoodsArray);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $chocolates = ['chocolate', 'cocoa'];
     $chocolatesArray = array();
     //Retrieve all foods with nut in the name. Super rudimentary way to filter, but this will just show that the API works.
     foreach ($chocolates as $chocolate) {
         $chocolatesArray = array_merge($chocolatesArray, \App\Food::GetNameSimilarTo($chocolate)->lists('id')->toArray());
     }
     $chocolatesArray = array_unique($chocolatesArray);
     $restriction = App\Restriction::find(5);
     $restriction->restrictedFoods()->attach($chocolatesArray);
 }
 public function testRestrictions()
 {
     $user = $this->spawnUser();
     $r = App\Restriction::all()[0];
     $user->addRestriction($r);
     $this->assertEquals($user->addRestriction($r), null);
     $this->assertEquals($r->getDisplayName(), "Nut Allergy");
     //Spawns food and detaches + reattaches restriction
     $f = App\Food::GetNameSimilarTo("nuts", [])[0];
     App\Food::ObeyRestrictions($r);
     $this->assertEquals(App\Food::ObeyRestrictions($r), null);
     if ($f->isRestricted($r)) {
         $f->removeRestriction($r);
         $this->assertEquals($f->removeRestriction($r), null);
         $this->assertEquals($f->isRestricted($r), false);
     }
     $f->addRestriction($r);
     $this->assertEquals($user->canEatFood($f), false);
     $this->assertEquals($f->isRestricted($r), true);
     $sample1 = $user->getFoodSuggestion();
     $sample2 = $user->getFoodSuggestion();
     $this->assertNotEquals($sample1, $sample2);
     $this->assertEquals($user->canEatFood($sample1), true);
 }