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
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
75 additions
and
39 deletions
+75
-39
AdminProductController.php
src/controllers/AdminProductController.php
+4
-6
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
+23
-29
No files found.
src/controllers/AdminProductController.php
View file @
c0ef4387
...
...
@@ -23,8 +23,9 @@ use Onestartup\Shop\Libs\Util;
use
Onestartup\Shop\Requests\RequestProduct
;
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\Refund
;
use
PayPal\Api\Sale
as
SalePaypal
;
...
...
@@ -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
);
...
...
@@ -247,11 +248,8 @@ class AdminProductController extends Controller
}
$product
->
cover
=
null
;
$product
->
save
();
$product
->
save
();
//$gallery->delete();
return
redirect
()
->
back
()
->
with
(
'message_danger'
,
'Imagen eliminada correctamente'
);
...
...
src/requests/RequestCategory.php
View file @
c0ef4387
...
...
@@ -23,11 +23,17 @@ class RequestCategory extends FormRequest
*/
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
[
'name'
=>
'required|max:355'
,
'slug'
=>
'required|max:255'
,
'slug'
=>
$slug
,
'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
*/
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
[
'name'
=>
'required|max:355'
,
'slug'
=>
'required|max:455'
,
'slug'
=>
$slug
,
'description'
=>
'required'
,
'active'
=>
'required|boolean'
,
'publication_date'
=>
'required'
,
...
...
src/views/category/edit.blade.php
View file @
c0ef4387
...
...
@@ -50,7 +50,7 @@
<div class='modal-footer'>
<button class='btn dark p-x-md' data-dismiss='modal' type='button'>Cerrar</button>
@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'>
<i class='fas fa-trash-alt icon-special-size'>
Eliminar
...
...
src/views/product/edit.blade.php
View file @
c0ef4387
...
...
@@ -120,41 +120,35 @@
</div>
</div>
</div><!-- end tab-3 -->
</div>
</div>
</div>
<!-- .modal nuevo contrato -->
<div class='modal fade' data-backdrop='true' id='ver'>
<div class='modal-dialog modal-lg'>
<div class='modal-content box-shadow-z3'>
<div class='modal-body text-center p-lg'>
@if (
$product->cover
== null)
<h4>No hay imagen asignada.</h4>
@else
<img class='image-modal-preview' src="
{{
asset
(
'storage/'
.
$product
->
cover
)}}
">
@endif
</div>
<div class='modal-footer'>
<button class='btn dark p-x-md' data-dismiss='modal' type='button'>Cerrar</button>
@if(
$product->cover
!= null)
{!! Form::open(['route'=> ['admin-shop-product.delete.cover',
$product->id
],'method'=>'DELETE'])!!}
<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>
Eliminar
</button>
{!! Form::close()!!}
@endif
</div>
<!-- .modal nuevo contrato -->
<div class='modal fade' data-backdrop='true' id='ver'>
<div class='modal-dialog modal-lg'>
<div class='modal-content box-shadow-z3'>
<div class='modal-body text-center p-lg'>
@if (
$product->cover
== null)
<h4>No hay imagen asignada.</h4>
@else
<img class='image-modal-preview' src="
{{
asset
(
'storage/'
.
$product
->
cover
)}}
">
@endif
</div>
<div class='modal-footer'>
<button class='btn dark p-x-md' data-dismiss='modal' type='button'>Cerrar</button>
@if(
$product->cover
!= null)
{!! Form::open(['route'=> ['admin-shop-product.delete.cover',
$product->id
],'method'=>'DELETE'])!!}
<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>
Eliminar
</button>
{!! Form::close()!!}
@endif
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-content -->
</div>
</div>
@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