Example #1
0
 public function contactUs()
 {
     $number = Input::get('number');
     $people = Input::get('people');
     $postcode = Input::get('postcode');
     $address = Input::get('address');
     $site = Input::get('site');
     $data = array('number' => $number, 'people' => $people, 'postcode' => $postcode, 'address' => $address, 'site' => $site);
     $rules = array('number' => 'required|numeric', 'people' => 'required', 'postcode' => 'required|numeric|size:6', 'address' => 'required', 'site' => 'required');
     $messages = array('required' => 1, 'number.numeric' => 2, 'postcode.numeric' => 3, 'postcode.size' => 4);
     $validation = Validator::make($data, $rules, $messages);
     if ($validation->fails()) {
         $number = $validation->messages()->all();
         if ($number[0] == 1) {
             return Response::json(array('errCode' => 1, 'message' => '信息填写不完整!'));
         }
         if ($number[0] == 2) {
             return Response::json(array('errCode' => 2, 'message' => '电话号码必须为数字!'));
         }
         if ($number[0] == 3) {
             return Response::json(array('errCode' => 3, 'message' => '邮编必须为数字!'));
         }
         if ($number[0] == 4) {
             return Response::json(array('errCode' => 4, 'message' => '邮编必须为6位数字!'));
         }
     }
     $contact = contactUs::find(1);
     if ($contact = null) {
         $contact = new contactUs();
     }
     $contact->number = $number;
     $contact->people = $people;
     $contact->postcode = $postcode;
     $contact->address = $address;
     $contact->site = $site;
     if (!$contact->save()) {
         return Response::json(array('errCode' => 5, 'message' => '保存失败!'));
     }
     return Response::json(array('errCode' => 0, 'message' => '保存成功!'));
 }
Example #2
0
 public function contactUs()
 {
     $contact = contactUs::find(1);
     return View::make('联系我们')->with('contact', $contact);
 }