teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

省略

2021/09/08 02:30

投稿

purinch
purinch

スコア1

title CHANGED
File without changes
body CHANGED
@@ -13,15 +13,7 @@
13
13
 
14
14
  ```PostController
15
15
  //新規投稿
16
- public function createForm(Request $request)
16
+
17
- {
18
- $post = $request->input('newPost');
19
- \DB::table('posts')->insert([
20
- 'post' => $post,
21
- 'user_id' => Auth::user()->id,
22
- ]);
23
- return redirect('/top');
24
- }
25
17
  //投稿更新
26
18
  public function updatepost(Request $request){
27
19
  $id = $request->input('id');
@@ -33,59 +25,4 @@
33
25
  );
34
26
  return redirect('/top');
35
27
  }
36
- ```
28
+ ```
37
-
38
-
39
- ```indexblade
40
- @foreach ($list as $list)
41
- @if ($list->user->id === Auth::user()->id)
42
- <tr class="if">
43
- <td class="edit">
44
- <a data-toggle="modal" data-target="#testModal"><input class="edit" type="image" src="images/edit.png"></a>
45
- </td>
46
- <td class=delete>
47
- <form method="post"  action="/post/delete/{id}">
48
- {{ csrf_field() }}
49
- {{ method_field('delete') }}
50
- <input type="hidden" name="id" value="{{$list->id}}">
51
- <a onclick="return confirm('このつぶやきを削除します。よろしいでしょうか?')"><input class="image btn-dell" type="image" src="images/trash_h.png" value="send"></a>
52
- </form>
53
- </td>
54
- </tr>
55
- @endif
56
- </tr>
57
- <div class="modal fade" id="testModal" tabindex="-1" role="dialog" aria-labelledby="basicModal" aria-hidden="true">
58
- <div class="modal-dialog">
59
- <div class="modal-content">
60
- <div>
61
- {!! Form::open(['url' => 'top','method'=>'post','route'=>'updatePost']) !!}
62
- <input type="hidden" name="_method" value="PUT">
63
- <input id="id" class="form-control" type="hidden" name="id" value="">
64
- <input id="post" class="form-control" type="text" name="upPost" value="">
65
- {{ csrf_field() }}
66
- {{ method_field('put') }}
67
- {!! Form::textarea('post', $list->post,null,['class' => 'form-control','cols'=>'30','rows'=>'10','maxlength'=>'150']) !!}
68
- <input type="image" src="images/edit.png">
69
- {!! Form::close() !!}
70
- </div>
71
- <div class="modal-footer">
72
- <button type="button" class="btn btn-default" data-dismiss="modal">閉じる</button>
73
- </div>
74
- </div>
75
- </div>
76
-
77
- </div>
78
- </div>
79
- @endforeach
80
- }
81
- ```
82
- ```webphp
83
- Route::put('/top', 'PostsController@updatepost')->name('updatePost');
84
- ````
85
- ### 試したこと
86
-
87
- Findを試しましたがうまくいきませんでした。
88
-
89
- ### 補足情報(FW/ツールのバージョンなど)
90
-
91
- ここにより詳細な情報を記載してください。

1

コード省略

2021/09/08 02:30

投稿

purinch
purinch

スコア1

title CHANGED
File without changes
body CHANGED
@@ -38,12 +38,6 @@
38
38
 
39
39
  ```indexblade
40
40
  @foreach ($list as $list)
41
- <tr class="timeline">
42
- <td><a href="{{ url('profile'.$list->user->id) }}"><img src="{{ $list->user->image }}" class="user_image" width="1" height="1"></a></td>
43
- <td><a href="{{ url('profile'.$list->user->id) }}" class="user_name">{{ $list->user->username }}</td></a>
44
- <td class="created_at">{{ $list->created_at }}</td>
45
- <td class="post">{{ $list->post }}</td>
46
-
47
41
  @if ($list->user->id === Auth::user()->id)
48
42
  <tr class="if">
49
43
  <td class="edit">