donglian2106 2019-07-26 04:32
浏览 16

模型[App \ UserModel] 0 [Laravel]没有查询结果

Getting an error when im trying delete users in my table.

My Route(api.php)

     Route::delete('/users/{id}', 'UsersController@destroy');

My Controller

    public function destroy($id)
    {
        $user = UserModel::findOrFail($id);
        $user->delete();
        return new UsersCollection($user);
    }

My Vue.js

        remove(id) {
            let $this = this;
            axios.delete(`/api/users/${id}`).then(function(response) {
                $this.fetchUser();
            })
        },

Any Help will be appreciate... Thanks in advances.

  • 写回答

4条回答 默认 最新

  • duanlang1196 2019-07-26 04:41
    关注

    You are getting a 404 error because you are trying to load a model with the id 0, which does not exist (keys start at 1).

    I would suggest checking your javascript code to ensure that the correct user ID to delete is passed, and that it's not accidently casting an empty value to 0.

    评论

报告相同问题?

悬赏问题

  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应