0

I just updated my application into version 5.3 and in many routes I'm getting trying to get property of non-object Like for example I have a resource called post and another called Article where each post can have one Articles. And each Article has one writer. When I do

$article->post->writer;

I get trying to get property 'writer' of non-object

Before updating from 5.2 this route as well as other routes worked perfectly. Am i missing something here? should i do something after composer update has been run successfully?

Edit: The article, the post and the writer all exist in the DB. When I try to return $article I get this.

{
    "article": []
}

When i switch back to laravel 5.2 I get the proper article

Edit 2: it is routing bidnings problem. I'm using implicit model binding, so when i pass the ID of the article to my route, Laravel fetches the resource. but Now apparently it doesn't do it. I followed the instructions here for the bindings https://laravel.com/docs/5.3/upgrade#upgrade-5.3.0 but Laravel can't still get the article

marmahan
  • 183
  • 2
  • 15

1 Answers1

0

It was name bindings issue. Laravel 5.3 needs some configuration in kernel.php as well as in the group route https://laravel.com/docs/5.3/upgrade#upgrade-5.3.0 The group should have 'middleware' => ['bindings']

marmahan
  • 183
  • 2
  • 15