Skip to content
Advertisement

How can I access variables displayed with dd( ) of Laravel?

I need to access to this id here is the code I used to displayed with dd()

Route::get('/', function () {

    Storage::extend('google', function ($app, $config) {
        $client = new Google_Client();
        $client->setClientId($config['clientId']);
        $client->setClientSecret($config['clientSecret']);
        $client->refreshToken($config['refreshToken']);
        $service = new Google_Service_Drive($client);
        $adapter = new GoogleDriveAdapter($service, $config['folderId']);
        
        return new Filesystem($adapter);
    });

    $disk = Storage::disk('google');
    
    $disk->put('abc.txt', "eyyyertr");
    
    dd($disk);
    ///return view('welcome');
});

What I need is to get the variable I mentioned in the picture below, so I can delete the uploaded file with its own id

so far I tried :

$disk['driver']['adapter']

but it doens’t work, it gives me this Error

Cannot use object of type IlluminateFilesystemFilesystemAdapter as array

enter image description here

What should I do ?

Advertisement

Answer

Thank you, Apparently we must create getters on each class Here what worked for me

dd($disk->getDriver()->getAdapter()->getCacheFileObjectsByName()->id);

note each ‘get….()’ is written on used classes example: in FilesystemAdapter.php class

public function getDriver()
{
   return $this->driver;
}

and the rest is the same.

also the ‘cacheFileObjectsByName’ was a private array, so the getter must be like so

public function getCacheFileObjectsByName()
{
   return array_values($this->cacheFileObjectsByName)[0];
}

..thank you for your helps

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement