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
4e939bd5
Commit
4e939bd5
authored
Oct 02, 2018
by
Angel MAS
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of bunkrbit.com:bsabbath/onestartup-shop
parents
b9083438
17cb5a0c
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
165 additions
and
34 deletions
+165
-34
shop.php
src/config/shop.php
+3
-0
CartController.php
src/controllers/CartController.php
+2
-2
SubCategoryController.php
src/controllers/SubCategoryController.php
+9
-1
2018_09_20_004720_create_related_products_table.php
...tions/2018_09_20_004720_create_related_products_table.php
+44
-0
ProductShop.php
src/models/ProductShop.php
+10
-0
ProductSubCategoryShop.php
src/models/ProductSubCategoryShop.php
+4
-0
RelatedProducts.php
src/models/RelatedProducts.php
+19
-0
fields.blade.php
src/views/category/fields.blade.php
+6
-6
index.blade.php
src/views/category/index.blade.php
+12
-6
fields.blade.php
src/views/product/fields.blade.php
+30
-15
index.blade.php
src/views/product/index.blade.php
+7
-3
edit.blade.php
src/views/subcategory/edit.blade.php
+7
-1
fields.blade.php
src/views/subcategory/fields.blade.php
+5
-0
index.blade.php
src/views/subcategory/index.blade.php
+7
-0
No files found.
src/config/shop.php
View file @
4e939bd5
...
...
@@ -3,6 +3,9 @@ return [
"slug-shop"
=>
"tienda"
,
"billing_enabled"
=>
false
,
"slug-shop-category"
=>
"categoria"
,
"tags-enable"
=>
false
,
"subcategory-enable"
=>
false
,
"version-minima-enable"
=>
true
,
"product-index"
=>
[
"pagination"
=>
15
,
"otros"
=>
3
...
...
src/controllers/CartController.php
View file @
4e939bd5
...
...
@@ -95,7 +95,7 @@ public function add(Product $product)
\Session
::
put
(
'cart'
,
$cart
);
return
redirect
()
->
route
(
'cart.show'
);
return
redirect
()
->
back
(
);
}
...
...
@@ -186,7 +186,7 @@ public function shipping()
->
with
(
'shipping'
,
$shipping
);
}
public
function
storeClient
(
Request
Client
$request
)
public
function
storeClient
(
Client
$request
)
{
$client
=
new
Client
();
$addres
=
new
Addres
();
...
...
src/controllers/SubCategoryController.php
View file @
4e939bd5
...
...
@@ -7,6 +7,8 @@ use App\Http\Controllers\Controller;
use
Onestartup\Shop\Model\ProductCategoryShop
as
Category
;
use
Onestartup\Shop\Model\ProductSubCategoryShop
as
SubCategory
;
use
Onestartup\Shop\Model\ProductShop
as
Product
;
use
Onestartup\Shop\Requests\RequestSubCategory
;
...
...
@@ -18,8 +20,9 @@ class SubCategoryController extends Controller{
return
$subcategories
=
$category
->
subcategories
()
->
get
();
}
$subcategories
=
$category
->
subcategories
()
->
paginate
(
30
);
$products
=
Product
::
pluck
(
'name'
,
'id'
);
return
view
(
"shop::subcategory.index"
)
->
with
(
"products"
,
$products
)
->
with
(
"subcategories"
,
$subcategories
)
->
with
(
"category"
,
$category
);
}
...
...
@@ -27,8 +30,10 @@ class SubCategoryController extends Controller{
public
function
edit
(
$category_id
,
$id
){
$category
=
Category
::
find
(
$category_id
);
$subcategory
=
SubCategory
::
where
(
"category_id"
,
$category_id
)
->
find
(
$id
);
$products
=
Product
::
pluck
(
'name'
,
'id'
);
return
view
(
"shop::subcategory.edit"
)
->
with
(
'products'
,
$products
)
->
with
(
"subcategory"
,
$subcategory
)
->
with
(
"category"
,
$category
);
}
...
...
@@ -37,6 +42,8 @@ class SubCategoryController extends Controller{
$subcategory
=
new
SubCategory
(
$request
->
all
());
$subcategory
->
category_id
=
$category_id
;
$subcategory
->
save
();
$subcategory
->
related_products
()
->
sync
(
$request
->
related_products
);
if
(
isset
(
$request
->
portada
))
{
$file
=
$request
->
file
(
'portada'
);
...
...
@@ -59,6 +66,7 @@ class SubCategoryController extends Controller{
$subcategory
=
SubCategory
::
where
(
"category_id"
,
$category_id
)
->
find
(
$id
);
$subcategory
->
fill
(
$request
->
all
());
$subcategory
->
save
();
$subcategory
->
related_products
()
->
sync
(
$request
->
related_products
);
if
(
isset
(
$request
->
portada
)
&&
$request
->
portada
!=
null
)
{
...
...
src/migrations/2018_09_20_004720_create_related_products_table.php
0 → 100644
View file @
4e939bd5
<?php
use
Illuminate\Support\Facades\Schema
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Database\Migrations\Migration
;
class
CreateRelatedProductsTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'related_products'
,
function
(
Blueprint
$table
)
{
$table
->
increments
(
'id'
);
$table
->
integer
(
'product_id'
)
->
unsigned
();
$table
->
foreign
(
'product_id'
)
->
references
(
'id'
)
->
on
(
'products_shop'
)
->
onDelete
(
'cascade'
);
$table
->
integer
(
'subcategory_id'
)
->
unsigned
();
$table
->
foreign
(
'subcategory_id'
)
->
references
(
'id'
)
->
on
(
'product_subcategories_shop'
)
->
onDelete
(
'cascade'
);
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'related_products'
);
}
}
src/models/ProductShop.php
View file @
4e939bd5
...
...
@@ -19,6 +19,7 @@ class ProductShop extends Model
'active'
,
'publication_date'
,
'category_id'
,
'subcategory_id'
,
'category_sat_id'
,
'cover'
,
'extra1'
,
...
...
@@ -66,4 +67,13 @@ class ProductShop extends Model
public
function
tags
(){
return
$this
->
belongsToMany
(
'Onestartup\Shop\Model\ProductTag'
,
'product_product_tags'
,
'product_id'
,
'tag_id'
);
}
public
function
subcategories_related
(){
return
$this
->
belongsToMany
(
'Onestartup\Shop\Model\ProductSubCategoryShop'
,
'related_products'
,
'product_id'
,
'subcategory_id'
);
}
public
function
details_sale
()
{
return
$this
->
hasMany
(
'Onestartup\Shop\Model\DetailShop'
,
'product_id'
);
}
}
src/models/ProductSubCategoryShop.php
View file @
4e939bd5
...
...
@@ -24,4 +24,8 @@ class ProductSubCategoryShop extends Model
public
function
products
(){
return
$this
->
hasMany
(
'Onestartup\Shop\Model\ProductShop'
,
'subcategory_id'
);
}
public
function
related_products
(){
return
$this
->
belongsToMany
(
'Onestartup\Shop\Model\ProductShop'
,
'related_products'
,
'subcategory_id'
,
'product_id'
);
}
}
src/models/RelatedProducts.php
0 → 100644
View file @
4e939bd5
<?php
namespace
Onestartup\Shop\Model
;
use
Illuminate\Database\Eloquent\Model
;
class
RelatedProducts
extends
Model
{
protected
$table
=
'related_products'
;
protected
$fillable
=
[
"product_id"
,
"subcategory_id"
];
public
function
products
(){
return
$this
->
belongsToMany
(
'Onestartup\Shop\Model\ProductShop'
,
'product_id'
);
}
public
function
subcategories
(){
return
$this
->
hasMany
(
'Onestartup\Shop\Model\ProductSubCategoryShop'
,
'subcategory_id'
);
}
}
src/views/category/fields.blade.php
View file @
4e939bd5
...
...
@@ -7,18 +7,17 @@
{!! Form::label('slug', 'URL Slug *') !!}
{!! Form::text('slug', null, ["class"=>"form-control", "required"=>"required", "placeholder"=>"Coloque aquí la liga o URL de la categoría", "id"=>"second"]) !!}
</div>
@if(config("shop.version-minima-enable") == false)
<div
class=
"form-group"
>
{!! Form::label('description', 'Resumen') !!}
{!! Form::text('description', null, ["class"=>"form-control", "placeholder"=>"Coloque la información descriptiva de la categoría"]) !!}
</div>
@endif
<div
class=
"form-group"
>
{!! Form::label('active', 'Estado') !!}
{!! Form::select('active', [true=>'Activo', false=>'Inactivo'], null, ["class"=>"form-control", "required"=>"required"]) !!}
</div>
@if(config("shop.version-minima-enable") == false)
<div
class=
"form-group"
>
{!! Form::label('portada', 'Imagén de portada') !!}
@if (isset($category))
...
...
@@ -31,4 +30,5 @@
@endif
<br>
{!! Form::file('portada', null, ["class"=>"form-control"]) !!}
</div>
\ No newline at end of file
</div>
@endif
\ No newline at end of file
src/views/category/index.blade.php
View file @
4e939bd5
...
...
@@ -58,7 +58,9 @@
<th>Categoría</th>
<th>Descripción</th>
<th>Productos</th>
<th>Subcategorias</th>
@if(config("
shop
.
subcategory
-
enable
"))
<th>Subcategorias</th>
@endif
<th></th>
</tr>
@foreach (
$categories
as
$category
)
...
...
@@ -73,12 +75,16 @@
</td>
<td>
{
{$category->description}
}
</td>
<td class="
text
-
center
">
{
{$category->products->count()}
}
</td>
<td class="
text
-
center
">
{
{$category->subcategories->count()}
}
</td>
@if(config("
shop
.
subcategory
-
enable
"))
<td class="
text
-
center
">
{
{$category->subcategories->count()}
}
</td>
@endif
<td class="
text
-
center
">
<a class='btn btn-xs btn-success button-mb' href="
{{
route
(
'admin.shop.subcategory.index'
,
$category
->
id
)}}
">
<i class='fas fa-plus icon-special-size'></i>
Subcategorías
</a>
@if(config("
shop
.
subcategory
-
enable
"))
<a class='btn btn-xs btn-success button-mb' href="
{{
route
(
'admin.shop.subcategory.index'
,
$category
->
id
)}}
">
<i class='fas fa-plus icon-special-size'></i>
Subcategorías
</a>
@endif
{!! Form::open(['route'=> ['admin.shop.category.destroy',
$category->id
],'method'=>'DELETE'])!!}
<button class='btn btn-danger btn-xs button-mb' onclick="
return
confirm
(
'¿Estás seguro de eliminar este elemento?'
);
" type='submit'>
<i class='fas fa-trash-alt icon-special-size'></i>
...
...
src/views/product/fields.blade.php
View file @
4e939bd5
...
...
@@ -24,8 +24,10 @@
</div>
<div
class=
'col-md-6'
>
<div
class=
"form-group"
>
{!! Form::label('category_id', 'Categoría', ['class'=>'control-label'])!!}
{!! Form::select('category_id', $categories, null, ["class"=>"form-control", "required"=>"required"]) !!}
{!! Form::label('publication_date', 'Fecha de publicación', ['class'=>'control-label'])!!}
{!! Form::text('publication_date', isset($product) ? null: date('Y-m-d'), ["class"=>"form-control", "required"=>"required", "id"=>"publication_date"]) !!}
</div>
</div>
</div>
...
...
@@ -48,25 +50,29 @@
</div>
<div
class=
"col-md-6"
>
<div
class=
"form-group"
>
{!! Form::label('
subcategory_id', 'Subc
ategoría', ['class'=>'control-label'])!!}
{!! Form::select('
subcategory_id', $subcategories, null, ["class"=>"form-control", "placeholder"=>"Selecciona una subcategoría
"]) !!}
{!! Form::label('
category_id', 'C
ategoría', ['class'=>'control-label'])!!}
{!! Form::select('
category_id', $categories, null, ["class"=>"form-control", "required"=>"required
"]) !!}
</div>
</div>
</div>
<div
class=
"row"
>
<div
class=
"col-md-6"
>
<div
class=
"form-group"
>
{!! Form::label('publication_date', 'Fecha de publicación', ['class'=>'control-label'])!!}
{!! Form::text('publication_date', isset($product) ? null: date('Y-m-d'), ["class"=>"form-control", "required"=>"required", "id"=>"publication_date"]) !!}
@if(config("shop.tags-enable"))
<div
class=
"col-md-6"
>
<div
class=
"form-group"
>
{!! Form::label('tags', 'Etiquetas', ['class'=>'control-label'])!!}
{!! Form::select('tags[]', $tags, null, ["class"=>"form-control", "id"=>"tags", "multiple"=>"multiple"]) !!}
</div>
</div>
</div>
<div
class=
"col-md-6"
>
<div
class=
"form-group"
>
{!! Form::label('tags', 'Etiquetas', ['class'=>'control-label'])!!}
{!! Form::select('tags[]', $tags, null, ["class"=>"form-control", "id"=>"tags", "multiple"=>"multiple"]) !!}
@endif
@if(config("shop.subcategory-enable"))
<div
class=
"col-md-6"
>
<div
class=
"form-group"
>
{!! Form::label('subcategory_id', 'Subcategoría', ['class'=>'control-label'])!!}
{!! Form::select('subcategory_id', $subcategories, null, ["class"=>"form-control", "placeholder"=>"Selecciona una subcategoría"]) !!}
</div>
</div>
</div>
@endif
</div>
...
...
@@ -116,7 +122,7 @@
@endif
</div>
@if(config("shop.version-minima-enable") == false)
<div
class=
"row"
>
<div
class=
"col-md-6"
>
{!! Form::label('description', 'Descripción', ['class'=>'control-label'])!!}
...
...
@@ -134,5 +140,14 @@
{!! Form::textarea('specifications', null, ["class"=>"form-control", "required"=>"required", 'id'=>'body', 'rows'=>"30", 'cols'=>"80"]) !!}
</div>
</div>
@endif
@if(config("shop.version-minima-enable"))
<div
class=
"row"
>
<div
class=
"col-md-12"
>
{!! Form::label('description', 'Descripción', ['class'=>'control-label'])!!}
{!! Form::textarea('description', null, ["class"=>"form-control", "required"=>"required", 'id'=>'body', 'rows'=>"30", 'cols'=>"80"]) !!}
</div>
</div>
@endif
src/views/product/index.blade.php
View file @
4e939bd5
...
...
@@ -32,8 +32,10 @@
<th>#</th>
<th>Producto</th>
<th>Descripción</th>
<th>Características</th>
<th>Especificaciones</th>
@if(config("
shop
.
version
-
minima
-
enable
") == false)
<th>Características</th>
<th>Especificaciones</th>
@endif
<th></th>
</tr>
</thead>
...
...
@@ -56,8 +58,10 @@
{data: 'id', name: 'id'},
{data: 'main', name: 'main'},
{data: 'description', name: 'description'},
{data: 'features', name: 'features'},
@if(config("
shop
.
version
-
minima
-
enable
") == false)
{data: 'features', name: 'features'},
{data: 'specifications', name: 'specifications'},
@endif
{data: 'form', name: 'form'},
]
});
...
...
src/views/subcategory/edit.blade.php
View file @
4e939bd5
...
...
@@ -35,7 +35,7 @@
</div>
<div class='dker p-a text-right'>
<div class='col-md-12'>
<a class='btn danger' href="
{{
route
(
'admin.
product
.subcategory.index'
,
$category
->
id
)}}
">Cancelar</a>
<a class='btn danger' href="
{{
route
(
'admin.
shop
.subcategory.index'
,
$category
->
id
)}}
">Cancelar</a>
{!! Form::submit('Actualizar información', ['class'=>'btn dark']) !!}
{!! Form::close() !!}
</div>
...
...
@@ -71,3 +71,9 @@
</div>
</div>
@endsection
@section('script_extras')
<script>
$('#related_products').select2();
</script>
@endsection
src/views/subcategory/fields.blade.php
View file @
4e939bd5
...
...
@@ -20,6 +20,11 @@
</div>
<div
class=
"form-group"
>
{!! Form::label('related_products', 'Productos relacionados') !!}
{!! Form::select('related_products[]', $products, null, ["class"=>"form-control", "required"=>"required", "multiple" => "multiple", "id" => "related_products", "style" => "width: 100%;"]) !!}
</div>
<div
class=
"form-group"
>
{!! Form::label('portada', 'Imagén de portada') !!}
@if (isset($subcategory))
<span>
...
...
src/views/subcategory/index.blade.php
View file @
4e939bd5
...
...
@@ -100,4 +100,10 @@
</div>
</div>
</div>
@endsection
@section('script_extras')
<script>
$('#related_products').select2();
</script>
@endsection
\ No newline at end of file
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