I cannot find the problem in this code.
public function dovoljenjaZaposlenega($id)
{
echo Dovoljenja::find($id)->naziv;
}
When I do this, i get a following error:
Trying to get property of non-object
But when i just echo $id out, it’s working
public function dovoljenjaZaposlenega($id)
{
echo $id;
}
But even more weird is, that if i replace $id with actual number it’s working again..
public function dovoljenjaZaposlenega($id)
{
echo Dovoljenja::find(2)->naziv; // Some number..
}
Thanks for your help!
There is nothing wrong .. you just need to basically check for errors.
Dovoljenja::find($id);would only return an object if the$idexistsTry this experiment with id
2and4