Skip to content

Cannot use "find" when Model has constructor #25

Closed
@rms2219

Description

@rms2219

I wanted to create a constructor for my model to give some fields some default values. I created the constructor like this:

protected $fillable = array('_id');

public function __construct($attributes = array(), $exists = false)
    {
        parent::construct($attributes, $exists);

        $this->wigets = array();
        $this->starredDocuments = array();
        $this->last_accessed_date = date('m/d/Y g:i:s A'); // e.g. 08/23/2013 1:23:45 PM
    }

My plan requires me to first check if an entry exists with the given key before creating a new one and saving it. When I call "find" on my model, I get a BadMethodCallException: Call to undefined method Jenssegers\Mongodb\Builder::construct()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions