예제 #1
0
 public function postCreate()
 {
     $validator = Validator::make(Input::all(), ContactInfo::$rules);
     if ($validator->passes()) {
         $info = new ContactInfo();
         $info->description = Input::get('description');
         $info->facebook = Input::get('facebook');
         $info->twitter = Input::get('twitter');
         $info->google = Input::get('google');
         if (count(ContactInfo::all()) >= 1) {
             $info->status = 0;
         } else {
             $info->status = 1;
         }
         if ($info->save()) {
             return Redirect::to('dashboard/contact-info')->with('event', '<p class="alert alert-success"><span class="glyphicon glyphicon-ok"></span> Contact Info added successfully</p>');
         } else {
             return Redirect::back()->with('event', '<p class="alert alert-danger"><span class="glyphicon glyphicon-remove"></span> Error occured. Please try again</p>');
         }
     }
     return Redirect::back()->withErrors($validator)->withInput();
 }