如何在删除模式vue.js上解决500(内部服务器错误)?

时间:2017-01-20 23:14:04

标签: javascript laravel vue.js laravel-5.3 vuejs2

我的观点是这样的:

parseInt(e.target.value, 10);

我的模态是这样的:

@foreach($account_list as $account)
<table class="table table-bordered">
    ...
        <li>
            <a href="javascript:;" @click="modalShow('modal-delete-account',{{ $account['id'] }})">
                <span class="glyphicon glyphicon-trash"></span>&nbsp;Delete
            </a>
        </li>
    ...
</table>
@endforeach

我的路线是这样的:

<template>
    <div class="modal" tabindex="-1" role="dialog">
        ...
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
                <button type="button" class="btn btn-success" @click="deleteAccount">OK</button>
            </div> 
        ...
    </div>
</template>

<script>
    export default{
        name: 'DeleteAccountModal',
        props:['idAccount'],
        methods:{
            deleteAccount(event){
                event.target.disabled = true
                const payload= {id_account: this.idAccount}
                this.$store.dispatch('deleteAccount', payload);
                window.location.reload(true)
            }
        }
    }
</script>

我的account.js(resources \ assets \ js \ api \ account.js)是这样的:

Route::group(['middleware' => 'auth', 'prefix'=>'member', 'as'=>'member.'], function () {
    ...
    Route::group(['prefix' => 'profile', 'as'=>'profile.'], function () {
        ...
        Route::post('setting/account/delete', 'Member\UserBankController@deleteAccount');
        ...
    });
    ...
});

我的控制器是这样的:

import Vue from 'vue'
import Resource from 'vue-resource'
Vue.use(Resource)
export default {
    ...
    delete (account, cb, ecb = null ) {
        Vue.http.post(window.Laravel.baseUrl+'/member/profile/setting/account/delete', account)
            .then(
            (resp) => cb(resp.data),
            (resp) => ecb(resp.data)
        );
    },
    ...
}

我的服务是这样的:

public function deleteAccount(Request $request)
{
    $id_account = $request->input('id_account');
    try{
        if($this->user_service->deleteAccount($id_account)) {
            return $this->respond(['status' => 'Success']);
        }else {
            return $this->respond(['status' => 'Failed Delete']);
        }
    }catch (\Exception $exception){
        return $this->respondInternalError();
    }
}

我的存储库是这样的:

public function deleteAccount($id)
{
    return $this->user_bank_repository->delete($id);
}

当我点击删除按钮时,它会显示一个带有vue.js的模态。之后,我单击确定按钮将其删除。但是没有记录被删除。

在控制台上看起来像这样:

enter image description here

存在错误:500(内部服务器错误)

如何解决这个问题?

0 个答案:

没有答案