This is my ajax function calling the route to controller:
<script type="text/javascript">
$(document).ready(function(){
$.ajax({
type: "get",
url: '/getRooms/{{ $roomtype->name }}',
data: "",
success: function(data) {
console.log(data);
}
})
});
</script>
This is my controller method called from the ajax function and route.
public function numberOfRooms($room_name, Request $request)
{
$room_model = new room;
$no_rooms = $room_model->where('rmtype', '=', $room_name)->get()->count();
return $no_rooms;
}
This is the value returned from ajax success and I need it to be converted to a PHP value to display it in laravel blade for my foreach statement