public function gallary()
 {
     $album_id = Input::get("album_id");
     $user_id = Input::get("user_id");
     $photos = Picture::where("album_id", "=", $album_id)->get();
     return View::make('userCenter.gallary')->with(array("photos" => $photos, "user_id" => $user_id, "album_id" => $album_id));
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     // $user = User::findOrFail($id);
     $ued = Sentry::getUser()->id;
     $user = $this->user->find($id);
     //$products =  DB::table('products')->where('user_id',$ued)->get();
     $products = Product::where('user_id', $ued)->paginate(10);
     //$picture = DB::table('pictures')->where('user_id',$ued)->find(1);
     $image = Picture::where('user_id', $ued)->orderBy('id', 'desc')->get()->take(1);
     // $images = $user->pictures->find(1);
     return View::make('protected.standardUser.edit')->withUser($user)->with('products', $products)->with('image', $image);
 }
 public function getView($id)
 {
     $album = Album::where('id', '=', $id)->first();
     $pictures = Picture::where('album_id', '=', $id)->orderBy('votes', 'desc')->paginate(12);
     // layouts variables
     $this->layout->title = $album->name . ' | Нещо Шантаво';
     $this->layout->canonical = 'https://neshto.shantavo.com/album/' . $id;
     $this->layout->robots = 'index,follow,noodp,noydir';
     $this->layout->description = 'Това е албум';
     $this->layout->keywords = 'начало, нещо шантаво, team navy pier';
     // nesting the view into the layout
     $this->layout->nest('content', 'album.view', array('album' => $album, 'pictures' => $pictures));
 }
 public function postVote()
 {
     $isVoted = false;
     $picture = Picture::where('id', '=', Input::get('id'))->first();
     if (Auth::check()) {
         foreach ($picture->voted as $vote) {
             if ($vote->user->id == Auth::user()->id) {
                 $isVoted = true;
             }
         }
         if (!$isVoted) {
             Picture::where('id', '=', Input::get('id'))->increment('votes', 1);
             Vote::insert(array('picture_id' => $picture->id, 'user_id' => Auth::user()->id));
             $picture = Picture::where('id', '=', Input::get('id'))->first();
             return intval($picture->votes);
         }
     }
     return false;
 }
Exemple #5
0
 public static function getByRefId($refId, $type)
 {
     $images = Picture::where('ref_id', $refId)->where('image_type', $type)->get();
     return $images;
 }
 /**
  * Action: Delete resource images
  * @param  int $id post ID
  * @return response
  */
 public function deleteUpload($id)
 {
     // Allow only pictures of the current article being deleted
     $filename = Picture::where('id', $id)->where('user_id', Auth::user()->id)->first();
     $oldImage = $filename->filename;
     if (is_null($filename)) {
         return Redirect::back()->with('error', '没有找到对应的图片');
     } elseif ($filename->delete()) {
         // Delete images
         File::delete(public_path('uploads/articles/' . $oldImage));
         return Redirect::back()->with('success', '图片删除成功。');
     } else {
         return Redirect::back()->with('warning', '图片删除失败。');
     }
 }