2017 © Pedro Peláez
 

library laravel-fillable-relations

Provides HasFillableRelations trait to Eloquent models

image

albinodrought/laravel-fillable-relations

Provides HasFillableRelations trait to Eloquent models

  • Friday, April 27, 2018
  • by AlbinoDrought
  • Repository
  • 1 Watchers
  • 1 Stars
  • 153 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 3 Versions
  • 40 % Grown

The README.md

Laravel Fillable Relations

Build Status, (*1)

This library provides a trait for mixing in to an Eloquent Model. Doing so will enable support for fillable relations., (*2)

This is a stricter, versioned, and opinionated fork of https://github.com/troelskn/laravel-fillable-relations, (*3)

Installation

composer require albinodrought/laravel-fillable-relations

Usage

First, in your model:, (*4)

<?php
namespace MyApp\Models;

use Illuminate\Database\Eloquent\Model;
use LaravelFillableRelations\Eloquent\Concerns\HasFillableRelations;

class Foo extends Model
{
    use HasFillableRelations;
    protected $fillableRelations = ['bar'];

    function bar()
    {
        return $this->hasOne(Bar::class);
    }
}

class Bar extends Model
{
    use HasFillableRelations;
    protected $fillableRelations = ['foos'];

    function foos()
    {
        return $this->hasMany(Foo::class);
    }
}

And you can now fill relations, like so:, (*5)

<?php
$foo = new Foo(
    [
        'cuux' => 42,
        'bar' => [
            'id' => 42
        ]
    ]
);

Or perhaps:, (*6)

<?php
$foo = new Foo(
    [
        'cuux' => 42,
        'bar' => [
            'name' => "Ye Olde Pubbe"
        ]
    ]
);

And also:, (*7)

<?php
$bar = new Bar(
    [
        'name' => "Ye Olde Pubbe",
        'foos' => [
            [
                'cuux' => 42
            ],
            [
                'cuux' => 1337
            ]
        ]
    ]
);

Testing

composer test, (*8)

The Versions

27/04 2018

dev-master

9999999-dev

Provides HasFillableRelations trait to Eloquent models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Troels Knak-Nielsen
by Avatar AlbinoDrought

27/04 2018

v1.1.0

1.1.0.0

Provides HasFillableRelations trait to Eloquent models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Troels Knak-Nielsen
by Avatar AlbinoDrought

20/04 2018

v1.0.0

1.0.0.0

Provides HasFillableRelations trait to Eloquent models

  Sources   Download

MIT

The Requires

 

The Development Requires

by Troels Knak-Nielsen
by Avatar AlbinoDrought