小编Tha*_*ung的帖子

如何在 laravel eloquent 中添加两列值并执行 where 条件

这是我的桌子:

id       remaining_amount     additional_amount
1             200                   0
2             100                -100
3             300                 100
4             200                 -50
Run Code Online (Sandbox Code Playgroud)

我正在尝试获取总和为剩余金额+额外金额> 0 的行。

$result = $this->model->where('remaining_amount' + 'total' > 0)->get();
Run Code Online (Sandbox Code Playgroud)

它不起作用。然后我尝试这样:

$result = DB::table('cash')->select(DB::raw('remaining_amount+additional_amount AS total'))
                ->where('total','>',0)
                ->get();
Run Code Online (Sandbox Code Playgroud)

它也不起作用。

请告诉我解决这个问题的方法。

php laravel eloquent

5
推荐指数
1
解决办法
4735
查看次数

当我更改项目文件夹时,在Laravel 5中发送ajax删除请求时令牌不匹配异常

我使用Dropzone.js上传图片.当我想删除图像时,我向图像控制器发送了Ajax删除请求.

        myDropzone.on("removedfile", function(file) {      
            console.log(file.name);
            console.log(uploadedImages[file.name]);
            var csrf = $('input[name=_token]').val();
            // var csrf = $('meta[name="_token"]').attr('content');
            console.log(csrf);
           var request = $.ajax({
                url: "/cms/image/"+uploadedImages[file.name],
                headers: {
                    'X-CSRF-Token': csrf ,
                    "Accept": "application/json"
                },
                type: "DELETE",
                data: {  "id": uploadedImages[file.name] },
                error: function(jqXHR, textStatus, errorThrown) {
                    // alert('HTTP Error: '+errorThrown+' | Error Message: '+textStatus);
                    console.log(errorThrown);
                },
Run Code Online (Sandbox Code Playgroud)

该方法在我的旧项目中成功发送到带有删除请求的Controller.

但我合并到其他项目,我得到了错误.

VerifyCsrfToken.php中的TokenMismatchException

我不明白为什么会发生这种异常.请解释一下我的情况.感谢并尊重所有极客.

php csrf laravel-5

4
推荐指数
1
解决办法
6463
查看次数

标签 统计

php ×2

csrf ×1

eloquent ×1

laravel ×1

laravel-5 ×1