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);
$query = WebDesignQuote::with('creator:id,name')
$query = WebDesignQuote::with('creator:id,firstname,lastname')
->when($request->get('filter'), fn($q, $f) =>
$q->where(fn($sub) => $sub
->where('quote_number', 'like', "%{$f}%")
@@ -47,7 +47,7 @@ class WebDesignQuoteController extends Controller
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) {
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([
'error' => false,
'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 [];
}
public function getNameAttribute(): string
{
return trim($this->firstname . ' ' . $this->lastname);
}
public function staffOnline()
{
return $this->hasOne(\App\Models\Staff::class, 'user_id', 'id');