Exemplo n.º 1
0
 public function postAdd()
 {
     $validator = Validator::make(Input::all(), Blackword::$rules);
     if ($validator->passes()) {
         if (Blackword::where('value', '=', Input::get('value'))->count() == 0) {
             $val = str_replace(array("\r", "\n"), "", Input::get('value'));
             $Blackword = new Blackword();
             $Blackword->value = Input::get('value');
             $Blackword->save();
             if (preg_match("/\\p{Hebrew}/u", Input::get('value')) == false) {
                 if ($this->starts_with_upper(Input::get('value'))) {
                     // insert lower case
                     $Blackword = new Blackword();
                     $Blackword->value = strtolower(Input::get('value'));
                     $Blackword->save();
                 } else {
                     // insert upper case
                     $Blackword = new Blackword();
                     $Blackword->value = ucwords(Input::get('value'));
                     $Blackword->save();
                 }
             }
         }
         return Redirect::action('BlackwordController@getIndex')->with('message', 'Word added!');
     }
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
 }