I have created a table as follows:
Table 'adjustment' consists of columns: id, adjustment_number, status.
The adjustment table has a relationship called materialloc, and another relationship to sbin.
Then, I crafted a query program like this using Laravel 10.
$query = Adjustment::with('materialloc.sbin'); if ($request->has('search') && $request->input('search')) { $searchTerm = $request->input('search'); $query->whereHas('materialloc.sbin', function ($query) use ($searchTerm) { $query->where('name', 'like', '%' . $searchTerm . '%'); }); $query->orWhere('adjustment_number', 'like', '%' . $searchTerm . '%'); } Why doesn't the search using adjustment_number work? However, when I search by name in materialloc.sbin, it works.
Is there something wrong with my use of whereHas, where, or orWhere?