Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
how to display a single result ? Lumen

I am unable to display the items called in my show function. Anyone know why nothing is showing?

The Route :

$router->get('/contrats/{id}', [
    'as' => 'contrats.show', 'uses' => 'ContratController@show'
]);

My public function show() :

/**
 * Display the specified resource.
 *
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
public function show(Contrat $contrat)
{
    return view('show', compact('contrat'));
}

The View part :

<p><strong>Contrat n° :</strong> {{ $contrat->id }}</p>
<hr>
<p><strong>Type d'énergie :</strong> {{ $contrat->enrgy }}</p>
<hr>
<p><strong>Numéro gsrn :</strong> {{ $contrat->gsrn }}</p>
<hr>
<p><strong>Durée du contrat : {{ $contrat->duration }} mois</strong></p>
<hr>
<p><strong>Code promotionnel utilisé :</strong> {{ $contrat->codePromo }}</p>

the Result

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I think the route should be

$router->get('/contrats/{contrat}', [...])

for route model binding to work.


Another possibility is to manually query the model.

$router->get('/contrats/{id}', [...])
public function show($id)
{
    $contrat = Contrat::findOrFail($id);

    return view('show', compact('contrat'));    
}

This seems to be the approach used in the official Lumen framework documentation

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!