[英]Laravel hasOne Relation 2 columns
我有 2 个模型,第一个是(计划),第二个是(计划价格)
我在 plan_price 表中有这个列:
$table->float('price')->comment('Price for one month or one year depends on country code'); $table->string('country_code')->default('EG');
我想要的是获得价格取决于用户国家/地区代码的计划。
我认为你应该这样做:
return $this->hasOne(PlanPrice::class, 'plan_id')->where('country_code',
$what_ever_your_code_is);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.