本文整理匯總了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]]);
}