When you give a 404 NOT FOUND , even though I am using it route resource . I don't go to any page

huangapple go评论72阅读模式
英文:

When you give a 404 NOT FOUND , even though I am using it route resource . I don't go to any page

问题

  1. 当您返回`404 NOT FOUND`时,即使我使用了路由资源,也不会跳转到任何页面。
  2. ```php
  3. Route::resource('/', ClientController::class)
  1. <tbody>
  2. @forelse($clients as $client)
  3. <tr>
  4. <th scope="row">{{$client->id}}</th>
  5. <td>{{$client->email}}</td>
  6. <td>{{$client->password}}</td>
  7. <td>{{$client->city}}</td>
  8. <td><a href="{{route('edit',$client->id)}}" >Update</a></td>
  9. </tr>
  10. <tr>
  11. @empty
  12. <h1>pas de client</h1>
  13. @endforelse
  14. </tbody>
  1. public function edit($id)
  2. {
  3. return $id;
  4. }
英文:

When you give a 404 NOT FOUND, even though I am using it route resource. I don't go to any page

  1. Route::resource(&#39;/&#39; , ClientController::class)
  1. &lt;tbody&gt;
  2. @forelse($clients as $client)
  3. &lt;tr&gt;
  4. &lt;th scope=&quot;row&quot;&gt;{{$client-&gt;id}}&lt;/th&gt;
  5. &lt;td&gt;{{$client-&gt;email}}&lt;/td&gt;
  6. &lt;td&gt;{{$client-&gt;password}}&lt;/td&gt;
  7. &lt;td&gt;{{$client-&gt;city}}&lt;/td&gt;
  8. &lt;td&gt;&lt;a href=&quot;{{route(&#39;edit&#39;,$client-&gt;id)}}&quot; &gt;Update&lt;/a&gt;&lt;/td&gt;
  9. &lt;/tr&gt;
  10. &lt;tr&gt;
  11. @empty
  12. &lt;h1&gt;pas de client&lt;/h1&gt;
  13. @endforelse
  14. &lt;/tbody&gt;
  1. public function edit($id)
  2. {
  3. return $id;
  4. }

答案1

得分: 1

以下是翻译好的部分:

  1. public function edit($id)
  2. {
  3. return redirect()->back();
  4. }

或者:

  1. public function edit($id)
  2. {
  3. return redirect()->route('route.name');
  4. }
英文:

Your return needs to go somewhere, try:

  1. public function edit($id)
  2. {
  3. return redirect()-&gt;back();
  4. }

or:

  1. public function edit($id)
  2. {
  3. return redirect()-&gt;route(&#39;route.name&#39;);
  4. }

答案2

得分: 0

  1. Route::resource('/client', ClientController::class);
  1. <td><a href="{{route('client.edit', $client->id)}}">Update</a></td>
英文:
  1. Route::resource(&#39;/&#39; , ClientController::class);

Change the above to:

  1. Route::resource(&#39;/client&#39; , ClientController::class);

Then, in the blade for edit:

  1. &lt;td&gt;&lt;a href=&quot;{{route(&#39;client.edit&#39;,$client-&gt;id)}}&quot; &gt;Update&lt;/a&gt;&lt;/td&gt;

huangapple
  • 本文由 发表于 2023年3月4日 01:19:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/75630093.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定