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
30366099
Commit
30366099
authored
May 04, 2020
by
ArtemTropanets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add delete product method
parent
6939c207
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
5 deletions
+16
-5
ProductController.php
app/Http/Controllers/ProductController.php
+2
-1
edit.blade.php
resources/views/product/edit.blade.php
+1
-1
product.blade.php
resources/views/product/product.blade.php
+12
-3
web.php
routes/web.php
+1
-0
No files found.
app/Http/Controllers/ProductController.php
View file @
30366099
...
@@ -143,7 +143,8 @@ class ProductController extends Controller
...
@@ -143,7 +143,8 @@ class ProductController extends Controller
*/
*/
public
function
destroy
(
Product
$product
)
public
function
destroy
(
Product
$product
)
{
{
//
$product
->
delete
();
return
redirect
(
'/'
);
}
}
public
function
validateProduct
()
public
function
validateProduct
()
...
...
resources/views/product/edit.blade.php
View file @
30366099
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
<
section
class
="
create
-
product
">
<
section
class
="
create
-
product
">
<div class="
container
">
<div class="
container
">
<h1>Update product</h1>
<h1>Update product</h1>
<form method="
POST
" action="
/
product
/
{{
$product
->
id
}}
">
<form method="
POST
" action="
{{
$product
->
path
()
}}
">
@csrf
@csrf
@method('PUT')
@method('PUT')
...
...
resources/views/product/product.blade.php
View file @
30366099
...
@@ -5,9 +5,18 @@
...
@@ -5,9 +5,18 @@
<div class="
container
">
<div class="
container
">
<p>
{
{$product->reference}
}
</p>
<p>
{
{$product->reference}
}
</p>
<p>
{
{$product->description_short}
}
</p>
<p>
{
{$product->description_short}
}
</p>
{{-- <div><a href="
/
product
/
{{
$product
->
id
}}
/
edit
">Edit product</a></div>--}}
<div>
{{-- <div><a href="
{{
route
(
'product.edit'
,
$product
)
}}
">Edit product</a></div>--}}
<a {{--href="
/
product
/
{{
$product
->
id
}}
/
edit
"
<div><a href="
{{
$product
->
editPath
()
}}
">Edit product</a></div>
href="
{{
route
(
'product.edit'
,
$product
)
}}
--
}}
href
=
"{{
$product->editPath
() }}"
>
Edit
product
</
a
>
</
div
>
<
form
method
=
"POST"
action
=
"{{
$product->path
() }}"
>
@
csrf
@
method
(
'DELETE'
)
<
button
class
="
btn
btn
-
outline
-
danger
mt
-
5
">Delete product</button>
</form>
</div>
</div>
</section>
</section>
@endsection
@endsection
routes/web.php
View file @
30366099
...
@@ -19,6 +19,7 @@ Route::get('/product/create', 'ProductController@create');
...
@@ -19,6 +19,7 @@ Route::get('/product/create', 'ProductController@create');
Route
::
get
(
'/product/{product}'
,
'ProductController@show'
)
->
name
(
'product.show'
);
Route
::
get
(
'/product/{product}'
,
'ProductController@show'
)
->
name
(
'product.show'
);
Route
::
get
(
'/product/{product}/edit'
,
'ProductController@edit'
)
->
name
(
'product.edit'
);
Route
::
get
(
'/product/{product}/edit'
,
'ProductController@edit'
)
->
name
(
'product.edit'
);
Route
::
put
(
'/product/{product}'
,
'ProductController@update'
);
Route
::
put
(
'/product/{product}'
,
'ProductController@update'
);
Route
::
delete
(
'/product/{product}'
,
'ProductController@destroy'
);
Auth
::
routes
();
Auth
::
routes
();
...
...
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