Commit 2476456f by Francisco Salazar

readme, config file, validacion en public views

parent 934c04cf
......@@ -43,6 +43,12 @@ public function productsShop()
php artisan vendor:publish --provider="Onestartup\Shop\ShopServiceProvider"
```
- run command for publish config file
```php
php artisan vendor:publish --tag=config
```
- run serv
```php
......
......@@ -36,6 +36,10 @@ class ShopServiceProvider extends ServiceProvider
__DIR__.'/assets' => public_path('vendor/onestartup/shop'),
], 'public');
$this->publishes([
__DIR__.'/config/shop.php' => config_path('shop.php'),
], 'config');
}
......@@ -53,5 +57,7 @@ class ShopServiceProvider extends ServiceProvider
$this->app->make('Onestartup\Shop\Controller\CartController');
$this->app->make('Onestartup\Shop\Controller\ShippingPriceController');
$this->app->make('Onestartup\Shop\Controller\ExtraFieldController');
$this->mergeConfigFrom( __DIR__.'/config/shop.php', 'shop');
}
}
<?php
return [
"slug-shop" => "tienda",
"slug-shop-category" => "categoria",
"product-index" => [
"pagination" => 15,
"otros" => 3
],
"product-show" => [
"otros" => 3
],
"product-by-category" => [
"pagination" => 15,
"otros" => 3
],
];
\ No newline at end of file
......@@ -16,12 +16,12 @@ class ProductController extends Controller
if(isset($request->category)){
$category = Category::where('slug', $request->category)->first();
$products = $category->products()->where('active', true)->paginate(15);
$products = $category->products()->where('active', true)->paginate(config("shop.product-index.pagination"));
} else {
$products = Product::where('active', true)->paginate(15);
$products = Product::where('active', true)->paginate(config("shop.product-index.pagination"));
}
$otros = Product::where('active', true)->inRandomOrder()->take(15)->get();
$otros = Product::where('active', true)->inRandomOrder()->take(config("shop.product-index.otros"))->get();
$categories = Category::where('active', true)->get();
return view('shop-public::list')
......@@ -36,7 +36,7 @@ class ProductController extends Controller
$product = Product::where('slug',$slug)->first();
$otros = $product->category->products()->where('active', true)->take(3)->get();
$otros = $product->category->products()->where('active', true)->inRandomOrder()->take(config("shop.product-show.otros"))->get();
$categories = Category::all();
......@@ -48,8 +48,6 @@ class ProductController extends Controller
return redirect('no_existe');
}
return view('shop-public::single')
->with('product', $product)
->with('categories', $categories)
......@@ -63,9 +61,9 @@ class ProductController extends Controller
->where('slug', $slug)
->first();
$products = $category->products()->where('active', true)->paginate(15);
$products = $category->products()->where('active', true)->paginate(config("shop.product-by-category.pagination"));
$otros = Product::where('active', true)->inRandomOrder()->take(15)->get();
$otros = Product::where('active', true)->inRandomOrder()->take(config("shop.product-by-category.otros"))->get();
$categories = Category::where('active', true)->get();
return view('shop-public::list')
......
......@@ -138,10 +138,10 @@ Route::group(['middleware' => ['web']], function(){
->name('cart.update');
Route::get(env('SLUG_SHOP').'/{slug}', 'Onestartup\Shop\Controller\ProductController@show')->name('show.shop');
Route::get(env('SLUG_SHOP'), 'Onestartup\Shop\Controller\ProductController@index')->name('main.shop');
Route::get(config("shop.slug-shop").'/{slug}', 'Onestartup\Shop\Controller\ProductController@show')->name('show.shop');
Route::get(config("shop.slug-shop"), 'Onestartup\Shop\Controller\ProductController@index')->name('main.shop');
Route::get(env('SLUG_SHOP').'/'.env('SLUG_SHOP_CATEGORY').'/{slug_category}',
Route::get(config("shop.slug-shop").'/'.config("shop.slug-shop-category").'/{slug_category}',
'Onestartup\Shop\Controller\ProductController@shoByCategory')
->name('category.shop');
......
......@@ -18,7 +18,7 @@
<div style="width: 150px; margin: 5px; float: left;">
<img src="{{asset('storage/'.$product->cover)}}" width="100%" alt="Imagen no disponible">
<h4>{{$product->name}}</h4>
<h4>Precio: {{money_format('%(#10n', $product->infoSale->sale_price)}}</h4>
<h4>Precio: {{is_null($product->infoSale) ? "N/A" : money_format('%(#10n', $product->infoSale->sale_price)}}</h4>
<div>
<p>
<a href="{{route('cart.add', $product->slug)}}">Agregar al carrito</a>
......
......@@ -17,7 +17,7 @@
<div style="width: 150px; margin: 5px; float: left;">
<img src="{{asset('storage/'.$product->cover)}}" width="100%" alt="Imagen no disponible">
<h4>{{$product->name}}</h4>
<h4>Precio: {{money_format('%(#10n', $product->infoSale->sale_price)}}</h4>
<h4>Precio: {{is_null($product->infoSale) ? "N/A" : money_format('%(#10n', $product->infoSale->sale_price)}}</h4>
<div>
<p>
<a href="{{route('cart.add', $product->slug)}}">Agregar al carrito</a>
......
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