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
c0ef4387
Commit
c0ef4387
authored
Jul 17, 2018
by
Francisco Salazar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
validate slug, validate images
parent
0eeead57
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
54 additions
and
18 deletions
+54
-18
AdminProductController.php
src/controllers/AdminProductController.php
+3
-5
RequestCategory.php
src/requests/RequestCategory.php
+9
-2
RequestGallery.php
src/requests/RequestGallery.php
+32
-0
RequestProduct.php
src/requests/RequestProduct.php
+6
-1
edit.blade.php
src/views/category/edit.blade.php
+1
-1
edit.blade.php
src/views/product/edit.blade.php
+3
-9
No files found.
src/controllers/AdminProductController.php
View file @
c0ef4387
...
@@ -23,8 +23,9 @@ use Onestartup\Shop\Libs\Util;
...
@@ -23,8 +23,9 @@ use Onestartup\Shop\Libs\Util;
use
Onestartup\Shop\Requests\RequestProduct
;
use
Onestartup\Shop\Requests\RequestProduct
;
use
Onestartup\Shop\Requests\RequestProductInfo
;
use
Onestartup\Shop\Requests\RequestProductInfo
;
use
Onestartup\Shop\
Payment\MP
;
use
Onestartup\Shop\
Requests\RequestGallery
;
use
Onestartup\Shop\Payment\MP
;
use
PayPal\Api\Amount
;
use
PayPal\Api\Amount
;
use
PayPal\Api\Refund
;
use
PayPal\Api\Refund
;
use
PayPal\Api\Sale
as
SalePaypal
;
use
PayPal\Api\Sale
as
SalePaypal
;
...
@@ -201,7 +202,7 @@ class AdminProductController extends Controller
...
@@ -201,7 +202,7 @@ class AdminProductController extends Controller
}
}
public
function
storeGallery
(
Request
$request
,
$product_id
)
public
function
storeGallery
(
Request
Gallery
$request
,
$product_id
)
{
{
$product
=
Product
::
find
(
$product_id
);
$product
=
Product
::
find
(
$product_id
);
...
@@ -248,10 +249,7 @@ class AdminProductController extends Controller
...
@@ -248,10 +249,7 @@ class AdminProductController extends Controller
$product
->
cover
=
null
;
$product
->
cover
=
null
;
$product
->
save
();
$product
->
save
();
//$gallery->delete();
//$gallery->delete();
return
redirect
()
return
redirect
()
->
back
()
->
back
()
->
with
(
'message_danger'
,
'Imagen eliminada correctamente'
);
->
with
(
'message_danger'
,
'Imagen eliminada correctamente'
);
...
...
src/requests/RequestCategory.php
View file @
c0ef4387
...
@@ -23,11 +23,17 @@ class RequestCategory extends FormRequest
...
@@ -23,11 +23,17 @@ class RequestCategory extends FormRequest
*/
*/
public
function
rules
()
public
function
rules
()
{
{
if
(
$this
->
get
(
"_method"
)
==
"PUT"
||
$this
->
get
(
"_method"
)
==
"PATCH"
){
$slug
=
'required|max:255|unique:product_categories_shop,slug,'
.
$this
->
route
(
"category"
);
}
else
{
$slug
=
'required|max:255|unique:product_categories_shop,slug'
;
}
return
[
return
[
'name'
=>
'required|max:355'
,
'name'
=>
'required|max:355'
,
'slug'
=>
'required|max:255'
,
'slug'
=>
$slug
,
'description'
=>
'max:455'
,
'description'
=>
'max:455'
,
'active'
=>
'required|boolean'
'active'
=>
'required|boolean'
,
'portada'
=>
'image'
];
];
}
}
}
}
\ No newline at end of file
src/requests/RequestGallery.php
0 → 100644
View file @
c0ef4387
<?php
namespace
Onestartup\Shop\Requests
;
use
Illuminate\Foundation\Http\FormRequest
;
class
RequestGallery
extends
FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public
function
authorize
()
{
return
true
;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public
function
rules
()
{
return
[
'file.*'
=>
'image'
];
}
}
\ No newline at end of file
src/requests/RequestProduct.php
View file @
c0ef4387
...
@@ -23,9 +23,14 @@ class RequestProduct extends FormRequest
...
@@ -23,9 +23,14 @@ class RequestProduct extends FormRequest
*/
*/
public
function
rules
()
public
function
rules
()
{
{
if
(
$this
->
get
(
"_method"
)
==
"PUT"
||
$this
->
get
(
"_method"
)
==
"PATCH"
){
$slug
=
'required|max:455|unique:products_shop,slug,'
.
$this
->
route
(
"product"
);
}
else
{
$slug
=
'required|max:455|unique:products_shop,slug'
;
}
return
[
return
[
'name'
=>
'required|max:355'
,
'name'
=>
'required|max:355'
,
'slug'
=>
'required|max:455'
,
'slug'
=>
$slug
,
'description'
=>
'required'
,
'description'
=>
'required'
,
'active'
=>
'required|boolean'
,
'active'
=>
'required|boolean'
,
'publication_date'
=>
'required'
,
'publication_date'
=>
'required'
,
...
...
src/views/category/edit.blade.php
View file @
c0ef4387
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
<div class='modal-footer'>
<div class='modal-footer'>
<button class='btn dark p-x-md' data-dismiss='modal' type='button'>Cerrar</button>
<button class='btn dark p-x-md' data-dismiss='modal' type='button'>Cerrar</button>
@if(
$category->cover
!= null)
@if(
$category->cover
!= null)
{!! Form::open(['route'=> ['
delete.cover.category.shop
',
$category->id
],'method'=>'DELETE'])!!}
{!! Form::open(['route'=> ['
admin-shop-category.delete.cover
',
$category->id
],'method'=>'DELETE'])!!}
<button class='btn btn-danger button-mb' onclick="
return
confirm
(
'¿Estás seguro de eliminar este elemento?'
);
" type='submit'>
<button class='btn btn-danger button-mb' onclick="
return
confirm
(
'¿Estás seguro de eliminar este elemento?'
);
" type='submit'>
<i class='fas fa-trash-alt icon-special-size'>
<i class='fas fa-trash-alt icon-special-size'>
Eliminar
Eliminar
...
...
src/views/product/edit.blade.php
View file @
c0ef4387
...
@@ -120,17 +120,11 @@
...
@@ -120,17 +120,11 @@
</div>
</div>
</div>
</div>
</div><!-- end tab-3 -->
</div><!-- end tab-3 -->
</div>
</div>
</div>
</div>
</div>
</div>
<!-- .modal nuevo contrato -->
<div class='modal fade' data-backdrop='true' id='ver'>
<!-- .modal nuevo contrato -->
<div class='modal fade' data-backdrop='true' id='ver'>
<div class='modal-dialog modal-lg'>
<div class='modal-dialog modal-lg'>
<div class='modal-content box-shadow-z3'>
<div class='modal-content box-shadow-z3'>
<div class='modal-body text-center p-lg'>
<div class='modal-body text-center p-lg'>
...
@@ -154,7 +148,7 @@
...
@@ -154,7 +148,7 @@
</div>
</div>
<!-- /.modal-content -->
<!-- /.modal-content -->
</div>
</div>
</div>
</div>
@endsection
@endsection
...
...
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