-1

I am new in laravel. How to convert laravel object into js array. my coce is below..

$customer = new Customer();             
$result = $customer->where('client_state','like', '%'.$statename.'%')->get(array('client_state'));

echo $result;

result is...

[{"client_state":"Gujarat1"},{"client_state":"Gujarat"}]

but i need like this..

["Gujarat1","Gujarat"]

How it is possible?

1

1 Answer 1

-1

If you want your query to return an array of which values are set to values of your preferred column, then you would use a method lists('your_column_here') instead of get()

Try this:

$result = $customer->where('client_state','like', '%'.$statename.'%')->lists('your_column'));

Reference here: http://laravel.com/docs/5.0/queries#selects

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.