Laravel 的查询条件怎么支持传递字符串,进行链式操作。$where="where ('created_at', '>', Carbon::today ())";

public function getTodayRegister()
    {
        $where="where('created_at', '>', Carbon::today())";
        return $this->getCount($where);
    }
    public function getCount($where)
    {
        if ($data=request()->only('field')) {
            User::Organization()->OrgAjaxRequest()->$where->get()->filter(
                function ($v, $k) use($data){
                    if ($v->extra) {
                        foreach ($v->extra as $k1 => $v1) {
                            if ($k1 == 'field') {
                                if (array_intersect($v1, $data['field'])) {
                                    return true;
                                } else {
                                    return false;
                                }
                            }
                        }
                    } else {
                        return false;
                    }
                }
            )->count();
        }

        return User::Organization()->OrgAjaxRequest()->$where->get()-count();
    }

$where="where('created_at', '>', Carbon::today())";传递进来之后,不能解析

User::Organization()->OrgAjaxRequest()->$where->get()-count();

报错

Undefined property: October\Rain\Database\Builder::$where

请问是否有这样调用的可能

Make everything simple instead of making difficulties as simple as possible
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
讨论数量: 2
Summer

推荐利用 本地作用域 功能来解决。

6年前 评论
jcc123

@Summer 多谢

6年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!