You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
784 B
26 lines
784 B
<?php
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Product;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ProductsController extends Controller
|
|
{
|
|
public function search(Request $request)
|
|
{
|
|
$query = $request->get('query');
|
|
$draftType = $request->get('draftType');
|
|
$draftKey = $request->get('draftKey');
|
|
$formToken = $request->get('formToken');
|
|
$queriedProducts = [];
|
|
if ($query) {
|
|
$queriedProducts = Product::where(function ($q) use ($query) {
|
|
$q->where('name', 'like', '%'.$query.'%');
|
|
})->with('unit')->get();
|
|
}
|
|
|
|
return view('cart.partials.product-search-result-box', compact('queriedProducts', 'draftType', 'draftKey', 'formToken'));
|
|
}
|
|
}
|