mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-21 10:49:10 -04:00
3.2.1
This commit is contained in:
@@ -4,45 +4,91 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Booking;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class BookingController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return Response
|
||||
*/
|
||||
public function index()
|
||||
public function index($type, $id)
|
||||
{
|
||||
//
|
||||
switch ($type)
|
||||
{
|
||||
case 'course':
|
||||
$event = \App\Course::find($id);
|
||||
$event->fulltime = $event->event->date_begin.', Niveau '.$event->level.', Période '.$event->periode;
|
||||
$event->fulldesc = $event->ocom;
|
||||
break;
|
||||
case 'event':
|
||||
$event = \App\Event::find($id);
|
||||
$event->fulltime = $event->date_begin;
|
||||
$event->fulldesc = $event->desc;
|
||||
break;
|
||||
default:
|
||||
abort(500);
|
||||
}
|
||||
|
||||
clogNav('consulte les réservations');
|
||||
return view('admin.booking.index',['event' => $event,'event_type' => $type,'event_id' => $id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return Response
|
||||
*/
|
||||
public function create()
|
||||
public function create($type,$id)
|
||||
{
|
||||
//
|
||||
return view('admin.booking.create',['items' => \App\Item::training(),'event_type' => $type,'event_id' => $id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
public function store(Request $request,$type,$id)
|
||||
{
|
||||
//
|
||||
$b = new Booking();
|
||||
|
||||
$b->item_id = $request->item_id;
|
||||
$b->amount = $request->amount;
|
||||
$b->bookable_id = $id;
|
||||
$b->user_id = \Auth::user()->id;
|
||||
if (!$request->comment == '')
|
||||
{
|
||||
$b->comment = $request->comment;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$b->comment = 'Aucun commentaire';
|
||||
}
|
||||
switch ($type)
|
||||
{
|
||||
case 'course':
|
||||
$b->bookable_type = 'App\Course';
|
||||
break;
|
||||
case 'event':
|
||||
$b->bookable_type = 'App\Event';
|
||||
default:
|
||||
$b->bookable_type = '';
|
||||
}
|
||||
|
||||
$b->save();
|
||||
clog('add','success','a ajouté une réservation avec succès',null,'App\Booking',$b->id);
|
||||
return redirect('/admin/booking/course/'.$id)->with('success','Réservation ajouté avec succès');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Booking $booking
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return Response
|
||||
*/
|
||||
public function show(Booking $booking)
|
||||
{
|
||||
@@ -53,7 +99,7 @@ class BookingController extends Controller
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Booking $booking
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return Response
|
||||
*/
|
||||
public function edit(Booking $booking)
|
||||
{
|
||||
@@ -65,21 +111,38 @@ class BookingController extends Controller
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Booking $booking
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return Response
|
||||
*/
|
||||
public function update(Request $request, Booking $booking)
|
||||
{
|
||||
//
|
||||
$b = Booking::find($request->booking_id);
|
||||
$b->amount = $request->amount;
|
||||
$b->comment = $request->comment;
|
||||
|
||||
$b->save();
|
||||
return back()->with('success','Modification sauvegardé avec succès');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Booking $booking
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return Response
|
||||
*/
|
||||
public function destroy(Booking $booking)
|
||||
public function destroy(Request $request)
|
||||
{
|
||||
//
|
||||
$b = Booking::find($request->id);
|
||||
|
||||
$b->delete();
|
||||
}
|
||||
|
||||
public function modalItem($id)
|
||||
{
|
||||
return view('admin.booking.modal.create',['item' => \App\Item::find($id)]);
|
||||
}
|
||||
|
||||
public function modalItemEdit($id)
|
||||
{
|
||||
return view('admin.booking.modal.edit',['booking' => \App\Booking::find($id)]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user