php - 如何检查用户是否存在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');
}
解决方案
推荐阅读
- javascript - 如何在 Javascript/Typescript 中创建基于类的枚举
- javascript - 当用户从textarea中的指定单词中删除字母时,如何重新隐藏按钮?
- macos - 在 Mac 上使用 Putty 尝试 mkdir /root/.local/share 时的只读文件系统
- pytorch - 关于使用 PyTorch 编写 cnn 的问题
- javascript - try 块中的 return 语句是否等待 finally 块中的 await 语句?
- css - 对于 Angular 9 mat-tables,有没有办法在一个地方为一行设置 CSS 颜色?
- reactjs - 为什么在 then() 内部存在数据,而外部不存在 - Axios 返回未定义
- reactjs - 使用 KendoReact 以编程方式在字段上显示错误消息
- google-sheets - DataStudio Question with Google Sheets - 添加逗号,添加百分点
- c# - SSIS 脚本任务因 NewtonSoft.Json 而失败