Question and answer is powered by AnsPress.io
Hello sir, I am new to start Laravel and I have faced a problem. I have tables in MySQL and I want to get result with relation and where clause:
Apply this code, I think it will be helpful for you.
public function getRecords(Request $request)
{
return Category::where(‘id’, ‘like’, ‘%’ . $request->category_id . ‘%’)->
->with(‘products’)
->get();
}