/**
  * @param \HorseStories\Models\Palmares\Palmares $palmares
  */
 public function delete(Palmares $palmares)
 {
     $status = $this->statuses->findById($palmares->status->id);
     $status->delete();
     $event = $this->events->findById($palmares->event->id);
     $event->delete();
     $palmares->delete();
 }
 /**
  * @param \HorseStories\Models\Palmares\Palmares $palmares
  * @param array $values
  */
 public function update(Palmares $palmares, $values)
 {
     $palmares->discipline = $values['discipline'];
     $palmares->level = $values['level'];
     $palmares->ranking = $values['ranking'];
     $palmares->date = DateTime::createFromFormat('d/m/Y', $values['date']);
     $palmares->event->name = $values['event_name'];
     $palmares->save();
 }
 /**
  * @param \HorseStories\Models\Horses\Horse $horse
  * @param array $values
  */
 public function create(Horse $horse, array $values)
 {
     $values = $this->statusCreator->createForPalmares($horse, $values);
     $event = $this->eventCreator->create($values);
     $palmares = new Palmares();
     $palmares->horse_id = $horse->id;
     $palmares->discipline = $values['discipline'];
     $palmares->level = $values['level'];
     $palmares->ranking = $values['ranking'];
     $palmares->date = DateTime::createFromFormat('d/m/Y', $values['date']);
     $palmares->status_id = $values['status']->id;
     $palmares->event_id = $event->id;
     $palmares->save();
 }
 /**
  * @param \HorseStories\Models\Horses\Horse $horse
  * @return \HorseStories\Models\Palmares\Palmares[]
  */
 public function getPalmaresForHorse(Horse $horse)
 {
     return $this->palmares->with('event')->where('horse_id', $horse->id)->orderBy('date', 'desc')->get();
 }