简体   繁体   English

url 和 laravel 中的问号

[英]question mark in the url with laravel

i'm learning laravel for now, i'm trying to build a crud application how i got the url with a question mark how i can remove it from the url the url that i got is like..../blogs?1 here is the view i'm learning laravel for now, i'm trying to build a crud application how i got the url with a question mark how i can remove it from the url the url that i got is like..../blogs?1 here是视图

@extends ('layouts.app')
@section('content')
<div class="row">
@foreach($blogs as $blog)
<div class="col-md-6">
<div class="card">
<div class="card-header">
<a href="{{ route('blogs_path', $blog->id) }}">{{$blog -> title}}</a>

</div>
<div class="card-body">
{{$blog->content}}
</div>

</div>

</div>
 </div>

@endforeach
@endsection


<?php


Route::get('/', function () {
    return view('welcome');
});
Route::name('blogs_path')->get('/blogs','BlogController@index');
Route::name('create_blog_path')->get('/blogs/create','BlogController@create');
Route::name('store_blog_path')->post('/blogs','BlogController@store');
Route::name('blogs_path1')->get('/blogs/{id}','BlogController@show');
Route::name('edit_blog_path')->get('/blogs/{id}/edit','BlogController@edit');

how can i fix this, thank you in advance我该如何解决这个问题,提前谢谢你

You made a mistake in the routing of the template Blade.您在模板 Blade 的路由中犯了一个错误。

{{ route('blogs_path1', ['id' => $blog->id]) }}

Because the second argument in route('blogs_path', $blog->id) is parameter.因为route('blogs_path', $blog->id)中的第二个参数是参数。

try this:尝试这个:

Routes:路线:

Route::name('blogs_path')->get('/blogs/{id}/','BlogController@index');

Controller: Controller:

public function index(Request $request, $id)
{
...
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM