Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
onestartup-shop
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Angel Martin
onestartup-shop
Commits
2476456f
Commit
2476456f
authored
Jul 30, 2018
by
Francisco Salazar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
readme, config file, validacion en public views
parent
934c04cf
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
41 additions
and
13 deletions
+41
-13
README.md
README.md
+6
-0
ShopServiceProvider.php
src/ShopServiceProvider.php
+6
-0
shop.php
src/config/shop.php
+18
-0
ProductController.php
src/controllers/ProductController.php
+6
-8
routes.php
src/routes.php
+3
-3
list.blade.php
src/views/public/list.blade.php
+1
-1
single.blade.php
src/views/public/single.blade.php
+1
-1
No files found.
README.md
View file @
2476456f
...
...
@@ -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
...
...
src/ShopServiceProvider.php
View file @
2476456f
...
...
@@ -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'
);
}
}
src/config/shop.php
0 → 100644
View file @
2476456f
<?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
src/controllers/ProductController.php
View file @
2476456f
...
...
@@ -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'
)
...
...
src/routes.php
View file @
2476456f
...
...
@@ -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'
);
...
...
src/views/public/list.blade.php
View file @
2476456f
...
...
@@ -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
>
...
...
src/views/public/single.blade.php
View file @
2476456f
...
...
@@ -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
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment