Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entity _options dates #1061

Closed
nowackipawel opened this issue Jun 1, 2018 · 3 comments
Closed

Entity _options dates #1061

nowackipawel opened this issue Jun 1, 2018 · 3 comments

Comments

@nowackipawel
Copy link
Contributor

nowackipawel commented Jun 1, 2018

When I am trying to add $_options = ['cast' => []]; to one of my class which contains entity and additionally I don't wanna define dates configuration... CI is returning an exception and made me to define it (dates cfg for entity):
Type: ErrorException Message: Undefined index: dates Filename: /home/zdamy/site/system/Entity.php Line Number: 176
(I am a huge fan of writing CLI application but I am sure the same is happening during normal requests).

@lonnieezell
Copy link
Member

That's because you're overwriting the entire $_options array, and not providing the default values it expects to be there.

@nowackipawel
Copy link
Contributor Author

nowackipawel commented Jun 8, 2018

I know what is causing this error but you should prevent it if in the documentation there is the example like this:

class User extends Entity
{
protected $id;
protected $name; // Represents a full name now
protected $email;
protected $password;
protected $created_at;
protected $updated_at;

protected $_options = [
    'datamap' => [
        'full_name' => 'name'
    ]
];

}

or just change the docs :)

/sorry there is no way to format code in this form from mobile device.

@lonnieezell
Copy link
Member

Just changing the docs is the way to go here :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants