Commit c264bcf6 by Angel MAS

categorias con sus urls

parent 077f60f2
...@@ -57,4 +57,22 @@ class ProductController extends Controller ...@@ -57,4 +57,22 @@ class ProductController extends Controller
} }
public function shoByCategory($slug)
{
$category = Category::where('active', true)
->where('slug', $slug)
->first();
$products = $category->products()->where('active', true)->paginate(15);
$otros = Product::where('active', true)->inRandomOrder()->take(15)->get();
$categories = Category::where('active', true)->get();
return view('shop-public::list')
->with('categories', $categories)
->with('otros', $otros)
->with('products', $products);
}
} }
...@@ -99,9 +99,13 @@ Route::group(['middleware' => ['web']], function(){ ...@@ -99,9 +99,13 @@ Route::group(['middleware' => ['web']], function(){
->name('cart.update'); ->name('cart.update');
Route::get('producto/{slug}', 'Onestartup\Shop\Controller\ProductController@show')->name('show.shop'); Route::get(env('SLUG_SHOP').'/{slug}', 'Onestartup\Shop\Controller\ProductController@show')->name('show.shop');
Route::get('shop', 'Onestartup\Shop\Controller\ProductController@index')->name('main.shop'); Route::get(env('SLUG_SHOP'), 'Onestartup\Shop\Controller\ProductController@index')->name('main.shop');
//Route::get('cart/{product_id}')
Route::get(env('SLUG_SHOP').'/'.env('SLUG_SHOP_CATEGORY').'/{slug_category}',
'Onestartup\Shop\Controller\ProductController@shoByCategory')
->name('category.shop');
Route::post('cart/paymentPaypal', 'Onestartup\Shop\Controller\CartController@paymentPaypal')->name('cart.paymentPaypal'); Route::post('cart/paymentPaypal', 'Onestartup\Shop\Controller\CartController@paymentPaypal')->name('cart.paymentPaypal');
Route::get('cart/successPaypal', 'Onestartup\Shop\Controller\CartController@successPaypal')->name('cart.successPaypal'); Route::get('cart/successPaypal', 'Onestartup\Shop\Controller\CartController@successPaypal')->name('cart.successPaypal');
......
...@@ -27,9 +27,13 @@ ...@@ -27,9 +27,13 @@
<a href="{{route('show.shop', $product->slug)}}">Ver mas informacion</a> <a href="{{route('show.shop', $product->slug)}}">Ver mas informacion</a>
</p> </p>
</div> </div>
<div>
<a href="{{route('category.shop', $product->category->slug)}}">Enlace categoria</a>
</div>
</div> </div>
@endforeach @endforeach
</div> </div>
@endsection @endsection
\ No newline at end of file
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