Crud: how to get the current Admin id ?

Created on 18 Apr 2018  路  8Comments  路  Source: Laravel-Backpack/CRUD

Bug report

What I did:

i want to check the current admin

What I expected to happen:

get the id of admin

What happened:

What I've already tried to fix it:

Backpack, Laravel, PHP, DB version:

triage

Most helpful comment

use Auth;
Auth::guard('admin')->user()->id;

All 8 comments

Hi @OdaiTu ,

You should be able to use backpack_user()->id anywhere inside your app, in the latest Backpack. It will also apply a custom authentication guard, if you've specified one in your base.php config file. If you're running an old Backpack\Base version, it's the normal Auth::user(), with no auth guard applied.

Hope it helps.
Cheers!

@tabacitu
im not sure if i get it
right im using the last version
using backpack_user()->id gives me an call to undefined function
i have i users table and admins table
which i use is the admins table for backpack login and register
i want to send notifications to these admins base in there id`s
so i can display the notifications for each admin base on his id

i did this
Auth::guard(admin)->user();

but i miss something here
i dont know what it is

check your guard in config/backpack/base.php config file

@iMokhles its admin

@OdaiTu you seem to be using Backpack\Base 0.8.x if you get undefined function when using backpack_user(). For this version use \Auth::user()->id. I assume you're not using custom auth guards.

Cheers!

use Auth;
Auth::guard('admin')->user()->id;

For me

Auth::guard('backpack')->user() works perfectly.

use Auth;
Auth::guard('admin')->user()->id;

I have been working on something for 2 hours and your code helped me get it done man. Bless you

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sokvebolkol picture sokvebolkol  路  3Comments

sseggio picture sseggio  路  3Comments

M0H3N picture M0H3N  路  3Comments

deepaksp picture deepaksp  路  3Comments

abewartech picture abewartech  路  3Comments