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

后端 未结 2 1590
故里飘歌
故里飘歌 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:25

    Check you are getting Input::get('siteId') correctly. if you are getting it then try to convert it into integer i.e

    $iSiteToDelete = intval(Input::get('siteId'));
    
    0 讨论(0)
  • 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
    
    0 讨论(0)
提交回复
热议问题