Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
onestartup-product
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-product
Commits
17432700
Commit
17432700
authored
Jul 17, 2018
by
Francisco Salazar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
validate slug, validate images
parent
7785f769
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
7 deletions
+61
-7
AdminProductController.php
src/controllers/AdminProductController.php
+2
-1
RequestCategory.php
src/requests/RequestCategory.php
+9
-2
RequestGallery.php
src/requests/RequestGallery.php
+32
-0
RequestProduct.php
src/requests/RequestProduct.php
+9
-2
RequestSubCategory.php
src/requests/RequestSubCategory.php
+8
-1
fields.blade.php
src/views/subcategory/fields.blade.php
+1
-1
No files found.
src/controllers/AdminProductController.php
View file @
17432700
...
...
@@ -14,6 +14,7 @@ use Onestartup\Product\Model\Variable as Variable;
use
Onestartup\Product\Requests\RequestProduct
;
use
Onestartup\Product\Requests\RequestVariables
;
use
Onestartup\Product\Requests\RequestGallery
;
class
AdminProductController
extends
Controller
{
...
...
@@ -167,7 +168,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
);
...
...
src/requests/RequestCategory.php
View file @
17432700
...
...
@@ -23,11 +23,17 @@ class RequestCategory extends FormRequest
*/
public
function
rules
()
{
if
(
$this
->
get
(
"_method"
)
==
"PUT"
||
$this
->
get
(
"_method"
)
==
"PATCH"
){
$slug
=
'required|max:455|unique:product_categories,slug,'
.
$this
->
route
(
"category"
);
}
else
{
$slug
=
'required|max:455|unique:product_categories,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 @
17432700
<?php
namespace
Onestartup\Product\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 @
17432700
...
...
@@ -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,slug,'
.
$this
->
route
(
"product"
);
}
else
{
$slug
=
'required|max:455|unique:products,slug'
;
}
return
[
'name'
=>
'required|max:355'
,
'slug'
=>
'required|max:455'
,
'slug'
=>
$slug
,
'description'
=>
'required'
,
'active'
=>
'required|boolean'
,
'publication_date'
=>
'required'
,
...
...
@@ -39,7 +44,8 @@ class RequestProduct extends FormRequest
'extra8'
=>
'max:455'
,
'extra9'
=>
'max:455'
,
'extra10'
=>
'max:455'
,
'category_id'
=>
'required|numeric'
'category_id'
=>
'required|numeric'
,
'cover'
=>
'image'
];
}
}
\ No newline at end of file
src/requests/RequestSubCategory.php
View file @
17432700
...
...
@@ -23,11 +23,17 @@ class RequestSubCategory extends FormRequest
*/
public
function
rules
()
{
if
(
$this
->
get
(
"_method"
)
==
"PUT"
||
$this
->
get
(
"_method"
)
==
"PATCH"
){
$slug
=
'required|max:255|unique:product_subcategories,slug,'
.
$this
->
route
(
"subcategory"
);
}
else
{
$slug
=
'required|max:255|unique:product_subcategories,slug'
;
}
return
[
'name'
=>
'required|max:355'
,
'slug'
=>
'required|max:255'
,
'slug'
=>
$slug
,
'description'
=>
'max:455'
,
'active'
=>
'required|boolean'
,
'portada'
=>
'image'
];
}
}
\ No newline at end of file
src/views/subcategory/fields.blade.php
View file @
17432700
...
...
@@ -21,7 +21,7 @@
<div
class=
"form-group"
>
{!! Form::label('portada', 'Imagén de portada') !!}
@if (isset($category))
@if (isset($
sub
category))
<span>
<a
class=
"btn btn-xs accent"
data-target=
"#ver"
data-toggle=
"modal"
href=
"#"
ui-toggle-class=
"fade-up-big"
>
Ver actual
...
...
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