2017 © Pedro Peláez
 

library fluents

Convert Eloquent Model objects to and from Fluent objects.

image

delatbabel/fluents

Convert Eloquent Model objects to and from Fluent objects.

  • Monday, June 26, 2017
  • by delatbabel
  • Repository
  • 2 Watchers
  • 0 Stars
  • 1,208 Installations
  • PHP
  • 6 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 1 % Grown

The README.md

Fluents

Laravel extension to convert to/from Fluent objects., (*1)

Rationale

The Laravel Fluent object is one of the most under-rated and under-utilized components of the framework. Essentially a free-standing object, it allows you to access an array of attributes as an object rather than as an array., (*2)

example:, (*3)

Instead of using an array like this:, (*4)

$myArray = [];
$myArray['first'] = 'one';
$myArray['second'] = 'two;

echo $myArray['first']; // prints "one"

Use fluent object like this:, (*5)

$myObject = new Fluent();
$myObject->first = 'one';
$myObject->second = 'two';

echo $myObject->first; // prints "one"

Until now, however, there has been no standard straightforwards way to convert an Eloquent Model object into a Fluent object. There is a toArray() function on a Model object but no equivalent toFluent() function., (*6)

This component adds such functions using a trait that can be applied to any model object. Note that several other of Laravel's internal classes can also have this trait applied, as long as they store their data in an internal attributes array this trait should work., (*7)

Usage

Model Fill From Fluent Object

use Delatbabel\Fluents\Fluents;

class User extends Eloquent {
    use Fluents;
}

$myFluent = new Fluent();
$myFluent->first = 'one';

$myUser = new User();
$myUser->fromFluent($myFluent);

Model Convert From Fluent Object

use Delatbabel\Fluents\Fluents;

class User extends Eloquent {
    use Fluents;
}

$myUser = User->find(1);
$myFluent = User->toFluent();

The Versions

26/06 2017

dev-master

9999999-dev

Convert Eloquent Model objects to and from Fluent objects.

  Sources   Download

MIT

The Requires

 

by Del

laravel eloquent l5 laravel5 fluent

26/06 2017

v1.4

1.4.0.0

Convert Eloquent Model objects to and from Fluent objects.

  Sources   Download

MIT

The Requires

 

by Del

laravel eloquent l5 laravel5 fluent

28/12 2015

v1.3.1

1.3.1.0

Convert Eloquent Model objects to and from Fluent objects.

  Sources   Download

MIT

The Requires

 

by Del

laravel eloquent l5 laravel5 fluent

14/12 2015

v1.3

1.3.0.0

Convert Eloquent Model objects to and from Fluent objects.

  Sources   Download

MIT

The Requires

 

by Del

laravel eloquent l5 laravel5 fluent

06/12 2015

v1.2

1.2.0.0

Convert Eloquent Model objects to and from Fluent objects.

  Sources   Download

MIT

The Requires

 

by Del

laravel eloquent l5 laravel5 fluent

06/12 2015

v1.1

1.1.0.0

Convert Eloquent Model objects to and from Fluent objects.

  Sources   Download

The Requires

 

by Del

laravel eloquent l5 laravel5 fluent

06/12 2015

v1.0

1.0.0.0

Convert Eloquent Model objects to and from Fluent objects.

  Sources   Download

The Requires

 

by Del

laravel eloquent l5 laravel5 fluent