feat: 需求列表完善
parent
b292dc74f1
commit
4bafdb2687
|
@ -32,7 +32,7 @@ class Demand extends Api
|
|||
|
||||
$count = thisModel::where($where)->count();
|
||||
|
||||
$list = thisModel::field(['id', 'name', 'create_time'])
|
||||
$list = thisModel::withCount(['reports'])->field(['id', 'name', 'create_time'])
|
||||
->where($where)
|
||||
->order($order)
|
||||
->page($page,$limit)
|
||||
|
@ -54,7 +54,7 @@ class Demand extends Api
|
|||
public function detail()
|
||||
{
|
||||
$id = input('id/d', 0);
|
||||
if (!$item = thisModel::where('id', $id)->find()) {
|
||||
if (!$item = thisModel::withCount(['reports'])->where('id', $id)->find()) {
|
||||
return JsonServer::error('记录不存在');
|
||||
}
|
||||
return JsonServer::success('获取成功', $item->toArray());
|
||||
|
|
|
@ -5,5 +5,8 @@ use app\common\basics\Models;
|
|||
|
||||
class Demand extends Models
|
||||
{
|
||||
|
||||
public function reports()
|
||||
{
|
||||
return $this->hasMany(DemandReport::class, 'demand_id', 'id');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue