Ejemplo n.º 1
0
 public function edit($plantID, $attributeArray)
 {
     $thePlant = Plants::find($plantID);
     $thePlant->name = $attributeArray['plant']['name'];
     $thePlant->name_latin = $attributeArray['plant']['latin'];
     $thePlant->description = $attributeArray['plant']['description'];
     $thePlant->history = $attributeArray['plant']['history'];
     $thePlant->save();
     $this->sizeHandler->edit($plantID, $attributeArray['size']);
     $this->seasonHandler->edit($plantID, $attributeArray['season']);
     $this->habitatHandler->edit($plantID, $attributeArray['habitat']);
     $this->colorHandler->edit($plantID, $attributeArray['color']);
     $this->applicationHandler->edit($plantID, $attributeArray['application']);
     /*if(!empty($attributeArray['photo']))
       for ($index = 0; $index < sizeof($attributeArray['photo']); $index++)
           $this->photoHandler->edit($plantID, $index, $attributeArray['photo'][$index]);*/
 }
 /**
  * Finds the plant from the id and all its relationships in the database
  * and passes it to the view, so the user can edit the data.
  * @return edit plant view with all the data as default from the plant
  */
 public function showEditPlant()
 {
     $plantId = Input::get('plantId');
     $thePlant = Plants::find($plantId);
     $sizeArray = $this->sizeHandler->get($plantId);
     $habitatArray = $this->habitatHandler->get($plantId);
     $seasonArray = $this->seasonHandler->get($plantId);
     $colorArray = $this->colorHandler->get($plantId);
     $photoArray = $this->photoHandler->get($plantId);
     $applicationArray = $this->applicationHandler->get($plantId);
     $data = array('plant' => $thePlant, 'seasons' => $seasonArray, 'colors' => $colorArray, 'habitats' => $habitatArray, 'sizes' => $sizeArray, 'photos' => $photoArray, 'applications' => $applicationArray);
     return View::make('editPlantView')->with('data', $data);
 }