2017 © Pedro Peláez
 

library eloquent-schema-query

EloquentSchemaQuery is a library that extracts only required items from Eloquent.

image

yonyon/eloquent-schema-query

EloquentSchemaQuery is a library that extracts only required items from Eloquent.

  • Friday, August 18, 2017
  • by yonyon
  • Repository
  • 1 Watchers
  • 1 Stars
  • 49 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

EloquentSchemaQuery

EloquentSchemaQuery is a library that extracts only required items from Eloquent. Describe items to be acquired using schema., (*1)

Install

composer require yonyon/eloquent-schema-query::dev-master

Use Laravel

After updating composer, add the service provider to the providers array in config/app.php, (*2)

'providers' => [
    // Other service providers...

    yonyon\EloquentSchemaQuery\Provider\EloquentSchemaQueryServiceProvider::class,
],

Also, add the facade to the aliases array in your app configuration file:, (*3)

'EloquentSchemaQuery' => \yonyon\EloquentSchemaQuery\Facades\EloquentSchemaQuery::class,

Example

```.php $user = User::find(1);, (*4)

$schema = new Schema([ 'id', 'name', 'todos' => new Schema([ 'name' ]) ]);, (*5)

$result = EloquentSchemaQuery::get($user, $schema);, (*6)


# When you want to change the item name The second argument to schema is an alias for the item name. ```.php $schema = new Schema([ 'id', 'name', 'todos' => new Schema([ 'name' ], 'todo_list') ]);

FunctionSchema

FunctionSchema is used when you want to obtain the result of executing eloquent's query, such as the number of todo. ```.php $schema = new Schema([ 'id', 'name', 'todo_count' => new FunctionSchema(function($user) { return $user->todos->count(); }) ]);, (*7)

If the query result is Collection or Model, you have to define schema as the second argument.
```.php
$schema = new Schema([
  'id',
  'name',
  'todo_count' => new FunctionSchema(
    function($user) {
      return $user->todos;
    },
    new Schema([
      'name'
    ]
  )
]);

The Versions

18/08 2017

dev-master

9999999-dev

EloquentSchemaQuery is a library that extracts only required items from Eloquent.

  Sources   Download

MIT

The Requires

 

by 44x1carbon

16/08 2017

v1.0.1

1.0.1.0

EloquentSchemaQuery is a library that extracts only required items from Eloquent.

  Sources   Download

MIT

The Requires

 

by 44x1carbon