master
cody 4 months ago
parent 5deeebf777
commit 1a66408608

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

@ -17,6 +17,7 @@ class SupplyDemand extends SoftDeletesModel
if (empty($this->file_ids)) return [];
return Upload::whereIn('id', $this->file_ids)->get();
}
public function user()
{
return $this->hasOne(User::class, 'id', 'user_id');
@ -27,5 +28,11 @@ class SupplyDemand extends SoftDeletesModel
return $this->hasMany(SupplyDemandKeep::class, 'supply_demand_id', 'id');
}
public function messages()
{
return $this->hasMany(Message::class, 'supply_demand_id', 'id');
}
}

Loading…
Cancel
Save