2

I using unisharp's laravel file manager. it works great and i am in love with the flexibility it has.

However, I need to users to store their files in their respective folders. i am able to do this by changing user_field in conf file. What i am not able to do is give acess to super administrator so that he can see all other user's files! i am almost giving up trying to figure this for days.

here is what i have tried so far:

in config/lfm.php

'base_directory'=>Unisharp\Laravelfilemanager\Handlers\ConfigHandler::class`,

And in the handler:

namespace Unisharp\Laravelfilemanager\Handlers;
class ConfigHandler
{
    public function userField()
    {
        return auth()->user()->name;
    }

    public function baseDirectory(){
        if(auth()->user()->user_type !== "S"){
            return 'storage/'.auth()->user()->name;
        }
        else{
            return 'storage/';
        }
    }
}

But the above code shows a blank page and it creates folders in Abyss which i cant find anywhere on my machine.

Any help will be appriciated.

Thanks in advance.

4

1 回答 1

7

I had the same problem. I managed to fix it modifying the function userField itself:

public function userField()
{
    $role = function_to_get_role();

    if($role == 'Admin'){
        return 'folder_1';
    }else{
        return 'folder_1/' . auth()->user()->name;          
    }
}

I tried to modify baseDirectory function too but had no success.

于 2018-03-16T14:31:28.190 回答