[Solved] CakePhp 3.5.3 | Trying to get property of non-object --> with method find()->first but not with method get()

Hello,

On cake 3.5.3

I have this strange error,

When i make this request from my playlists table

$playlist = $this->find()->where([‘id’ => $id])->first();

I have an error in my view “Trying to get property of non-object”

If i make is_object($playlist) , it’s return true
If i print $playlist->title, it’s also work


Now if i do :
$playlist = $this->get($id)

I have no error this time.


So what is the problem with find()->first() ? I don’t undestand :confused:


Edit : i finally found this damn mistake, it’s was in js file in my layout theme,

// Append config box / Only for demo purpose
// Uncomment on server mode to enable XHR calls
$.get(“skin-config.html”, function (data) {
if (!$(‘body’).hasClass(‘no-skin-config’))
$(‘body’).append(data);
});


You can delete this post :wink: