예제 #1
0
 public function getIndex(Request $request)
 {
     $data = [];
     $userControllerObj = new UserController();
     $cookie = $userControllerObj->checkCookie($request);
     $data['categories'] = Categories::getCategories();
     if ($cookie === 0) {
         return View::make('index', $data);
     } else {
         if ($cookie === -1) {
             $response = new Response('Your cookie is invalid, We have cleared it for you, Refresh to re-login to NEUP-Channel');
             return $response->withCookie('neupchan', "", -1);
         } else {
             if ($cookie->shortCookie === NULL) {
                 $shortCookie = $cookie->short_cookie;
                 $data['firstLogin'] = true;
             } else {
                 $shortCookie = $cookie->shortCookie;
                 $data['lastLoginIP'] = $cookie->last_login_ip;
             }
         }
     }
     $data['shortCookie'] = $shortCookie;
     //return View::make('index', $data)->withCookie(cookie('neupchan', $cookie, 90 * 24 * 60));
     $response = new Response(view('index', $data));
     if (isset($data['firstLogin'])) {
         return $response->withCookie('neupchan', $cookie, 90 * 24 * 60);
     } else {
         return $response;
     }
 }
 /**
  * Prépare l'insertion d'un item dans la BDD
  *
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function add(Request $request)
 {
     $item_id = null;
     $this->validate($request, ['name' => 'required|max:200', 'category' => 'required|in:' . implode(',', array_keys(Categories::getCategories())), 'photo' => 'image', 'price' => 'required|numeric|min:0', 'date_start' => 'required|date|after:' . date('Y-m-d'), 'date_end' => 'required|date|after:date_start', 'description' => 'required']);
     // S'il y a eu un problème quelconque pendant la création de l'Item
     if (!($item_id = $this->create($request))) {
         $request->session()->flash('message', 'danger|Une erreur s\'est produite');
         return redirect('sell::index');
     }
     // Tout s'est bien passé, on redirige ensuite sur la page de l'annonce
     $request->session()->flash('message', 'success|Votre annonce à bien été mise en ligne !');
     return redirect(route('item', ['id' => $item_id]));
 }
 public function index()
 {
     $categories = Categories::getCategories();
     return view('sell')->with(compact('categories'));
 }