0

I have an issue with my Laravel installation and the use of Adldap... The error message I receive :

FatalThrowableError in UserCreationController.php line 100:
Class 'App\Http\Controllers\Adldap' not found

I have installed/deployed Adldap according to the documentation and it is working when I call it from some other location.

Working stuff :

Route::get('ldap', function() {
    $results = Adldap::search()->where('ou', 'ends_with', ' Users')
                               ->orWhere('ou','not_contains', 'Production')  
                               ->sortBy('ou', 'asc')
                               ->get();


    foreach ($results as $result) {
        dump ($result->ou);
    }

The page displays the dump correctly. All is fine.

Not working stuff (yields error code listed above). Route calling a Controller...

Route :

Route::get('newuser', 'UserCreationController@GetUserOrganizationalUnits'); 

Controller :

public function GetUserOrganizationalUnits()
{
    $results = Adldap::search()->where('ou', 'ends_with', ' Users')
                               ->orWhere('ou','not_contains', 'Production')  
                               ->sortBy('ou', 'asc')
                               ->get();
    return view('newuserform',compact('results'));
}   

Why is it working from the web php with the routes directly but not from the called Controller?

I already try adding explicitely the following as well...

use Adldap\Contracts\AdldapInterface;

The facade is declared and it works in the web routes without even calling this...

Can you please help ?

Thanks.

2 Answers2

0

I think you forgot to include the Facade

Add: use Adldap; in your UserCreationController.php

Paras
  • 9,258
  • 31
  • 55
  • Indeed, I did. Well. I didn't at first but I had other errors in the way which made me comment that out... and i thought i didn't need to do so as it was in the Facades and working from the web routes file... **Thank you** - Issue solved. :) – François Bastien Feb 07 '17 at 08:08
0

You'll also need to have this in your UserCreationController to get this working with the "use Adldap\Contracts\AdldapInterface;" approach:

protected $adldap;

public function __construct(AdldapInterface $adldap)
{
    $this->adldap = $adldap;
}

Or implement the facade in your config/app.php:

'Adldap' => Adldap\Laravel\Facades\Adldap::class
Michael Rodriguez
  • 2,142
  • 1
  • 9
  • 15