首页 > 解决方案 > 如何检查用户是否存在pricing_plan_id?

问题描述

我正在我的 laravel 网站上制定免费的奖金计划。我想如果用户已经申请了红利计划,那么他应该不能再次申请。我希望如果pricing_plan_id 已经在具有该用户ID 的plan_logs 中,它应该返回错误。

我可以使用以下代码检查用户的记录是否存在,但我只想查找它是否存在。

 $plan = PlanLog::where('user_id', $user->id)->where('pricing_plan_id', $plan->cat_id)->get();

    if (empty($plan)) {
       return redirect()->back()->with('type','danger')->with('message','please add funds atleast once');
    }

标签: phplaravel

解决方案


推荐阅读