Exemple #1
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(EditUserRequest $request, $id)
 {
     $propertyKeys = ArrayCheckHelper::ignoreRepeated($request->all(), "property");
     $person = Person::where('ci', $request->get('ci'))->get()->first();
     $person->fill(['ci' => $request->get('ci'), 'name' => $request->get('name'), 'last_name' => $request->get('last_name'), 'email' => $request->get('email'), 'telephone' => $request->get('telephone'), 'id_country' => $request->get('id_country')]);
     $person->save();
     $user = User::findOrFail($id);
     $user->fill(['id_person' => $person->id, 'id_role' => $request->get('id_role'), 'default_property' => $request->get('default_property'), 'auth_key' => 'some key', 'username' => $request->get('username'), 'password' => $request->get('password')]);
     $user->save();
     $user->properties()->sync($propertyKeys);
     $message = $user->username . ' updated successfully';
     if ($request->ajax()) {
         return $message;
     }
     Session::flash('message', $message);
     return redirect()->route('admin.users.index');
 }
Exemple #2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(EditBookingRequest $request, $id)
 {
     $this->checkAvailability($request, $id);
     if (count(Person::where('ci', $request->get('ci'))->get()) == 0) {
         $message = "You can not change the owner of this booking. You must create a new booking instead";
         if ($request->ajax()) {
             return $message;
         }
         Session::flash('message', $message);
         return redirect()->route('admin.booking.edit');
     }
     $person = Person::where('ci', $request->get('ci'))->get()->first();
     $person->fill(['name' => $request->get('name'), 'last_name' => $request->get('last_name'), 'email' => $request->get('email'), 'telephone' => $request->get('telephone'), 'id_country' => $request->get('id_country')]);
     $person->save();
     $booking = Booking::findOrFail($id);
     //$booking->roomType->occupied= 0;
     $booking->fill(['id_property' => session('current_property')->id, 'id_user' => Auth::user()->id, 'person' => $person->id, 'date' => date("Y/m/d"), 'check_in' => $request->get('check_in'), 'check_out' => $request->get('check_out'), 'arrival_time' => $request->get('arrival_time'), 'comments_and_requests' => $request->get('comments_and_requests'), 'id_room_type' => $request->get('id_room_type'), 'number_of_rooms' => $request->get('number_of_rooms'), 'adults' => $request->get('adults'), 'children' => $request->get('children'), 'pets' => $request->get('pets'), 'rate_plan' => $request->get('rate_plan')]);
     $booking->save();
     //$booking->roomType->occupied= 1;
     $message = "Booking " . $booking->reference_code . ' updated succesfully';
     if ($request->ajax()) {
         return $message;
     }
     Session::flash('message', $message);
     return redirect()->route('admin.booking.index');
 }
Exemple #3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id, Request $request)
 {
     $person = Person::findOrFail($id);
     $message = "";
     try {
         $person->delete();
         $message = trans('appstrings.item_removed', ['item' => $person->full_name]);
         Session::flash('message_type', 'success');
     } catch (\PDOException $e) {
         $message = trans('sqlmessages.' . $e->getCode());
         if ($message == 'sqlmessages.' . $e->getCode()) {
             $message = trans('sqlmessages.undefined');
         }
         if ($request->ajax()) {
             return ['code' => 'error', 'message' => $message];
         }
         Session::flash('message_type', 'error');
     }
     if ($request->ajax()) {
         return ['code' => 'ok', 'message' => $message];
     }
     Session::flash('message', $message);
     return redirect()->route('admin.people.index');
 }
Exemple #4
0
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
// Authentication routes...
Route::controllers(['auth' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController']);
Route::get('/', function () {
    return redirect()->route('admin.dashboard.index');
});
Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'set_current_property'], 'namespace' => 'Admin'], function () {
    Route::get('people/search/{ci}', ['as' => 'peopleSearch', function ($ci) {
        $person = Person::where('ci', $ci)->first();
        if ($person !== null) {
            return $person->toJson();
        }
        return $person;
    }]);
    Route::get('availability/list/{fromDate}/{toDate}', ['as' => 'availabilityList', 'uses' => 'AvailabilityController@listAll']);
    Route::get('booking/canceled', ["as" => "admin.booking.canceled", 'uses' => 'BookingController@canceled']);
    Route::get('booking/arrival', ["as" => "admin.booking.arrival", 'uses' => 'BookingController@arrival']);
    //the middleware for resource is defined within every controller constructor
    Route::resource('dashboard', 'DashboardController');
    Route::resource('people', 'PeopleController');
    Route::resource('booking', 'BookingController');
    Route::resource('property', 'PropertyController');
    Route::resource('rate', 'RateController');
    Route::resource('services', 'ServicesController');