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

120
Views
add php {{--php code--}} to laravel blade using javascript

There is a laravel project I'm working on, in which I have to retrieve data from database and then show it to the users. the thing is I have some pre-built components in javascript and the data needs to be inside of it. an example would be:

    var element = ` <div class="col-12 p-4 d-flex flex-column">
                      <h3 class="text-white">
                        {{$user_data->data}}
                      </h3>
                      <div class="bg-white p-3 rounded">
                        <p class="mb-0">
                        {{$user_data->data}}
                        </p>
                      </div>
                    </div>`;

and then I would add this element div to the blades body in my js file. the problem is that the php tags are working like strings so what I get instead of users data in the page is {{$user_data->data}}. Can anyone help me how to fix that?

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