This commit is contained in:
baodev0
2026-07-06 08:16:06 +07:00
parent 9a16a5c313
commit 61fc870c03
2 changed files with 8 additions and 3 deletions
@@ -18,7 +18,7 @@ class WebDesignQuoteController extends Controller
{ {
$perPage = min((int) $request->get('per_page', 15), 100); $perPage = min((int) $request->get('per_page', 15), 100);
$query = WebDesignQuote::with('creator:id,name') $query = WebDesignQuote::with('creator:id,firstname,lastname')
->when($request->get('filter'), fn($q, $f) => ->when($request->get('filter'), fn($q, $f) =>
$q->where(fn($sub) => $sub $q->where(fn($sub) => $sub
->where('quote_number', 'like', "%{$f}%") ->where('quote_number', 'like', "%{$f}%")
@@ -47,7 +47,7 @@ class WebDesignQuoteController extends Controller
public function show(int $id): JsonResponse public function show(int $id): JsonResponse
{ {
$quote = WebDesignQuote::with('creator:id,name')->find($id); $quote = WebDesignQuote::with('creator:id,firstname,lastname')->find($id);
if (!$quote) { if (!$quote) {
return response()->json(['error' => true, 'message' => 'Không tìm thấy báo giá.'], 404); return response()->json(['error' => true, 'message' => 'Không tìm thấy báo giá.'], 404);
@@ -92,7 +92,7 @@ class WebDesignQuoteController extends Controller
return response()->json([ return response()->json([
'error' => false, 'error' => false,
'message' => 'Cập nhật báo giá thành công.', 'message' => 'Cập nhật báo giá thành công.',
'data' => $quote->fresh('creator:id,name'), 'data' => $quote->fresh('creator:id,firstname,lastname'),
]); ]);
} }
+5
View File
@@ -63,6 +63,11 @@ class User extends Authenticatable implements JWTSubject
return []; return [];
} }
public function getNameAttribute(): string
{
return trim($this->firstname . ' ' . $this->lastname);
}
public function staffOnline() public function staffOnline()
{ {
return $this->hasOne(\App\Models\Staff::class, 'user_id', 'id'); return $this->hasOne(\App\Models\Staff::class, 'user_id', 'id');