/**
  * @param int $id
  * @return \Illuminate\Http\RedirectResponse
  */
 public function destroy($id)
 {
     $horse = $this->horseRepository->findById($id);
     Auth::user()->unFollow($horse);
     Session::put('succes', 'You are no longer following ' . $horse->name);
     return Redirect::back();
 }
 /**
  * @param \HorseStories\Models\Horses\Horse $horse
  * @param array $values
  * @return \HorseStories\Models\Horses\Horse|null
  */
 private function createFamilyConnection(Horse $horse, $values)
 {
     if ($values['life_number'] && ($family = $this->horses->findByLifeNumber($values['life_number']))) {
         $family = $family;
     } else {
         $values['gender'] = $this->pedigreeConnector->getGender($values['type']);
         $family = $this->horseCreator->create($values, true);
     }
     $values['type'] = $this->pedigreeConnector->getConnection($horse, $values['type']);
     $this->createPedigree($family, $horse, $values['type']);
     return $family;
 }
 /**
  * @return \Illuminate\View\View
  */
 public function home()
 {
     if (Auth::check()) {
         $horses = $this->horses->findHorsesForSelect(Auth::user());
         if (count($horses)) {
             $statuses = $this->statuses->getFeedForUser(Auth::user());
             $likes = DB::table('likes')->whereUserId(Auth::user()->id)->lists('status_id');
         } else {
             $statuses = [];
         }
     }
     return view('pages.home', compact('horses', 'statuses', 'likes'));
 }
Esempio n. 4
0
 /**
  * @param array $data
  * @return \HorseStories\Models\Statuses\Status
  */
 public function create($data = [])
 {
     $status = new Status();
     $status->body = $data['status'];
     $status->horse_id = $data['horse'];
     $status->save();
     if (array_key_exists('picture', $data)) {
         $horse = $this->horses->findById($data['horse']);
         $picture = $this->uploader->uploadPicture($data['picture'], $horse);
         $status->setPicture($picture);
     }
     return $status;
 }
 /**
  * @param $horseSlug
  * @return \Illuminate\Database\Eloquent\Model
  */
 private function initHorse($horseSlug)
 {
     $horse = $this->horses->findBySlug($horseSlug);
     if ($this->userHasPermission($horse)) {
         return $horse;
     }
     abort(403);
 }
 /**
  * @param int $horseId
  * @return \HorseStories\Models\Horses\Horse
  */
 private function initHorse($horseId)
 {
     $horse = $this->horses->findBySlug($horseId);
     if ($horse->owner()->first()->id !== Auth::user()->id) {
         abort(403);
     }
     return $horse;
 }
 /**
  * @param string horseSlug
  * @return \HorseStories\Models\Horses\Horse
  */
 private function initHorse($horseSlug)
 {
     $horse = $this->horses->findBySlug($horseSlug);
     return $horse;
 }
 public function index()
 {
     $horses = $this->horses->search(Input::get('search'));
     $profiles = $this->users->search(Input::get('search'));
     return view('searches.index', compact('horses', 'profiles'));
 }