Exemple #1
0
 public function action_unflag($id)
 {
     if (Auth::check() && Session::has('id')) {
         if (Session::get('admin') == 1) {
             $flags = Flag::all();
             foreach ($flags as $flag) {
                 if ($flag->listing_id == $id) {
                     $flag->delete();
                 }
             }
             return Redirect::to('/account/flaggedListings');
         } else {
             return Redirect::to('/');
         }
     } else {
         return Redirect::to('/');
     }
 }
Exemple #2
0
 public function action_flaggedlistings()
 {
     if (Auth::check()) {
         if (Session::has('id')) {
             if (Session::get('admin') == 1) {
                 $flags = Flag::all();
                 $listings = array();
                 foreach ($flags as $flag) {
                     if (array_key_exists($flag->listing_id, $listings)) {
                         $listings[$flag->listing_id]->flags += 1;
                     } else {
                         $listing = Listing::find($flag->listing_id);
                         $listing->flags = 1;
                         $listing->location = $listing->location()->first();
                         $listing->category = Categorie::find($listing->category_id)->title;
                         $listings[$listing->id] = $listing;
                     }
                 }
                 $view = View::make('account.flagged_listings.index')->with('title', 'Flagged Listings')->with('listings', $listings);
                 return $view;
             } else {
                 Redirect::to('/account/mylistings');
             }
         }
     }
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function getFlags()
 {
     return Response::json(array('flags' => Flag::all()));
 }