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

193
Views
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 answers
Answer question

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 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!