Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
onestartup-shop-ceramica-gtz
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
Francisco Salazar
onestartup-shop-ceramica-gtz
Commits
4dc5f91f
Commit
4dc5f91f
authored
6 years ago
by
Francisco Salazar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sugeridos subcategoria vs subcategoria
parent
a9e92971
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
61 additions
and
13 deletions
+61
-13
shop.php
src/config/shop.php
+2
-2
SubCategoryController.php
src/controllers/SubCategoryController.php
+5
-4
2018_10_18_221930_add_field_related_to_related_products.php
...18_10_18_221930_add_field_related_to_related_products.php
+46
-0
ProductShop.php
src/models/ProductShop.php
+2
-2
ProductSubCategoryShop.php
src/models/ProductSubCategoryShop.php
+1
-1
edit.blade.php
src/views/subcategory/edit.blade.php
+1
-1
fields.blade.php
src/views/subcategory/fields.blade.php
+2
-2
index.blade.php
src/views/subcategory/index.blade.php
+2
-1
No files found.
src/config/shop.php
View file @
4dc5f91f
...
...
@@ -3,8 +3,8 @@ return [
"slug-shop"
=>
"tienda"
,
"billing_enabled"
=>
false
,
"slug-shop-category"
=>
"categoria"
,
"tags-enable"
=>
fals
e
,
"subcategory-enable"
=>
fals
e
,
"tags-enable"
=>
tru
e
,
"subcategory-enable"
=>
tru
e
,
"product-index"
=>
[
"pagination"
=>
15
,
"otros"
=>
3
...
...
This diff is collapsed.
Click to expand it.
src/controllers/SubCategoryController.php
View file @
4dc5f91f
...
...
@@ -20,9 +20,10 @@ class SubCategoryController extends Controller{
return
$subcategories
=
$category
->
subcategories
()
->
get
();
}
$subcategories
=
$category
->
subcategories
()
->
paginate
(
30
);
$related_subcategories
=
SubCategory
::
pluck
(
'name'
,
"id"
);
$products
=
Product
::
pluck
(
'name'
,
'id'
);
return
view
(
"shop::subcategory.index"
)
->
with
(
"
products"
,
$product
s
)
->
with
(
"
related_subcategories"
,
$related_subcategorie
s
)
->
with
(
"subcategories"
,
$subcategories
)
->
with
(
"category"
,
$category
);
}
...
...
@@ -30,10 +31,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'
);
$
related_subcategories
=
SubCategory
::
where
(
"id"
,
"<>"
,
$id
)
->
pluck
(
'name'
,
"id"
);
return
view
(
"shop::subcategory.edit"
)
->
with
(
'products'
,
$product
s
)
->
with
(
"related_subcategories"
,
$related_subcategorie
s
)
->
with
(
"subcategory"
,
$subcategory
)
->
with
(
"category"
,
$category
);
}
...
...
@@ -66,7 +67,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_
product
s
);
$subcategory
->
related_products
()
->
sync
(
$request
->
related_
subcategorie
s
);
if
(
isset
(
$request
->
portada
)
&&
$request
->
portada
!=
null
)
{
...
...
This diff is collapsed.
Click to expand it.
src/migrations/2018_10_18_221930_add_field_related_to_related_products.php
0 → 100644
View file @
4dc5f91f
<?php
use
Illuminate\Support\Facades\Schema
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Database\Migrations\Migration
;
class
AddFieldRelatedToRelatedProducts
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
table
(
'related_products'
,
function
(
Blueprint
$table
)
{
$table
->
dropForeign
([
'product_id'
]);
$table
->
dropColumn
(
'product_id'
);
$table
->
integer
(
'subcategory_related_id'
)
->
unsigned
();
$table
->
foreign
(
'subcategory_related_id'
)
->
references
(
'id'
)
->
on
(
'product_subcategories_shop'
)
->
onDelete
(
'cascade'
);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
table
(
'related_products'
,
function
(
Blueprint
$table
)
{
$table
->
dropForeign
([
'subcategory_related_id'
]);
$table
->
dropColumn
(
'subcategory_related_id'
);
$table
->
integer
(
'product_id'
)
->
unsigned
();
$table
->
foreign
(
'product_id'
)
->
references
(
'id'
)
->
on
(
'products_shop'
)
->
onDelete
(
'cascade'
);
});
}
}
This diff is collapsed.
Click to expand it.
src/models/ProductShop.php
View file @
4dc5f91f
...
...
@@ -68,9 +68,9 @@ class ProductShop extends Model
return
$this
->
belongsToMany
(
'Onestartup\Shop\Model\ProductTag'
,
'product_product_tags'
,
'product_id'
,
'tag_id'
);
}
public
function
subcategories_related
(){
/*
public function subcategories_related(){
return $this->belongsToMany('Onestartup\Shop\Model\ProductSubCategoryShop', 'related_products', 'product_id', 'subcategory_id');
}
}
*/
public
function
details_sale
()
{
...
...
This diff is collapsed.
Click to expand it.
src/models/ProductSubCategoryShop.php
View file @
4dc5f91f
...
...
@@ -26,6 +26,6 @@ class ProductSubCategoryShop extends Model
}
public
function
related_products
(){
return
$this
->
belongsToMany
(
'Onestartup\Shop\Model\ProductS
hop'
,
'related_products'
,
'subcategory_id'
,
'product
_id'
);
return
$this
->
belongsToMany
(
'Onestartup\Shop\Model\ProductS
ubCategoryShop'
,
'related_products'
,
'subcategory_id'
,
'subcategory_related
_id'
);
}
}
This diff is collapsed.
Click to expand it.
src/views/subcategory/edit.blade.php
View file @
4dc5f91f
...
...
@@ -74,6 +74,6 @@
@section('script_extras')
<script>
$('#related_
product
s').select2();
$('#related_
subcategorie
s').select2();
</script>
@endsection
This diff is collapsed.
Click to expand it.
src/views/subcategory/fields.blade.php
View file @
4dc5f91f
...
...
@@ -20,8 +20,8 @@
</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_product
s", "style" => "width: 100%;"]) !!}
{!! Form::label('related_
subcategories', '¿De cual(es) subcategorías seran los productos relacionados de esta subcategoría?
') !!}
{!! Form::select('related_
subcategories[]', $related_subcategories, isset($subcategory->related_products) ? $subcategory->related_products->pluck("id") : null, ["class"=>"form-control", "multiple" => "multiple", "id" => "related_subcategorie
s", "style" => "width: 100%;"]) !!}
</div>
<div
class=
"form-group"
>
...
...
This diff is collapsed.
Click to expand it.
src/views/subcategory/index.blade.php
View file @
4dc5f91f
...
...
@@ -104,6 +104,6 @@
@section('script_extras')
<script>
$('#related_
product
s').select2();
$('#related_
subcategorie
s').select2();
</script>
@endsection
\ No newline at end of file
This diff is collapsed.
Click to expand it.
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