【问题标题】:Getting id with Where clause使用 Where 子句获取 id
【发布时间】:2020-10-01 20:01:04
【问题描述】:

我有一个问题。有谁知道这种情况下如何取id id

    public function handle($request, Closure $next)
    {   
        if($request->has('id')) {
            $notification = auth()->user()->unreadNotifications()->where('I need put something here', $request->id)->first();
            if($notification) {
                $notification->markAsRead();
            }
        }
        return $next($request);
    }

我的表结构就像
编号:4 Notifiable_type 应用\用户
Notifiable_id 1
数据:{"evaluation_id":1} !!!这里是 $request->id 在我的情况下等于评估 ID 的点,我还需要从数据列中获取评估 ID 来比较它们并获取 ID

【问题讨论】:

  • 你能告诉更多关于你的Data : {"evaluation_id":1}你是如何在这里访问它的吗?基于此,只有我能帮你。

标签: laravel get notifications where-clause middleware


【解决方案1】:

我不确定我是否理解正确。

您需要将数据的evaluation_id 与$request->id 进行比较?

如果:

     $notification = auth()->user()->unreadNotifications()
->where('Data->evaluation_id', $request->id)->first();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-07-18
    • 2016-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-22
    相关资源
    最近更新 更多