Commit 93d8203d by Francisco Salazar

return category, relations products-tags

parent 5077bbab
...@@ -36,8 +36,6 @@ class ProductController extends Controller ...@@ -36,8 +36,6 @@ class ProductController extends Controller
$product = Product::where('slug',$slug)->first(); $product = Product::where('slug',$slug)->first();
$otros = $product->category->products()->where('active', true)->inRandomOrder()->take(config("shop.product-show.otros"))->get();
$categories = Category::all(); $categories = Category::all();
if ($product != null) { if ($product != null) {
...@@ -48,6 +46,8 @@ class ProductController extends Controller ...@@ -48,6 +46,8 @@ class ProductController extends Controller
return redirect('no_existe'); return redirect('no_existe');
} }
$otros = $product->category->products()->where('active', true)->where('id', '<>', $product->id)->inRandomOrder()->take(config("shop.product-show.otros"))->get();
return view('shop-public::single') return view('shop-public::single')
->with('product', $product) ->with('product', $product)
->with('categories', $categories) ->with('categories', $categories)
...@@ -67,6 +67,7 @@ class ProductController extends Controller ...@@ -67,6 +67,7 @@ class ProductController extends Controller
$categories = Category::where('active', true)->get(); $categories = Category::where('active', true)->get();
return view('shop-public::list') return view('shop-public::list')
->with('category', $category)
->with('categories', $categories) ->with('categories', $categories)
->with('otros', $otros) ->with('otros', $otros)
->with('products', $products); ->with('products', $products);
......
...@@ -9,7 +9,7 @@ class ProductTag extends Model ...@@ -9,7 +9,7 @@ class ProductTag extends Model
protected $table = 'product_tags'; protected $table = 'product_tags';
protected $fillable = ["description"]; protected $fillable = ["description"];
public function tags(){ public function products(){
return $this->belongsToMany('Onestartup\Shop\Model\ProductShop', 'product_product_tags', 'tag_id', 'product_id'); return $this->belongsToMany('Onestartup\Shop\Model\ProductShop', 'product_product_tags', 'tag_id', 'product_id');
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment