Giogiosw
4 months ago

Include Auth or personal variable in config.

Posted 4 months ago by Giogiosw

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

Please sign in or create an account to participate in this conversation.