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

298
Views
Llame a una ruta y almacene la carga útil en una variable en laravel

Entonces, actualmente, tengo una página y necesito llamar a una ruta, y la respuesta JSON que devuelve, necesito almacenarla en una variable en mi página chat.blade.php. Intenté usar {{ruta}} como verá en el código, pero eso no me devolvería a mi chat.blade, a menos que agregara una redirección (), -> ruta () a /me, pero luego Me quedé atrapado en un bucle.

chat.blade.php

 <div class="content"> <head> <script> // quick javascript to act as a client to our web socket server // to state the obvious, this has nothing to do with PHP; this is javascript var conn = new WebSocket('ws://localhost:9000'); var meObj = {}; // some basic call back functions when // certain events happen on the web socket server // when we successfully connect, log a simple message conn.onopen = function (e) { meObj = {{ route('profiles-me') }}; console.log("Connected!"); }; --- redacted to keep it short ---

MeController.php

 --- Redacted to keep it short --- public function me() { /** @var User $user */ $user = Auth::user(); // Lets extract the APP_KEY string to decode it. $appKeyString = explode(':', env('APP_KEY')); $secret = base64_decode($appKeyString[1]); $signature = hash('sha256', $user->name . $secret); return response()->json([ 'me' => [ 'id' => $user->id, 'name' => $user->name, 'picture' => $user->picture, 'csrf_token' => csrf_token(), 'sig' => $signature, ] ]); } --- Redacted to keep it short ---

Ruta

 Route::get('/me', [MeController::class, 'me'])->name('profiles-me')->middleware('auth:profile');
about 4 years ago · Santiago Trujillo
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!