Giogiosw's avatar

Include Auth or personal variable in config.

Hello

I installed the ckfinder https://github.com/ckfinder/ckfinder-laravel-package , is now I need to insert in the configuration file of the ckfinder the auth to see the id of the user and allow the upload in the folder belonging to the user.

The file is located in root/config/ckconfig.php

I tried to use Use Auth;

and

use Illuminate\Support\Facades\Auth;

but without success.

I created a variable inside boot() in theAppServiceProvider.php file but it always returns me nulled.

Here is the code

Config/Ckfinder.php

use App\Providers\AppServiceProvider;


$config['backends']['default'] = array(
    'name'         => 'default',
    'adapter'      => 'local',
    'baseUrl'      => env('APP_URL').'/userfiles/files/'.AppServiceProvider::check_id(),
    'root'         => public_path('/userfiles/files/'.AppServiceProvider::check_id()),
    'chmodFiles'   => 0777,
    'chmodFolders' => 0755,
    'filesystemEncoding' => 'UTF-8'
);

AppSeriveceProvider.php


namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Auth;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function check_id(){

      $utente_id =  Auth::id();
      return $utente_id;
    }
    public function boot()
    {


    }
}

I Have a this error :

Mistake:
RuntimeException
A facade root has not been set.

Can you help me? Thank you

0 likes
2 replies
mushood's avatar

I have not used this package before, but why exactly are you doing this.

From the ReadMe, you have to publish the config file like so

php artisan vendor:publish --tag=ckfinder

Then for auth, you should use a middleware, also explained in the ReadMe. You could specify the middleware you are using for auth in your config:file. https://github.com/ckfinder/ckfinder-laravel-package/blob/master/src/config.php

The key is $config['authentication'];

Please or to participate in this conversation.