Laravel-admin: How to get the current authenticated admin user id in Form field value

Created on 26 Aug 2019  ·  1Comment  ·  Source: z-song/laravel-admin

How to get the current authenticated admin user id in Form field value

 $form->text('created_by', 'created_by')->default(Admin::user()->id)->setWidth(3, 2);

Error:

Symfony Component Debug Exception FatalThrowableError (E_ERROR)
Class 'AppAdminControllersAdmin' not found

Most helpful comment

@rajkumarForDev you must add to header
use Encore\Admin\Facades\Admin;
and then you can use Admin::user()->id

>All comments

@rajkumarForDev you must add to header
use Encore\Admin\Facades\Admin;
and then you can use Admin::user()->id

Was this page helpful?
0 / 5 - 0 ratings