Laravel Eloquent::Find() returning NULL with an existing ID

后端 未结 2 1589
故里飘歌
故里飘歌 2020-12-10 14:10

It\'s pretty straightforward as it\'s the most basic thing but I don\'t know what I\'m missing:

Having a model called Site

I\'m using Eloquent O

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-10 14:31

    You're not returning your model.

    var_dump prints output and returns nothing.

    do this instead:

    dd($oSite); // stands for var_dump and die - a helper method
    

    and even better, simply return the model:

    return $oSite; // will be cast to JSON string
    

提交回复
热议问题