whoami7 - Manager
:
/
home
/
n170823s
/
.trash
/
app
/
Http
/
Controllers
/
Upload File:
files >> /home/n170823s/.trash/app/Http/Controllers/ProductController.php
<?php namespace App\Http\Controllers; use App\Models\Product; use App\Models\Category; class ProductController extends Controller { public function shop() { $products = Product::with(['variants', 'category']) ->where('is_public', 1) ->paginate(12); return view('product-list', compact('products')); } public function categoryProducts($slug) { $category = Category::where('slug', $slug)->firstOrFail(); $products = Product::with(['variants', 'category']) ->where('category_id', $category->id) ->where('is_public', 1) ->paginate(12); return view('product-list', compact('products', 'category')); } public function productDetail($slug) { $product = Product::with(['variants', 'category']) ->where('slug', $slug) ->where('is_public', 1) ->firstOrFail(); $relatedProducts = Product::with(['variants']) ->where('category_id', $product->category_id) ->where('id', '!=', $product->id) ->where('is_public', 1) ->limit(5) ->get(); return view('product-detail', compact('product', 'relatedProducts')); } }
Copyright ©2021 || Defacer Indonesia