0

in balde and controller when i want to get the authenticated admin i use

$data=Auth::guard('admin')->user();

is there a way to get this in a javascript variable and then console.log it?

i have tried to solve this by this but it doesn't work. I have also searched google and stackoverflow but cannot get an existing answer

var data = <?php Auth::guard('admin')->user();?>
console.log(data);

i'm using hesto multiauth

Muzammil Baloch
  • 176
  • 3
  • 14
  • 1
    Possible duplicate of [How to pass variables and data from PHP to JavaScript?](https://stackoverflow.com/questions/23740548/how-to-pass-variables-and-data-from-php-to-javascript) – online Thomas May 15 '18 at 08:23

2 Answers2

1

i solved the problem by doing this.

var data = <?= Auth::guard('customer')->user() ?>;

Muzammil Baloch
  • 176
  • 3
  • 14
0

Try this in your blade file:

<script>
   var data = {!! Auth::guard('admin')->user() !!}
   console.log(data);
</script>