Skip to content

Instantly share code, notes, and snippets.

@vades
Last active October 24, 2024 13:02
Show Gist options
  • Save vades/2b294523db53569ffe6f7d6804cc4e7e to your computer and use it in GitHub Desktop.
Save vades/2b294523db53569ffe6f7d6804cc4e7e to your computer and use it in GitHub Desktop.
Convert JSON data to Eloquent collection in Laravel application

Convert JSON data to Eloquent collection in Laravel application

$collection = collect(json_decode($response));
$items = $collection->where('id', 25);
@javierrodriguez-uala
Copy link

that would make it a collection and not an eloquent model, that is to say... it would be a collection object but it would not be an instance of, for example, User

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment