改进 user 字段处理
This commit is contained in:
parent
30ae62b2e6
commit
d9b648d2e4
@ -18,9 +18,7 @@ class ReplyController extends Controller
|
||||
*/
|
||||
public function index(WorkOrder $workOrder)
|
||||
{
|
||||
$replies = Reply::workOrderId($workOrder->id)->with(['module'])->with(['user' => function ($query) {
|
||||
$query->select('id', 'name', 'email');
|
||||
}])->simplePaginate(10);
|
||||
$replies = Reply::workOrderId($workOrder->id)->with('module')->withUser()->simplePaginate(20);
|
||||
|
||||
return $this->success($replies);
|
||||
}
|
||||
|
@ -145,4 +145,11 @@ public function scopeWorkOrderId($query, $work_order_id)
|
||||
{
|
||||
return $query->where('work_order_id', $work_order_id);
|
||||
}
|
||||
|
||||
public function scopeWithUser($query)
|
||||
{
|
||||
return $query->with(['user' => function ($query) {
|
||||
$query->select('id', 'name', 'email');
|
||||
}]);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user