ana bel
ana bel

Reputation: 187

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

@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

Upvotes: 0

Views: 1557

Answers (2)

Nick
Nick

Reputation: 546

You made a mistake in the routing of the template Blade.

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

Upvotes: 1

Milad Barazandeh
Milad Barazandeh

Reputation: 331

Because the second argument in route('blogs_path', $blog->id) is parameter.

try this:

Routes:

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

Controller:

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

Upvotes: 1

Related Questions