In my application users logged in through a button register themselves with an activity, when they click on the button, the user and activity information is sent to a table in the database.
The above works in the following way:
Laravel driver:
public function eventoRegistrado(Request $request){
$eventoRegistrado = new Registration();
$eventoRegistrado->user_id = $request->user_id;
$eventoRegistrado->event_id = $request->event_id;
$eventoRegistrado->nombre_asistente = $request->nombre_asistente;
$eventoRegistrado->nombre_evento = $request->nombre_evento;
$eventoRegistrado->save();
}
Javascript function:
$http.post("/eventoRegistrado", {user_id: $scope.user_id, event_id: $scope.evento_id,
nombre_asistente: $scope.nombre_asistente, nombre_evento: $scope.nombre_evento})
view:
<button class="btn btn-primary" ng-click='registrarEvento("{{$event->name}}", "{{$event->id}}", "{{Auth::user()->id}}", "{{Auth::user()->name}}")'>Registrarme en este evento.</button>
The idea is that in addition to the registration button, there is also a button to delete the record, but I do not know how to create a function to eliminate the record already done.