How can I get current user id through ajax?

Posted in CategoryLaravel
  • B
    Bob 1 week ago

    Hi,

    I am following this article https://itsolutionstuff.com/post/laravel-5-ajax-crud-with-pagination-example-and-demo-from-scratchexample.html 

    It's been very helpful. Thank you for the tutorial. However, I want to get current user id and save the id to the database. How can I do it?

    Thank you in advance :D

  • H
    Hardik Savani 1 week ago

    Sure you can get current login user id using auth(). You can get user id in your controller this way:

    $userId = auth()->user()->id;

    Let me know if it is work.

Please login or register to leave a response.

* You May Also Like Bellow Issue to check *