Join tour with rooms from modal
This commit is contained in:
parent
757dfea5a4
commit
f1ff6ed4c2
5 changed files with 29 additions and 11 deletions
|
|
@ -7,5 +7,5 @@ use Illuminate\Database\Eloquent\Model;
|
|||
class Booking extends Model
|
||||
{
|
||||
public $timestamps=true;
|
||||
protected $fillable=['tour_id','user_id','created_at','updated_at'];
|
||||
protected $fillable=['tour_id','user_id','room_id','created_at','updated_at'];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -316,10 +316,17 @@ class TourController extends Controller
|
|||
}
|
||||
|
||||
public function join($tour_id) {
|
||||
Log::info("TourController::join");
|
||||
$user=Auth::user();
|
||||
Tour::join($tour_id,$user->id);
|
||||
return redirect('/tour/'.$tour_id);
|
||||
}
|
||||
public function join_room($tour_id,$room_id) {
|
||||
Log::info("TourController::join_room");
|
||||
$user=Auth::user();
|
||||
Tour::join_room($tour_id,$user->id, $room_id);
|
||||
return redirect('/tour/'.$tour_id);
|
||||
}
|
||||
|
||||
public function cancelBooking($tour_id) {
|
||||
$user=Auth::user();
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ namespace App;
|
|||
use Illuminate\Database\Eloquent\Model;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Log;
|
||||
|
||||
class Tour extends Model
|
||||
{
|
||||
|
|
@ -26,20 +27,27 @@ class Tour extends Model
|
|||
return false;
|
||||
}
|
||||
|
||||
// old join without room parameter
|
||||
public static function join($tour_id,$user_id) {
|
||||
error_log("Tour::join, tour_id=".$tour_id.", user_id=".$user_id);
|
||||
/*
|
||||
Booking::firstOrCreate(
|
||||
['tour_id',$tour_id],
|
||||
['user_id',$user_id],
|
||||
['updated_at', Carbon::now()]
|
||||
);
|
||||
*/
|
||||
Log::info("Tour::join, tour_id=".$tour_id.", user_id=".$user_id);
|
||||
$booking = Booking::firstOrCreate(
|
||||
['tour_id' => $tour_id, 'user_id' => $user_id],
|
||||
['tour_id' => $tour_id, 'user_id' => $user_id, 'created_at' => Carbon::now(), 'updated_at' => Carbon::now() ]
|
||||
);
|
||||
error_log($booking);
|
||||
//Log::info($booking);
|
||||
}
|
||||
|
||||
// new join with room parameter
|
||||
public static function join_room($tour_id, $user_id, $room_id) {
|
||||
Log::info("Tour::join_room, tour_id=".$tour_id.", user_id=".$user_id.", room_id=".$room_id);
|
||||
$booking = Booking::firstOrCreate(
|
||||
['tour_id' => $tour_id, 'user_id' => $user_id], // Retrieve if existing
|
||||
['tour_id' => $tour_id, 'user_id' => $user_id, 'room_id' => $room_id,
|
||||
'created_at' => Carbon::now(), 'updated_at' => Carbon::now() ] // or create new
|
||||
);
|
||||
$booking->room_id=$room_id;
|
||||
$booking->save();
|
||||
//Log::info($booking);
|
||||
}
|
||||
|
||||
public static function cancel($tour_id, $user_id) {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
<!-- CSRF Token -->
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
|
||||
<title>{{ config('app.name', 'Laravel') }}</title>
|
||||
<title>{{ config('app.name', 'Motorrag IG') }}</title>
|
||||
|
||||
<!-- Scripts -->
|
||||
<script src="{{ asset('js/app.js') }}" defer></script>
|
||||
|
|
|
|||
|
|
@ -48,7 +48,10 @@ Route::post('/tour/update', 'TourController@store')->middleware('auth');
|
|||
Route::post('/tour/upload_gallery/{tour_id}', 'TourController@upload_gallery');
|
||||
Route::resource('/tour', TourController::class)->middleware('auth');
|
||||
|
||||
// alt
|
||||
Route::get('/tour/{tour_id}/join', 'TourController@join')->middleware('auth');
|
||||
// neu
|
||||
Route::get('/tour/{tour_id}/join/{room_id}', 'TourController@join_room')->middleware('auth');
|
||||
Route::get('/tour/{tour_id}/cancelBooking', 'TourController@cancelBooking')->middleware('auth');
|
||||
Route::get('/tour/{tour_id}/cancelBookingAdmin/{user_id}', 'TourController@cancelBookingAdmin')->middleware('auth');
|
||||
Route::get('/tour/{tour_id}/create_room/{capacity}', 'TourController@create_room')->middleware('auth');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue