master
cody 4 months ago
parent ccc75c79ea
commit 3574e0efda

@ -271,7 +271,9 @@ class SupplyDemandController extends BaseController
// 当期供需发布分页 // 当期供需发布分页
$list = SupplyDemand::with(['user', 'dialogues' => function ($query) { $list = SupplyDemand::with(['user', 'dialogues' => function ($query) {
$query->with('user', 'toUser')->limit(2)->orderBy('created_at', 'desc'); $query->with(['user', 'toUser', 'messages' => function ($q) {
$q->orderBy('created_at', 'desc');
}])->limit(2)->orderBy('created_at', 'desc');
}])->where(function ($query) use ($type) { }])->where(function ($query) use ($type) {
if ($type) { if ($type) {
$query->where('type', $type); $query->where('type', $type);

@ -15,8 +15,14 @@ class Dialogue extends SoftDeletesModel
return $this->hasOne(User::class, 'id', 'to_user_id'); return $this->hasOne(User::class, 'id', 'to_user_id');
} }
public function supplyDemand(){ public function supplyDemand()
{
return $this->hasOne(SupplyDemand::class, 'id', 'supply_demand_id'); return $this->hasOne(SupplyDemand::class, 'id', 'supply_demand_id');
} }
public function messages()
{
return $this->hasMany(Message::class, 'dialogue_id', 'id');
}
} }

Loading…
Cancel
Save