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

201
Visualizações
How to request data from database in Laravel?

I've built a frontend in my vue3/laravel8 project and now want to get into the backend. I've been good at learning Vue3 but my knowledge base of Laravel is bare minimum.

I need to fetch an image link from a database and render it in a blade file.

In Vue3 I would use axios.get to send a request to a controller through an url and receive the image link. How do I send a request to my controller in Laravel? Is that even the right way to do it? I thought that maybe Laravel has some backend tricks up its sleeve, that Vue does not.

Edit:

I know that I can get data like this:

$data = DB::select('select * from db_name');

Does it have to be sent through an http response or can I just import the variable in the blade file?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Let's decompose your question to 2 sub-questions:

1- We need to fetch data when call axios request:

you have to update routes\api.php to link the coming request to the proper method located inside your controller

here's an example

2- We need to access our data in front-end:

Vue

  • If you using Vue components you can parse the response data then use it as you prefer

Laravel Blade System

  • You to call return view('your-blade-location', payload), payload => is your fetched data

here's a docs link

about 4 years ago · Juan Pablo Isaza 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