$order_detail = Order::where([['user_id', $user->id], ['updated_at', '>', $updated_at]])
->with([
'currency' => function ($query) {
$query->select('currency_code', 'currency_symbol', 'ex_rate_with_base');
},
'orderList' => function ($query) {
$query->select('id', 'order_id', 'product_code', 'qty',
DB::raw('(unit_price*orders.ex_rate_with_base) as unit_price_new'), 'status');
},
])->get();
Run Code Online (Sandbox Code Playgroud)
请帮忙,
如何ex_rate_with_base在子查询中使用订单表中的属性。我不想使用DB查询。请雄辩地解决它。
资料夹结构:
应用程式
| -Admin.php
|-管理员
|
| -Product.php
Admin.php
-------------------------------------------------- ------
命名空间应用;
使用Illuminate \ Foundation \ Auth \ User作为Authenticateable;
管理员类扩展了Authenticateable
{
公共功能erp()
{
返回$ this-> belongsToMany(Admin \ Product :: class);
}
}
-------------------------------------------------- ---------
Product.php
-------------------------------------------------- ---------
命名空间App \ Admin;
使用Illuminate \ Database \ Eloquent \ Model;
类产品扩展模型
{
protected $ primaryKey ='产品代码';
public $ incrementing = false;
公共函数updateBy()
{
返回$ this-> belongsTo(Admin :: class);
}
}
-------------------------------------------------- ---------
但是出现错误Class'Admin :: class'找不到任何解决方案?