Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

187
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda