/**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $validation = Validator::make($input, Stat::$rules);
     if ($validation->passes()) {
         $this->stat->create($input);
         return Redirect::route('stats.index');
     }
     return Redirect::route('stats.create')->withInput()->withErrors($validation)->with('message', 'There were validation errors.');
 }
Ejemplo n.º 2
0
 public function postAddBoard()
 {
     if (Auth::check()) {
         $rules = array('hashtag' => 'required|min:3', 'avatar' => 'mimes:jpg,jpeg,png|image|max:1024|image_size:>=300', 'cover' => 'mimes:jpg,jpeg,png|image|max:3072|image_size:>=1200,>=150', 'presentation_cover' => 'mimes:jpg,jpeg,png|image|max:4096|image_size:>=1200,*', 'website_url' => 'url', 'refresh_interval' => 'integer|min:10|max:120', 'refresh_count' => 'integer|min:1|max:100');
         $user = Auth::user();
         $validator = Validator::make(Input::all(), $rules);
         if ($validator->fails()) {
             $messages = $validator->messages();
             return Redirect::to('/konto/tablica/dodaj')->withInput(Input::flash())->withErrors($validator)->with('alert', array('type' => 'error', 'content' => 'Błąd! Sprawdź wszystkie pola.'));
         } else {
             $data = Input::get('hashtag');
             $data = explode(' ', trim($data));
             $result = preg_replace('/#([\\w-]+)/i', '$1', $data[0]);
             $hashtag = Sanitize::string($result);
             $board = Board::create(array('hashtag' => $hashtag, 'description' => Input::get('description'), 'avatar' => Input::file('avatar'), 'cover' => Input::file('cover'), 'presentation_cover' => Input::file('presentation_cover'), 'fb_user' => Input::get('fb_user'), 'tw_user' => Input::get('tw_user'), 'insta_user' => Input::get('insta_user'), 'google_user' => Input::get('google_user'), 'website_url' => Input::get('website_url')));
             $fb = Input::has('has_fb') ? 0 : -1;
             $insta = Input::has('has_insta') ? 0 : -1;
             $tw = Input::has('has_tw') ? 0 : -1;
             $google = Input::has('has_google') ? 0 : -1;
             $vine = Input::has('has_vine') ? 0 : -1;
             $refreshInterval = Input::has('refresh_interval') ? Input::get('refresh_interval') : 30;
             $refreshCount = Input::has('refresh_count') ? Input::get('refresh_count') : 2;
             $bannedUsers = Input::has('banned_users') ? Input::get('banned_users') : '';
             $filter = Input::has('filters') ? Input::get('filters') : '';
             $live = Input::has('live') ? 1 : 0;
             $presentation = Input::has('presentation') ? 1 : 0;
             $color = Input::has('color') ? Input::get('color') : '';
             $config = BoardConfig::create(array('board_id' => $board->id, 'user_id' => $user->id, 'has_fb' => $fb, 'has_insta' => $insta, 'has_tw' => $tw, 'has_google' => $google, 'has_vine' => $vine, 'refresh_interval' => $refreshInterval, 'refresh_count' => $refreshCount, 'presentation' => $presentation, 'color' => $color, 'live' => $live, 'banned_users' => $bannedUsers, 'filter' => $filter));
             Stat::create(array('board_id' => $board->id));
             return Redirect::to('/konto/tablice')->with('alert', array('type' => 'success', 'content' => 'Tablica utworzona!'));
         }
     }
 }