2017 © Pedro Peláez
 

library notate

Put your JSON data to work in Eloquent.

image

notate/notate

Put your JSON data to work in Eloquent.

  • Friday, June 15, 2018
  • by mink
  • Repository
  • 1 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 100 % Grown

The README.md

Notate

Notate is a tool for the Laravel Eloquent ORM that allows you to define HasOne, HasMany and BelongsTo relationships using properties defined in JSON on a foreign key., (*1)

Installation

Run the following command in your terminal in the directory of your Laravel project., (*2)

composer require notate/notate

Usage

Add the Notate\Notate trait to your Eloquent models, and you will be able to reference JSON columns on both ends when creating relationships., (*3)

Relationships

use Illuminate\Database\Eloquent\Model;
use Notate\Notate;
use Notate\Relations\{HasOne, HasMany, BelongsTo};

class User extends Model
{
    use Notate;

    public function guild(): HasOne
    {
        return $this->hasOne(Guild::class, 'id', 'stats->guild_id');
    }

    public function items(): HasMany
    {
        return $this->hasMany(Item::class, 'data->id', 'nested->some->property');
    }

    public function role(): BelongsTo
    {
        return $this->belongsTo(Role::class, 'name', 'stats->role->name');
    }
}
$user = User::find(1);

// user->nested->some->property == item->data->id
echo $user->items->first()->data->id;

// can use the query builder as usual
$equippedItems = $user->items()->where('equipped',0)->get();

// eager loading support
$users = User::with(['items','guild'])->get();

The Versions

15/06 2018

dev-master

9999999-dev https://github.com/mink/notate

Put your JSON data to work in Eloquent.

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

laravel json collection eloquent relationship notate

15/06 2018

v0.0.5

0.0.5.0 https://github.com/mink/notate

Put your JSON data to work in Eloquent.

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

laravel json collection eloquent relationship notate

15/06 2018

v0.0.4

0.0.4.0 https://github.com/mink/notate

Put your JSON data to work in Eloquent.

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

laravel json collection eloquent relationship notate

15/06 2018

v0.0.3

0.0.3.0 https://github.com/mink/notate

Put your JSON data to work in Eloquent.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel json collection eloquent relationship notate

27/01 2018

v0.0.2

0.0.2.0 https://github.com/mink/notate

Put your JSON data to work in Eloquent.

  Sources   Download

MIT

The Requires

 

laravel json collection eloquent relationship notate

08/01 2018

v0.0.1

0.0.1.0 https://github.com/mink/notate

auto convert json columns to collections, relation support

  Sources   Download

MIT

The Requires

 

laravel json collection eloquent relationship notate

21/12 2017

v1.0.0

1.0.0.0 https://github.com/mink/notate

auto convert json columns to collections, relation support

  Sources   Download

MIT

The Requires

 

laravel json collection eloquent relationship notate