Home > Blockchain >  sql to orm LARAVEL
sql to orm LARAVEL

Time:08-24

How are you? I have one question for you. How will be code in ORM Laravel this sql query

SELECT * FROM `products` WHERE category LIKE 'Laptops';

CodePudding user response:

U should really read Laravel Docs

It is MVC framework so assuming u have model products with category for each product u use something like

Products::where('category', 'LIKE', "%Laptops%")->get();

CodePudding user response:

You can do like this:

Product::where('category', 'LIKE',$variable)->get();

  • Related