コード例 #1
0
 public static function postAddGuest()
 {
     if (Auth::check()) {
         $validation = \App\Models\Guest::validate(Input::all());
         if ($validation->passes()) {
             if (count(\App\Models\Reservation::checkIfExistsZakaznik(Input::get('guest_id'))) == 0) {
                 /** Here, you have to check if user_id is valid ID number **/
                 DB::insert('INSERT INTO zakaznik (meno, rodnecislo, adresa, datnar, telcis, mail) VALUES (?, ?, ?, ?, ?, ?)', [Input::get('name'), Input::get('guest_id'), Input::get('address'), Input::get('birth_date'), Input::get('telephone'), Input::get('mail')]);
             }
             DB::insert('INSERT INTO obyvana (CisPobytu, IDZak) VALUES (?, ?)', [Input::get('id'), Input::get('guest_id')]);
             return Redirect::route('home')->with('message', 'Guest successfully added!');
         } else {
             return Redirect::route('addguest')->withErrors($validation)->withInput()->with('id', Input::get('id'));
         }
     } else {
         return Redirect::route('home')->with('message', 'You are not logged in!');
     }
 }