Php 在什么时候,如何才能在laravel中获得有说服力的积极关系
嗨,我有一个when-elount子句,我只想选择具有折扣活动关系的属性,因此我的代码如下所示:Php 在什么时候,如何才能在laravel中获得有说服力的积极关系,php,laravel,eloquent,eloquent-relationship,Php,Laravel,Eloquent,Eloquent Relationship,嗨,我有一个when-elount子句,我只想选择具有折扣活动关系的属性,因此我的代码如下所示: ->when($has_discount, function ($query, $has_discount) { $query->with([ 'accommodationRoomsLimited' => function ($q) use ($has_discount) { $q-&g
->when($has_discount, function ($query, $has_discount) {
$query->with([
'accommodationRoomsLimited' => function ($q) use ($has_discount) {
$q->has('discount');
}
]);
我会去我的酒店,然后在里面,我选择房间,我想选择与房间折扣有积极关系的酒店,但是这个代码现在对我没有任何帮助,我如何才能实现???设置条件的closer功能 那样
$query->with([
'accommodationRoomsLimited' => function ($q) use ($has_discount) {
$q->where('discount', 'active');
}
]);
没有模型名或表名如何导出解决方案@法沙德