Laravel Model->save() returns false but no error

后端 未结 1 1296
感情败类
感情败类 2021-02-02 07:56

Normally when I call Model->save(), it creates the new record in the database successfully. I\'m trying to debug a situation when nothing happens and Model

相关标签:
1条回答
  • 2021-02-02 08:58

    To get the insert queries when $user->save(); error, you can try to catch the exception like this:

        try{
           $user = new User;
           $user->fields = 'example';
           $user->save(); // returns false
        }
        catch(\Exception $e){
           // do task when error
           echo $e->getMessage();   // insert query
        }
    

    Hope this helps :)

    0 讨论(0)
提交回复
热议问题