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
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
讨论数量: 2
Summer

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

6年前 评论
jcc123

@Summer 多谢

6年前 评论

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