Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
T
test-webshop
Project
Project
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
Artem
test-webshop
Commits
0ac9ed16
Commit
0ac9ed16
authored
May 05, 2020
by
Artem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve product validation
parent
30366099
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
20 additions
and
15 deletions
+20
-15
ProductController.php
app/Http/Controllers/ProductController.php
+1
-1
2020_04_30_093749_create_products_table.php
...se/migrations/2020_04_30_093749_create_products_table.php
+3
-3
create.blade.php
resources/views/product/create.blade.php
+1
-1
edit.blade.php
resources/views/product/edit.blade.php
+1
-1
product.blade.php
resources/views/product/product.blade.php
+5
-1
welcome.blade.php
resources/views/welcome.blade.php
+9
-8
No files found.
app/Http/Controllers/ProductController.php
View file @
0ac9ed16
...
@@ -150,7 +150,7 @@ class ProductController extends Controller
...
@@ -150,7 +150,7 @@ class ProductController extends Controller
public
function
validateProduct
()
public
function
validateProduct
()
{
{
return
request
()
->
validate
([
return
request
()
->
validate
([
'reference'
=>
'required'
,
'reference'
=>
'required
|unique:products,reference
'
,
'description_short'
=>
'required'
,
'description_short'
=>
'required'
,
'description_long'
=>
'required'
,
'description_long'
=>
'required'
,
'price'
=>
'required'
,
'price'
=>
'required'
,
...
...
database/migrations/2020_04_30_093749_create_products_table.php
View file @
0ac9ed16
...
@@ -15,10 +15,10 @@ class CreateProductsTable extends Migration
...
@@ -15,10 +15,10 @@ class CreateProductsTable extends Migration
{
{
Schema
::
create
(
'products'
,
function
(
Blueprint
$table
)
{
Schema
::
create
(
'products'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
id
();
$table
->
string
(
'reference'
);
$table
->
string
(
'reference'
)
->
unique
()
;
$table
->
string
(
'description_short'
);
$table
->
string
(
'description_short'
);
$table
->
string
(
'description_long'
);
$table
->
text
(
'description_long'
);
$table
->
string
(
'price'
);
$table
->
integer
(
'price'
);
$table
->
string
(
'type'
);
$table
->
string
(
'type'
);
$table
->
timestamps
();
$table
->
timestamps
();
});
});
...
...
resources/views/product/create.blade.php
View file @
0ac9ed16
...
@@ -93,7 +93,7 @@
...
@@ -93,7 +93,7 @@
<div class="
col
-
sm
-
10
">
<div class="
col
-
sm
-
10
">
<input
<input
type="
text
"
type="
number
"
class="
form
-
control
@
error
(
'price'
)
is
-
invalid
@
enderror
"
class="
form
-
control
@
error
(
'price'
)
is
-
invalid
@
enderror
"
id="
price
"
id="
price
"
name="
price
"
name="
price
"
...
...
resources/views/product/edit.blade.php
View file @
0ac9ed16
...
@@ -42,7 +42,7 @@
...
@@ -42,7 +42,7 @@
<div class="
form
-
group
row
">
<div class="
form
-
group
row
">
<label for="
price
" class="
col
-
sm
-
2
col
-
form
-
label
">Price</label>
<label for="
price
" class="
col
-
sm
-
2
col
-
form
-
label
">Price</label>
<div class="
col
-
sm
-
10
">
<div class="
col
-
sm
-
10
">
<input type="
text
" class="
form
-
control
" id="
price
" name="
price
" value="
{{
$product
->
price
}}
" required>
<input type="
number
" class="
form
-
control
" id="
price
" name="
price
" value="
{{
$product
->
price
}}
" required>
</div>
</div>
</div>
</div>
<button class="
btn
btn
-
primary
">Submit</button>
<button class="
btn
btn
-
primary
">Submit</button>
...
...
resources/views/product/product.blade.php
View file @
0ac9ed16
...
@@ -3,8 +3,12 @@
...
@@ -3,8 +3,12 @@
@
section
(
'content'
)
@
section
(
'content'
)
<
section
class
="
product
-
info
">
<
section
class
="
product
-
info
">
<div class="
container
">
<div class="
container
">
<div>
<img src="
/
img
/
{{
$product
->
type
}}
.
jpg
" alt="
{{
$product
->
reference
}}
">
</div>
<p>
{
{$product->reference}
}
</p>
<p>
{
{$product->reference}
}
</p>
<p>
{
{$product->description_short}
}
</p>
<p>
{
{$product->description_long}
}
</p>
<p>Price
{
{$product->price}
}
EUR</p>
<div>
<div>
<a {{--href="
/
product
/
{{
$product
->
id
}}
/
edit
"
<a {{--href="
/
product
/
{{
$product
->
id
}}
/
edit
"
href="
{{
route
(
'product.edit'
,
$product
)
}}
--
}}
href="
{{
route
(
'product.edit'
,
$product
)
}}
--
}}
...
...
resources/views/welcome.blade.php
View file @
0ac9ed16
...
@@ -15,17 +15,18 @@
...
@@ -15,17 +15,18 @@
<div class="
product
">
<div class="
product
">
{{-- <a href="
/
product
/
{{
$product
->
id
}}
" class="
product__image
">--}}
{{-- <a href="
/
product
/
{{
$product
->
id
}}
" class="
product__image
">--}}
<a href="
{{
$product
->
path
()
}}
" class="
product__image
">
<a href="
{{
$product
->
path
()
}}
" class="
product__image
">
<img
<img src="
/
img
/
{{
$product
->
type
}}
.
jpg
" alt="
{{
$product
->
reference
}}
">
@if (
$product->type
=== 'Phone' ||
$product->type
=== 'Balalaika')
{{-- <img--}}
src="
/
img
/
{{
$product
->
type
}}
.
jpg
"
{{-- @if (
$product->type
=== 'Phone' ||
$product->type
=== 'Balalaika')--}}
@else
{{-- src="
/
img
/
{{
$product
->
type
}}
.
jpg
"--}}
src="
https
://
placehold
.
it
/
150
x150
"
{{-- @else--}}
@endif
{{-- src="
https
://
placehold
.
it
/
150
x150
"--}}
alt="
{{
$product
->
reference
}}
">
{{-- @endif--}}
{{-- alt="
{{
$product
->
reference
}}
">--}}
</a>
</a>
<a href="
{{
$product
->
path
()
}}
" class="
product__name
">
{
{$product->reference}
}
</a>
<a href="
{{
$product
->
path
()
}}
" class="
product__name
">
{
{$product->reference}
}
</a>
<p class="
product__short
-
text
">
{
{$product->description_short}
}
</p>
<p class="
product__short
-
text
">
{
{$product->description_short}
}
</p>
<p class="
product__price
">
{
{$product->price}
}
</p>
<p class="
product__price
">
{
{$product->price}
}
EUR
</p>
<button class="
btn
-
add
-
to
-
basket
">Add to basket</button>
<button class="
btn
-
add
-
to
-
basket
">Add to basket</button>
</div>
</div>
</li>
</li>
...
...
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