PHPackages                             coder-at-heart/object-models - 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. coder-at-heart/object-models

ActiveLibrary

coder-at-heart/object-models
============================

Add schema, control and cast php json as objects and arrays for Laravel projects

1.1.14(2y ago)62.0kMITPHPPHP ^8.1

Since Aug 28Pushed 2y ago1 watchersCompare

[ Source](https://github.com/coder-at-heart/object-models)[ Packagist](https://packagist.org/packages/coder-at-heart/object-models)[ RSS](/packages/coder-at-heart-object-models/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (5)Versions (19)Used By (0)

A handy way to define, use and convert object and arrays to json
================================================================

[](#a-handy-way-to-define-use-and-convert-object-and-arrays-to-json)

This Laravel package:

- Provides a fluent way to define structure / schema over objects
- Allows you to validate those objects in a consistent way
- Easily cast eloquent json attributes to objectModels for easy handling
- Reduces the number of meta tables in your app

Requirements
------------

[](#requirements)

This package requires

- PHP 8.1 and
- Laravel 8.0 or higher (including 10).

Installation
------------

[](#installation)

Install it:

```
composer require coder-at-heart/object-models
```

Defining ObjectModels
---------------------

[](#defining-objectmodels)

Extend the ObjectModel class and extend override the `properties()` method

I usually create an `app/ObjectModels` folder to store my models

Here's an example from the tests folder:

```
