mardi 24 novembre 2015

laravel populating typeahead

I am trying to populate typeahead with a list of data.

model:

 public function getClientNameAttribute() {
     return '{"clientID":"'.$this->id.'", "clientName": "'.$this->name.'"}';
 }

on running the following:

{!! $clients->lists('ClientName') !!}

I get this as my output :

["{\"clientID\":\"1\", \"clientName\": \"client 1\"}","{\"clientID\":\"2\", \"clientName\": \"client 2\"}"

It should be like this :

 [{"clientID": "1", "clientName": "client 1"}, {"clientID": "2", "clientName": "client 2"},

So I need to get rid of the slashes, and the double quotes around each record.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire