<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class SerialNumberController extends Controller
{
    public function search(Request $request)
{
    $serial = $request->input('serial_number');
    $result = \App\SerialNumber::with('purchaseLine')
                ->where('serial_number', $serial)
                ->first();

    if ($result) {
        return response()->json(['success' => true, 'data' => $result]);
    } else {
        return response()->json(['success' => false, 'msg' => 'Serial number not found.']);
    }
}

}
