1

Right now, I'm doing this :

  $raw_messages_id = Messages::select('id')->get();
  $messages_id = array();
  foreach($raw_messages_id as $message_id){
       array_push($messages_id,$message_id->id);
  }

In order to get this :

[1034,2031,1023,2234,...]

Is there a better approach to this? I want to prevent the use of looping server-side because it takes a lot of time.


What I have tried

$raw_messages_id = Messages::select('id')->get()->toArray();

OR

$raw_messages_id = Messages::select('id')->get(array('id'))->toArray();

unwanted result

[{id:1034},{id:2031},{id:1023},...]

1 Answer 1

1

You may try this:

$ids = Messages::lists('id');
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.