// routes/api.php
Route::prefix('v1')->group(function () {
Route::apiResource('products', ProductController::class);
});
// ProductResource keeps the JSON shape stable
class ProductResource extends JsonResource
{
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'name' => $this->name,
'price' => (float) $this->price,
'created_at' => $this->created_at->toIso8601String(),
];
}
}
Why it matters: API Resources decouple your database schema from your API contract. Without them, every database change breaks your mobile app. If the candidate says "just return the model as JSON," that's a red flag — it leaks internal fields like password hashes and timestamps you never intended to expose.
// Issue a token on login
$token = $user->createToken('api-token')->plainTextToken;
// Protect routes
Route::middleware('auth:sanctum')->group(function () {
Route::apiResource('products', ProductController::class);
});
// Revoke on logout
$request->user()->currentAccessToken()->delete();Why it matters: A developer who reaches for a hand-rolled token system, or who stores JWT secrets in the codebase, is introducing security debt you will pay for later. Sanctum handles token hashing, abilities, and revocation out of the box. Bonus points if they mention rate limiting on the login endpoint to block brute-force attacks:
Route::middleware('throttle:10,1')->post('/login', [AuthController::class, 'login']);Check 3: The N+1 question — the classic tell
// BAD: one query for products, then one query PER product for its category
$products = Product::all();
foreach ($products as $product) {
echo $product->category->name; // +1 query each loop
}
The fix is one word — eager loading:
// GOOD: two queries total, no matter how many products
$products = Product::with('category')->paginate(20);Why it matters: If a candidate cannot explain N+1 and eager loading, they have never debugged a real production performance problem. This single concept separates developers whose apps scale from developers whose apps fall over at 10,000 rows.
// Controller stays fast
ProcessOrder::dispatch($order);
return response()->json(['message' => 'Order received'], 202);
// The heavy lifting runs in the background
class ProcessOrder implements ShouldQueue
{
public function handle(): void
{
Mail::to($this->order->user)->send(new OrderConfirmation($this->order));
InvoiceService::generate($this->order);
CrmService::sync($this->order);
}
}Why it matters: Developers who do everything synchronously build apps where checkout takes 12 seconds and timeouts multiply under load. Queues are a core Laravel feature — a Laravel API developer who doesn't reach for them is fighting the framework.
{ public function rules(): array { return [ 'name' => 'required|string|max:255', 'price' => 'required|numeric|min:0', 'sku' => 'required|string|unique:products,sku', ]; }}Common pitfall to watch for: candidates who skip the `unique` rule and handle duplicates with try/catch, or who return HTML error pages from API routes. Both signal a developer who hasn't shipped a real API consumed by a frontend team.
public function test_can_create_product(): void
{
$user = User::factory()->create();
$response = $this->actingAs($user)->postJson('/api/v1/products', [
'name' => 'Test Widget',
'price' => 29.99,
'sku' => 'WIDGET-001',
]);
$response->assertCreated();
$this->assertDatabaseHas('products', ['sku' => 'WIDGET-001']);
}Why it matters: Untested Laravel codebases become "don't touch it" codebases within months. Every change risks breaking something invisible. A developer who writes tests is a developer you can safely hire again for phase two.
What a healthy engagement looks like
- Start with a technical spec — endpoints, data model, and acceptance criteria written down before code starts.
- Milestone-based payments tied to working, tested features — never 100% upfront.
- Code in your repository from day one, with pull requests you (or a reviewer) can see.
- A handover document at the end: how to deploy, where secrets live, how to run the test suite.
- A developer who resists any of these is telling you how the engagement will go.