PHPackages                             stechstudio/laravel-record - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. stechstudio/laravel-record

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

stechstudio/laravel-record
==========================

What if Laravel's Collection and Model classes had a baby?

1.13(3w ago)2314.2k↓21.7%32MITPHPCI failing

Since Jun 13Pushed 3w ago2 watchersCompare

[ Source](https://github.com/stechstudio/laravel-record)[ Packagist](https://packagist.org/packages/stechstudio/laravel-record)[ RSS](/packages/stechstudio-laravel-record/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (8)Dependencies (6)Versions (17)Used By (2)

Laravel Record
==============

[](#laravel-record)

[![Latest Version on Packagist](https://camo.githubusercontent.com/67ce0fe4bce3ea250354037d24395d55925d14bc3a6ec4578d35ad225bd06a95/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f737465636873747564696f2f6c61726176656c2d7265636f72642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/stechstudio/laravel-record)[![Total Downloads](https://camo.githubusercontent.com/24bfad93909239cecf2197b5bc493024c0c8f331631562bf1209b2f61563546c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f737465636873747564696f2f6c61726176656c2d7265636f72642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/stechstudio/laravel-record)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

I'm going to assume you already know all about Laravel's awesome [Collection](https://laravel.com/docs/5.4/collections) class, and hopefully you've read [Refactoring to Collections](https://adamwathan.me/refactoring-to-collections/). (If you haven't, stop what you're doing and go buy that PDF. You'll thank me later.)

I also assume you know all about [Eloquent models](https://laravel.com/docs/5.4/eloquent).

But have you ever wanted some of the functionality of a model, merged onto a collection?

This is a super small, single-class library that brings those together just a bit.

Benefits
========

[](#benefits)

Starting with the Collection class, I wanted to add:

1. **Magic getter for attributes**. If you have key/value pairs in your collection, the Collection class does provide the [get](https://laravel.com/docs/5.4/collections#method-get) method. But I'm lazy. And I like accessing my collection with plain 'ol object notation. You know, like a model. Record lets you do `$collection->attribute`.
2. **New collection for sub-arrays**. If you hand a multi-dimensional array to `collect()` and access a nested array, it's still just an array. Like `$collection->get('attribute')['subattribute']`. I want collections all the way down! This will turn any sub-array into a new instance of Record, allowing you to do `$record->attribute->subattribute->as->deep->as->your->array->goes`. And because you still have a real collection at each level, you can use all of the goodies like `$record->attribute->subattribute->count()`.
3. **Custom accessors**. Just like Eloquent, you can extend the Record class and define a custom accessor. Create a `getFooAttribute()` method and then just use `$collection->foo` to get your custom computed attribute.

Quick example: handling rich arrays
===================================

[](#quick-example-handling-rich-arrays)

I find myself frequently needing to handle a multi-dimensional array, often a response from a remote web service. This array may have attributes (like 'name' or 'id') as well as a nested collections (like 'data' or 'rows').

Consider this:

```
{
  "name" : "My Blog",
  "url" : "http://foo.dev",
  "posts" : [
    {
      "id" : 1,
      "title" : "Hello World",
      "content" : "...",
      "comments" : [
        {
          "name" : "John Doe",
          "email" : "john@example.com",
          "content": "..."
        }
      ]
    },
    {
      "id" : 2,
      "title" : "My second post",
      "content" : "...",
      "comments" : [
        ...
      ]
    }
  ]
}
```

We can take this whole payload and navigate it quite nicely with Record:

```
$record = record(json_decode($webServiceResponse, true));

echo $record->name; // My Blog
echo $record->posts->count(); // 2
echo $record->posts->first()->title; // Hello World
echo $record->posts->first()->comments->count(); // 1
```

Nice! At each level I get a combination Laravel's Collection class, plus some attribute goodness borrowed from Model.

Furthermore I might extend Record and create a class with custom accessors to sanitize `content`, or split the `name` into first and last, or... you get the idea.

Installation
============

[](#installation)

You know the drill.

```
composer require stechstudio/laravel-record

```

Then you can either:

```
$record = new STS\Record\Record([...]);
```

Or you can use the `record` helper method:

```
$record = record([...]);
```

###  Health Score

58

—

FairBetter than 98% of packages

Maintenance95

Actively maintained with recent releases

Popularity35

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 88.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~234 days

Recently: every ~205 days

Total

15

Last Release

21d ago

Major Versions

0.1 → 1.02017-06-13

### Community

Maintainers

![](https://www.gravatar.com/avatar/315be5f111b5501a41b99a0205c9c85915335391168a0ed10316546a1a38bbd8?d=identicon)[jszobody](/maintainers/jszobody)

---

Top Contributors

[![jszobody](https://avatars.githubusercontent.com/u/203749?v=4)](https://github.com/jszobody "jszobody (24 commits)")[![V13Axel](https://avatars.githubusercontent.com/u/2779682?v=4)](https://github.com/V13Axel "V13Axel (2 commits)")[![krp-kp](https://avatars.githubusercontent.com/u/1413296?v=4)](https://github.com/krp-kp "krp-kp (1 commits)")

---

Tags

collectionslaravelmodel

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/stechstudio-laravel-record/health.svg)

```
[![Health](https://phpackages.com/badges/stechstudio-laravel-record/health.svg)](https://phpackages.com/packages/stechstudio-laravel-record)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M345](/packages/psalm-plugin-laravel)[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M11](/packages/renatomarinho-laravel-page-speed)[illuminate/pagination

The Illuminate Pagination package.

12234.1M1.0k](/packages/illuminate-pagination)[illuminate/pipeline

The Illuminate Pipeline package.

9349.2M282](/packages/illuminate-pipeline)[illuminate/redis

The Illuminate Redis package.

8314.6M375](/packages/illuminate-redis)[illuminate/cookie

The Illuminate Cookie package.

244.6M137](/packages/illuminate-cookie)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
