Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Opening Laravel links based on their Id

I’ve created a laravel blog and I want to open every single post on their own page using the following laravel link.

 <a href="{{route('about.show'.$about_us)}}" class="text-success text-decoration-none">{{$about_us->button}}</a> which I trying to open using the show method and the routes. This is how I have set up the show method and it's route.

public function show($id)
{
    //
    return view('about.show')
}

Route::get('/about.show','App\Http\Controllers\AboutController@show')->name('about.show');

When I try, it gives me an error Route [about.show{"id":1,"title":"My Agenda","description":"My four",… not defined.

When I try to open it up using the index method it shows but it picks up two ids. and when I delete .$about_us, it displays a blank white page. This is a noob question, but I’m struggling. Can anyone assist

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

I don’t know your code so that’s why I am giving some example how to acheive this thing.

Route::get('/show/{id}','App\Http\Controllers\AboutController@getPostById');
public function getPostById($id){
  $request=app('request');
  $data=Model::where('id',$request->id)->get();
  return response()->json([$data]);
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading