/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     DB::table('categories')->truncate();
     DB::table('products')->truncate();
     $category = new Category();
     $category->name = "Blood";
     $category->save();
     foreach (BloodGroup::all() as $bg) {
         $product = new Product();
         $product->name = $bg->name;
         $product->validity_period = 120;
         $product->category_id = $category->id;
         $product->save();
     }
     $category = new Category();
     $category->name = "General";
     $category->save();
 }
Example #2
0
 public static function getBloodGroup()
 {
     $model = new BloodGroup();
     return $model->findAll();
 }
Example #3
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $donor = Donor::find($id);
     $blood_groups = array('') + BloodGroup::all()->lists('name', 'id');
     return View::make('donors.create', array('donor' => $donor, 'blood_groups' => $blood_groups));
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = BloodGroup::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }