Files
yuezi-saas/backend/app/Http/Controllers/Client/NannyController.php
T

57 lines
1.3 KiB
PHP

<?php
namespace App\Http\Controllers\Client;
use App\Http\Controllers\Controller;
use App\Models\Crm\Customer;
use App\Models\Nanny\Nanny;
use App\Models\Nanny\NannyOrder;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class NannyController extends Controller
{
/**
* 当前派单月嫂信息
*/
public function myNanny(Request $request): JsonResponse
{
/** @var Customer $customer */
$customer = $request->user();
$order = NannyOrder::withoutGlobalScope('store')
->where('customer_id', $customer->id)
->whereIn('status', [2, 3])
->latest()
->first();
if (!$order) {
return $this->success(null);
}
$order->load('nanny');
return $this->success([
'order' => $order,
'nanny' => $order->nanny,
]);
}
/**
* 月嫂订单列表(分页)
*/
public function orders(Request $request): JsonResponse
{
/** @var Customer $customer */
$customer = $request->user();
$query = NannyOrder::withoutGlobalScope('store')
->where('customer_id', $customer->id)
->with('nanny:id,name,level,phone');
return $this->paginate(
$query->orderByDesc('id')->paginate(15)
);
}
}