So I'm new to a lot of this. Definitely PHP and idorm. I Searched far and wide but I'm not seeing an answer to this specific problem.
Object of class ORM could not be converted to string.
The Slim error pops up at the php code for $picture.
This is in my Html view
<div class="profile-left">
<div class="profile-image">
<img src="<?= empty($picture) ? '/static/images/profile-default.png' : $picture ?>"/>
<i class="fa fa-user hide"></i>
</div>
<div class="m-b-10">
<button class="btn btn-warning btn-block btn-sm" type="button" id="change_picture" data-toggle="modal" href="#change-picture-modal">Change picture</button>
</div>
</div>
This is the route for $picture in another file
$picture = ORM::for_table('picture')
->where('picture_gallery_id', $user->account_id)
->where('name', $user->account_id . ':profile')
->find_one();
$params = array_merge(
get_base_params('account', 'Edit Profile'),
[
'picture' => $picture,
]);
The data itself is saved in a Postgres table as bytea.
I'm quite sure I am missing something in my noob-ishness. Thank you in advance for any help.
Assuming the ORM returns a picture object of some type, do a var_dump()
the variable $picture
and see the fields that are available if you don't know the structure of the picture
table.
Your issue is exactly as the error indicates, $picture
is an object, your template system expects a string (or something that casts to a string). You want to pass in a string property of $picture
object you want displayed:
$params = array_merge(
get_base_params('account', 'Edit Profile'),
[
'picture' => $picture->some_property,
]);
There is a chance the ORM library isn't finding the picture and returning an instance of itself or somehting.