laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.51k stars 11.01k forks source link

Database Capsule Events #1183

Closed Surt closed 11 years ago

Surt commented 11 years ago

Hi Taylor,

after yesterday fix for standalone database lib, the events still don't fire. I can't follow the entire architecture, but I see the Model not getting the dispatcher from the DatabaseManager at all, so, even if you create one on the config and assign it to Capsule (or letting the getEmptyConfig create it), the Model still don't have it, since is not using the DatabaseManager one.

/**
     * Prepare the Eloquent ORM for use.
     *
     * @return void
     */
    public function bootEloquent()
    {
        Eloquent\Model::setConnectionResolver($this->manager);
    }
taylorotwell commented 11 years ago

I don't get one you mean... we're setting the event dispatcher:

Eloquent\Model::setEventDispatcher($this->config['events']);
Surt commented 11 years ago

It seems to be

    /**
     * Create a new Eloquent model instance.
     *
     * @param  array  $attributes
     * @return void
     */
    public function __construct(array $attributes = array())
    {
        if ( ! isset(static::$booted[get_class($this)]))
        {
            static::boot();

            static::$booted[get_class($this)] = true;
        }

        $this->fill($attributes);
    }

static::$booted does not exists on standalone capsule installation? I don't know, just, with capsule my events defined on the boot method inside a model does not work.