Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Arnas42's avatar

PHP Error: Call to undefined method Illuminate/Events/Dispatcher::all()

Hi, I'm new to laravel, it's great, but I just ran into the problem that I cannot seem to find any answers for. While trying to use tinker I get an error when I try to look up all the objects in events model, like so:

Event::all();

I get the error: PHP Error: Call to undefined method Illuminate/Events/Dispatcher::all() in my_path Version/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 261

Athough every other model seems to work fine, I get all the objects from other tables and I create them in the same and only way I know. For example:

    $event = new Event();
    $event->date_from = $request->post('date_from');
    $event->date_to = $request->post('date_to');
    $event->place = $request->post('place');
    $event->name = $request->post('name');
    $event->description = $request->post('description');

    $event->save();

So if I type Objects::all(); it works just fine

0 likes
7 replies
Sergiu17's avatar

Hi, if Event is your model, then:

$ php artisan tinker

>>> App\Event::all();
Nakov's avatar

@arnas42 seems like you are using a class name that already exists in the framework, so when using wrong import, then this will happen.

Make sure that in tinker you use the full namespace like this:

App\Event::all();

or

App\Models\Event::all();

Depends on where you store your models. Same in the code, make sure that you've got the correct import at the top of the class:

for example:

use App\Event;
Arnas42's avatar

App\Event::all(); - works fine, but I do not understand why. Because all my models are under App folder and I can access all others. I also import them like this: use App\Event;

Is there a comant like php artisan route:list, where I could see all the paths for comparison?

Nakov's avatar
Nakov
Best Answer
Level 73

All your models are there, but as I said above you are using an Event class that exists in the framework as well.

If you open your config/app.php in the aliases array you will see this:

'Event' => Illuminate\Support\Facades\Event::class,

So either chose a different name, or make sure you always use the correct import.

1 like
Sergiu17's avatar

Your models have namespace App,

<?php

namespace App; // this is why 

class Event extends Model
{
sauravs012's avatar

In versions prior to Laravel 5.7, this method class name was fire but with Laravel 5.8, it is now dispatch.

Replace fire with dispatch in \Your Project\vendor\santigarcor\laratrust\src\Traits\LaratrustHasEvents.php from

    protected function fireLaratrustEvent($event, array $payload)
    {
        if (! isset(static::$dispatcher)) {
            return true;
        }

        return static::$dispatcher->fire(
            "laratrust.{$event}: ".static::class,
            $payload
        );
    }

to

    protected function fireLaratrustEvent($event, array $payload)
    {
        if (! isset(static::$dispatcher)) {
            return true;
        }

        return static::$dispatcher->dispatch(
            "laratrust.{$event}: ".static::class,
            $payload
        );
    }

Please or to participate in this conversation.