首页 > 解决方案 > 从laravel中的一句话中取一个词?

问题描述

$text="Samsung Galaxy s21 ";
$product=  Product::Select('*')->where('name', 'like', "%{$text}%")->get();

我如何获得Galaxy 相关产品表格$product

标签: phplaravellaravel-8

解决方案


$product= Product::where('name', 'like', '%' . $text . '%')->get();

或者

$product= Product::where('name', 'like', "%$text%")->get();

你可以这样做。从这个线程得到它, Laravel-5 'LIKE' 等效(雄辩)


推荐阅读