本文整理汇总了PHP中app\Product::recommend方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::recommend方法的具体用法?PHP Product::recommend怎么用?PHP Product::recommend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Product
的用法示例。
在下文中一共展示了Product::recommend方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFavourite
public function getFavourite(Request $request)
{
if (Auth::user()->role == 'admin') {
return redirect('/dashboard');
}
$page = 1;
if ($request->has('page')) {
$page = $request->input('page');
}
$product = new Product();
$productIdlist = Preference::where('user_id', Auth::user()->id)->lists('product_id')->toArray();
$products = $product->recommend($page, $productIdlist);
return view('favourite')->with(['products' => $products[0], 'paginate' => $products[1]]);
}
示例2: getProducts
public function getProducts(Request $request)
{
$attrWt = AttributeWeight::where('user_id', Auth::user()->id)->get();
if (count($attrWt)) {
$firstTimeLogin = "false";
} else {
$firstTimeLogin = "true";
}
$page = 1;
if ($request->has('page')) {
$page = $request->input('page');
}
$products = new Product();
$productArray = $products->recommend($page);
return view('dashboard')->with(['products' => $productArray[0], 'paginate' => $productArray[1], 'firstTimeLogin' => $firstTimeLogin]);
}
示例3: getSearch
public function getSearch(Request $request)
{
$productNameId = $productIds = [];
foreach ($request->all() as $key => $value) {
$products = new Product();
if ($key == 'q') {
$productNameId = $products->where('name', 'like', '%' . $value . '%')->lists('id')->toArray();
if (count($productNameId)) {
$productIds = $productNameId;
}
}
if ($key != 'q' && $value) {
$productId = $products->where('category', '=', $key)->lists('id')->toArray();
if (count($productId)) {
array_merge($productIds, $productId);
}
}
}
if (!count($productIds)) {
$productIds[0] = [-5];
}
$page = 1;
if ($request->has('page')) {
$page = $request->input('page');
}
$product = new Product();
$productArray = $product->recommend($page, $productIds);
return view('search')->with(['products' => $productArray[0], 'paginate' => $productArray[1]]);
}