質問編集履歴
1
bladeを追加しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -76,6 +76,78 @@
|
|
76
76
|
// 商品削除
|
77
77
|
Route::post('/product/delete/{id}', 'ProductController@exeDelete')->name('delete');
|
78
78
|
```
|
79
|
+
```ListBlade
|
80
|
+
@extends('product.layout')
|
81
|
+
@section('title', '商品一覧')
|
82
|
+
@section('content')
|
83
|
+
<div class="row">
|
84
|
+
<div class="input-group">
|
85
|
+
<form class="form-inline" action="{{ route('search') }}" method="get">
|
86
|
+
<input name="search" value="" type="text" class="form-control input-lg" placeholder="商品名">
|
87
|
+
|
88
|
+
<select class="form-control" name="search">
|
89
|
+
<option selected disabled>メーカー名</option>
|
90
|
+
@foreach($products as $product)
|
91
|
+
<option id="company_id" name="company_id" value="{{ $product->id }}">{{ $product->company_name }}</option>
|
92
|
+
@endforeach
|
93
|
+
</select>
|
94
|
+
|
95
|
+
<button type="submit" class="btn btn-primary">検索</button>
|
96
|
+
</form>
|
97
|
+
</div>
|
98
|
+
|
99
|
+
<div class="mb-5 col-md-10 col-md-offset-2">
|
100
|
+
<h2 class="text-secondary mt-3">商品一覧</h2>
|
101
|
+
|
102
|
+
@isset($search_result)
|
103
|
+
<p class="text-danger">{{ $search_result }}</p>
|
104
|
+
@endisset
|
105
|
+
|
106
|
+
@if (session('err_msg'))
|
107
|
+
<p class="text-danger">{{ session('err_msg') }}</p>
|
108
|
+
@endif
|
109
|
+
|
110
|
+
<table class="table table-striped text-secondary">
|
111
|
+
<tr>
|
112
|
+
<th>ID</th>
|
113
|
+
<th>商品画像</th>
|
114
|
+
<th>商品名</th>
|
115
|
+
<th>価格</th>
|
116
|
+
<th>在庫数</th>
|
117
|
+
<th>メーカー名</th>
|
118
|
+
<th></th>
|
119
|
+
<th></th>
|
120
|
+
</tr>
|
121
|
+
@foreach($products as $product)
|
122
|
+
<tr>
|
123
|
+
<td>{{ $product->id }}</td>
|
124
|
+
<td><img src="{{ asset('/storage/' . $product->image) }}" class="img-fluid" alt="{{ $product->image }}" width="200" height="200"></td>
|
125
|
+
<td>{{ $product->product_name }}</td>
|
126
|
+
<td>{{ $product->price }}</td>
|
127
|
+
<td>{{ $product->stock }}</td>
|
128
|
+
<td>{{ $product->company_name }}</td>
|
129
|
+
<td><button type="button" class="btn btn-primary" onclick="location.href='/product/detail/{{ $product->id }}'">詳細</button></td>
|
130
|
+
|
131
|
+
<form method="POST" action="{{ route('delete', $product->id) }}" onSubmit="return checkDelete()">
|
132
|
+
@csrf
|
133
|
+
<td><button type="submit" class="btn btn-secondary" onclick=>削除</button></td>
|
134
|
+
</form>
|
135
|
+
</tr>
|
136
|
+
@endforeach
|
137
|
+
</table>
|
138
|
+
</div>
|
139
|
+
</div>
|
140
|
+
<script>
|
141
|
+
function checkDelete(){
|
142
|
+
if(window.confirm('削除してよろしいですか?')){
|
143
|
+
return true;
|
144
|
+
} else {
|
145
|
+
return false;
|
146
|
+
}
|
147
|
+
}
|
148
|
+
</script>
|
149
|
+
@endsection
|
150
|
+
```
|
79
151
|
### 補足情報(FW/ツールのバージョンなど)
|
80
152
|
Laravel5.8
|
81
153
|
MAMP
|