Пример #1
0
 /**
  * @param \HorseStories\Models\Horses\Horse $horse
  * @param \HorseStories\Models\Horses\Horse $family
  * @param $type
  */
 private function createPedigree(Horse $horse, Horse $family, $type)
 {
     $pedigree = new Pedigree();
     $pedigree->horse_id = $horse->id;
     $pedigree->type = $type;
     $pedigree->family_id = $family->id;
     $pedigree->save();
 }
Пример #2
0
 /**
  * @param \HorseStories\Models\Pedigrees\Pedigree $pedigree
  * @param array $values
  */
 public function update(Pedigree $pedigree, $values)
 {
     $pedigree->type = $values['type'];
     $pedigree->family_name = $values['name'];
     $pedigree->family_life_number = $values['life_number'];
     $pedigree->color = $values['color'];
     $pedigree->breed = $values['breed'];
     $pedigree->height = $values['height'];
     if ($values['date_of_birth']) {
         $pedigree->date_of_birth = new DateTime($values['date_of_birth']);
     }
     if ($values['date_of_death']) {
         $pedigree->date_of_death = new DateTime($values['date_of_death']);
     }
     $pedigree->save();
 }
 /**
  * @param \HorseStories\Models\Horses\Horse $horse
  * @param int $type
  * @return \HorseStories\Models\Pedigrees\Pedigree|null
  */
 public function findExistingPedigree(Horse $horse, $type)
 {
     return $this->pedigree->where('horse_id', $horse->id)->where('type', $type)->first();
 }