Miljan Rakita
Miljan Rakita

Reputation: 1533

Laravel 5 Function name must be a string Error

i suddenly got this error message 'Function name must be a string' when i try to read all of my model rows from database.

This is the code, i run when i get the error.

 /**
 * Display a listing of the resource.
 *
 * @return \Illuminate\Http\Response
 */
public function index()
{
    return Customer::all();
}

This is the image of the error.

enter image description here

I don't understand what i could do so i can't run simple query to list all rows from database. Can anyone help me how to fix this ? I have checked all other posts from stackoverflow for this title but i could not find solution.

Upvotes: 1

Views: 2587

Answers (1)

Miljan Rakita
Miljan Rakita

Reputation: 1533

The problem was because i had CustomerObserver class and in AppServiceProvider i used wrong class

public function boot()
{
    Subscription::observe(SubscriptionObserver::class);
    SocialMediaAccount::observe(SocialMediaAccountObserver::class);
    Customer::observe(Customer::class);
}

I should use:

Customer::observe(CustomerObserver::class);

That caused my problem.

Upvotes: 7

Related Questions