dimanche 4 février 2018

convert value of a collection into a key in laravel

this my mysql query:

$tmp=almacen::select('nombre_empresa','oferta')->join('users','users.id','=','almacen.emp_id')->where('almacen.event_id','5')->get();

this returns several objects like these:

   ...
   App\almacen {#1948
     nombre_empresa: "Aux1",
     oferta: "Serv_1234",
   },
   App\almacen {#1947
     nombre_empresa: "Aux2",
     oferta: "Serv 12345678",
   },
  ...

i need to convert "nombre_empresa" in a key, for example

$tmp['Aux2']
this return:
"Serv 12345678"

Is it possible to do this in Laravel? or should I do it in another way?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire