Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

189
Vistas
Button on a view with a href that has a variable passed in the route?

I would like a button's url to take it to a page with a ID in the URL.

Controller:

 public function printpreviewingredients($MealPlan_ID)
     {

//contains the value
$ingredientsid = $MealPlan_ID;

return view('MealPlanDisplay.printpreviewingredientslist', compact('ingredientsid'));

The button with URL:

  <div class="d-flex justify-content-end mb-4">
              <a class="btn btn-primary" href="{{ url('/printpreviewingredients/pdf/$ingredientsid') }}">Export to PDF</a>
          </div>

Despite the value $ingredientsid not being blank, it still won't place the value in the URL link. How can I pass a variable from the Controller method into a button url? I can get it working in a table with a @foreach loop, but presentation wise it doesn't look right.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You must concatenate the variable, don't use PHP inside of the single quote mark. When you use a single quote mark all the content inside of it is takes as string, even if you use PHP syntax.

Use:

href="{{ url('/printpreviewingredients/pdf/'.$ingredientsid) }}"

Instead of:

href="{{ url('/printpreviewingredients/pdf/$ingredientsid') }}"
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda