回答編集履歴
2
誤字修正
test
CHANGED
@@ -6,6 +6,6 @@
|
|
6
6
|
|
7
7
|
```php
|
8
8
|
//'public/images/'.ファイル名を$delItemに代入
|
9
|
-
'public/images/'.
|
9
|
+
'public/images/'.$post->image;
|
10
10
|
```
|
11
11
|
上記に修正して無事にstorage内の画像を削除できました。
|
1
文法の修正
test
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
-
```ここに言語を入力
|
2
|
-
public function destroy(Post $post)
|
3
|
-
{
|
4
|
-
$delImage = Post::find($post->id);
|
5
|
-
$delFile = $delImage->image;
|
6
|
-
Storage::delete('public/images/'.$delFile);
|
7
|
-
$post->delete();
|
8
|
-
return redirect()->route('home')->with('message', '投稿を削除しました');
|
9
|
-
}
|
10
1
|
```
|
2
|
+
//'public/images'.ファイル名を$delItemに代入
|
3
|
+
$delItem = 'public/images'.$post->image;
|
4
|
+
```
|
5
|
+
上記コードの 'public/images'. に「/」が必要でした。。。
|
11
6
|
|
7
|
+
```php
|
12
|
-
|
8
|
+
//'public/images/'.ファイル名を$delItemに代入
|
9
|
+
'public/images/'..$post->image;
|
10
|
+
```
|
11
|
+
上記に修正して無事にstorage内の画像を削除できました。
|