I have already achieve that by adding the code under bootstrap.php:
Admin::user()->setStorage();
For Administrator user list I would like to update the config variable by selecting/edit each user:
return Admin::form(User::class, function (Form $form) {
config([
'filesystems.disks.local.root' => public_path('upload')."\\".$form->model()->username,
]);
...
but problem is I can't access $form->model()->username under form
setStorage()
config([
//'filesystems.disks.local.root' => public_path('upload')."\\".$this->username,
'admin.upload.host' => config('admin.upload.host').$this->username,
'admin.upload.directory' => [
'image' => $this->username.'/image',
'file' => $this->username.'/file',
'video' => $this->username.'/video',
],
]);
echo config('admin.upload.directory.image') showing updated path: username/image
But still image is uploading on directory image/ instead of username/image/
under prepareForSingle still showing the old config values??
protected function prepareForSingle(UploadedFile $image = null)
{
dd(config('admin.upload.directory.image'));
}
Can anyone please help me how to fix this problem?
This also does't work:
$form->image('avatar', trans('admin::lang.avatar'))->move(function ($form) {
return $form->model()->username;
});
Have you tried this:
$form->image('image')->move(Admin::user()->name)
I have figure the solution by adding the setStorage() for users in the Auth middleware it was not working properly when I put on bootstrap.php.
It's working find for logged it users.
But for Super Admin I would like to change the the default path for each selected users from the grid, something like this:
$form->image('avatar', trans('admin::lang.avatar'))->move(function ($form) {
return $form->model()->username;
});
Under move() "$form->model()->username" it always returns null.
Is there any solution for this?
Just one more important question can I return just the simple value? example:
$form->column('id')->value();
The first parameter for method move() can be a closure now:
$form->image('avatar', trans('admin::lang.avatar'))->move(function ($form) {
return $form->username;
});
Most helpful comment
The first parameter for method
move()can be a closure now: