Welcome Guest, Not a member yet? Register   Sign In
How to access entity method?
#2

(11-15-2020, 01:19 PM)jnar Wrote:
Code:
    public function view( $user_id=false )
    {
        $model = model('UserModel');
        $user = $model->find();
        d($user->name);
    }

In kint I can see getName as an available method but I got this error:

"Trying to get property 'name' of non-object"

How can I acces that method?

That's because find() doesn't find anything. You need to pass the id as parameter:
PHP Code:
    public function view$user_id=false )
    {
        $model model('UserModel');
        $user $model->find($user_id);
        d($user->name);
    
Reply


Messages In This Thread
How to access entity method? - by jnar - 11-15-2020, 01:19 PM
RE: How to access entity method? - by includebeer - 11-15-2020, 04:52 PM
RE: How to access entity method? - by jnar - 11-15-2020, 05:52 PM
RE: How to access entity method? - by includebeer - 11-15-2020, 06:01 PM
RE: How to access entity method? - by jnar - 11-15-2020, 08:22 PM



Theme © iAndrew 2016 - Forum software by © MyBB