Commit 75593d2c by Angel MAS

vista de categorias

parent 5046b78a
......@@ -56,4 +56,19 @@ class ProductController extends Controller
}
public function byCategory($category_slug)
{
$category = Category::where('slug', $category_slug)->first();
$products = $category->products()->where('active', true)->paginate(15);
$otros = Product::where('active', true)->inRandomOrder()->take(3)->get();
$categories = Category::where('active', true)->get();
return view('product-public::category')
->with('categories', $categories)
->with('otros', $otros)
->with('products', $products);
}
}
......@@ -27,8 +27,6 @@ class RequestProduct extends FormRequest
'name' => 'required|max:355',
'slug' => 'required|max:455',
'description'=> 'required',
'specifications' => 'required',
'features' => 'required',
'active' => 'required|boolean',
'publication_date' => 'required',
'extra1' => 'max:455',
......
......@@ -27,4 +27,7 @@ Route::group(['middleware' => ['web', 'auth', 'is_admin']], function(){
Route::group(['middleware' => ['web']], function(){
Route::get(env('SLUG_PRODUCTS').'/{slug}', 'Onestartup\Product\Controller\ProductController@show')->name('show.product');
Route::get(env('SLUG_PRODUCTS'), 'Onestartup\Product\Controller\ProductController@index')->name('main.product');
Route::get(env('SLUG_PRODUCTS_CATEGORY').'/{slug_category}',
'Onestartup\Product\Controller\ProductController@byCategory')
->name('category.product');
});
......@@ -169,14 +169,14 @@
</div>
<div class="col-md-6">
{!! Form::label('features', 'Características', ['class'=>'control-label'])!!}
{!! Form::textarea('features', null, ["class"=>"form-control", "required"=>"required", 'id'=>'body', 'rows'=>"30", 'cols'=>"80"]) !!}
{!! Form::textarea('features', null, ["class"=>"form-control", 'id'=>'body', 'rows'=>"30", 'cols'=>"80"]) !!}
</div>
</div>
<div class="row">
<div class="col-md-6">
{!! Form::label('specifications', 'Información adicional', ['class'=>'control-label'])!!}
{!! Form::textarea('specifications', null, ["class"=>"form-control", "required"=>"required", 'id'=>'body', 'rows'=>"30", 'cols'=>"80"]) !!}
{!! Form::textarea('specifications', null, ["class"=>"form-control", 'id'=>'body', 'rows'=>"30", 'cols'=>"80"]) !!}
</div>
</div>
......
@extends('product-public::layout')
@section('content')
Listado de entradas
<p>
Categorias:
{{$categories}}
</p>
<p>
Productos todas
{{$products}}
</p>
<p>
Productos al azar
{{$otros}}
</p>
<p>
Paginacion:
{!! $products->links() !!}
</p>
@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