本文整理汇总了PHP中app\Product::comments方法的典型用法代码示例。如果您正苦于以下问题:PHP Product::comments方法的具体用法?PHP Product::comments怎么用?PHP Product::comments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Product
的用法示例。
在下文中一共展示了Product::comments方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: product
public function product(Shop $shop, Product $product, Request $request)
{
$user = Auth::user();
$product->comments()->create(['user_id' => $user->id, 'body' => $request->input('body')]);
$product->update(['num_comment' => $product->comments()->count()]);
Flash::success('comment Added');
return redirect()->back();
}
示例2: get_product_data
public function get_product_data(Product $product)
{
$product->views += 1;
$product->rating += 0.2;
$product->save();
$product->author;
$classes = array();
foreach ($product->author->registers as $register) {
$register->studyClass->course;
$classes[] = $register->studyClass;
}
if ($product->category != null) {
$product->category_name = $product->category->name;
$product->category_url = url('category?cat_id=' . $product->category->id);
}
if ($product->type == 2 || $product->type == 3) {
$product->share_url = url('post/colormevn-' . convert_vi_to_en($product->description) . '?id=' . $product->id);
}
$product->parsed_tags = view('components.tag', ['current_product' => $product])->render();
$product->classes = $classes;
$product->remain_time = time_elapsed_string(strtotime($product->created_at));
$product->author->email_name = get_first_part_of_email($product->author->email);
$product->total_likes = $product->likes()->count();
$product->total_comments = $product->comments()->count();
if ($product->type == 3) {
$product->items = '';
foreach ($product->images as $image) {
if ($image->type == 0) {
$product->items .= "<img src='{$image->url}'style='width: 100%' />";
} else {
$product->items .= "\n <video full=\"{$image->url}\" class=\"responsive-video\"\n controls preload='metadata'>\n <source src=\"{$product->url}\" type=\"video/mp4\">\n </video>\n ";
}
}
}
return $product;
}