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

(11-15-2020, 06:01 PM)includebeer Wrote: But you no longer have "Trying to get property 'name' of non-object" ?

Well you are right on that... Anyways I found my answer with help of another thread.  I needed to extend original entity, not model as I was doing.

I had to change this (was taken literally from docs) on my entity:
Code:
use Myth\Auth\Models\UserModel as MythUser;

For this:
Code:
use \Myth\Auth\Entities\User as MythEntity;

Then put this on my controller:
Code:
public function view( $user_id=false )
{
    $model = model('UserModel');
    $data['user'] = $model->find($user_id);

    echo view('user\profile',$data);
}

And finally in my view I were able to do this:
Code:
<h3 class="profile-username text-center"><?= $user->name ?></h3>

And all is good now.
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