Reputation: 57
guys, I am trying to use the Auth
function in my script
tag which is inside a blade
file but it seems like I am getting a yellow warning when I checked their source in google. Is it possible to use the Auth
function in a script tag or is there an alternative approach for this? Anyone able to help? thanks in advance.
Here my snippets of code in the script tag
<script type="text/javascript">
$('button').click(function(){
//CONST DATA
const prefix = "QATS";
const url = "http://qr5.dev.ificonsultancy.net/api/sendData";
//Extract Data
var lecturer_id = Auth::user()->id; //HERE IS THE ERROR
var faculty_code = $( "#Faculty" ).val();
var programme_code = $( "#Programme" ).val();
var class_code = $("#Class").val();
//Location Coordinates
var gps_school_lng = "101.5597904";
var gps_school_lat = "3.0923526";
//URL Concatenation
var urlContent = prefix.concat("|",url,"|",lecturer_id,"|",faculty_code,"|",programme_code,"|",class_code,"|",gps_school_lat,"|",gps_school_lng);
//Add src to #qrImg
$("img#qrImg").attr('src',"https://chart.googleapis.com/chart?chs=300x300&cht=qr&chl="+urlContent+"&choe=UTF-8");
console.log("pass");
});
</script>
Upvotes: 1
Views: 523
Reputation: 18187
Yes, just use the mustache syntax:
var lecturer_id = '{{ Auth::user()->id; }}'
Upvotes: 1