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

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

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

问题

当您返回`404 NOT FOUND`时,即使我使用了路由资源,也不会跳转到任何页面。

```php
Route::resource('/', ClientController::class)
<tbody>
    @forelse($clients as $client)
        <tr>
            <th scope="row">{{$client->id}}</th>
            <td>{{$client->email}}</td>
            <td>{{$client->password}}</td>
            <td>{{$client->city}}</td>
            <td><a href="{{route('edit',$client->id)}}" >Update</a></td>
        </tr>
        <tr>
    @empty
        <h1>pas de client</h1>
    @endforelse
</tbody>
public function edit($id)
{
    return $id;
}
英文:

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

Route::resource(&#39;/&#39; , ClientController::class)
&lt;tbody&gt;
    @forelse($clients as $client)
        &lt;tr&gt;
            &lt;th scope=&quot;row&quot;&gt;{{$client-&gt;id}}&lt;/th&gt;
            &lt;td&gt;{{$client-&gt;email}}&lt;/td&gt;
            &lt;td&gt;{{$client-&gt;password}}&lt;/td&gt;
            &lt;td&gt;{{$client-&gt;city}}&lt;/td&gt;
            &lt;td&gt;&lt;a href=&quot;{{route(&#39;edit&#39;,$client-&gt;id)}}&quot;  &gt;Update&lt;/a&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
    @empty
        &lt;h1&gt;pas de client&lt;/h1&gt;
    @endforelse
&lt;/tbody&gt;
public function edit($id)
{
    return $id;
}

答案1

得分: 1

以下是翻译好的部分:

public function edit($id)
{
    return redirect()->back();
}

或者:

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

Your return needs to go somewhere, try:

public function edit($id)
{
    return redirect()-&gt;back();
}

or:

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

答案2

得分: 0

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

Change the above to:

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

Then, in the blade for edit:

&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:

确定