laraveladldap

Laravel 5.4 - Adldap - Call to undefined method Adldap\Adldap::search()


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.


Solution

  • I think you forgot to include the Facade

    Add: use Adldap; in your UserCreationController.php