Download the PHP package sukohi/eloquent-array without Composer

On this page you can find all versions of the php package sukohi/eloquent-array. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package eloquent-array

EloquentArray

A Laravel package to deal with array values that we can search through where clause.
This package is only for Laravel 5.3+.

Installation

Execute the following command.

composer require sukohi/eloquent-array:6.*

then set EloquentArrayServiceProvider in your config/app.php.

Sukohi\EloquentArray\EloquentArrayServiceProvider::class, 

Preparation

Execute the following command to publish and migrate the migration.

php artisan vendor:publish --provider="Sukohi\EloquentArray\EloquentArrayServiceProvider"
php artisan migrate

Then set EloquentArrayTrait in your model like so.

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Sukohi\EloquentArray\EloquentArrayTrait;

class Item extends Model
{
    use EloquentArrayTrait;
}

Usage

Set

$item = \App\Item::find(1);
$item->setArray('locales', [
    'en' => 'English',
    'es' => 'Spanish',
    'ja' => 'Japanese'
]);
$item->saveArray();

Unset

$item->unsetArray('locales'); // Remove `locales`
$item->saveArray();

// Or

$item->unsetArray('locales', 'en'); // Remove `en`
$item->saveArray();

Delete

A specific array values related to an item will be removed.

\App\Item::find(1)->deleteArray('locales');

Clear

All of the array values related to an item will be removed.

\App\Item::find(1)->clearArray();

Retrieve

with Key

$item = \App\Item::find(1);
$array = $item->getArray('locales');

/* 

    Array
    (
        [en] => English
        [es] => Spanish
        [ja] => Japanese
    )

*/

without Key

$array = $item->getArray('locales', false);

/* 

    Array
    (
        [0] => English
        [1] => Spanish
        [2] => Japanese
    )

*/

All values

$array = $item->getAllArray();

A Specific Value

echo $item->getArrayValue('locales', 'en'); // English

// with Default Value

echo $item->getArrayValue('locales', 'en', 'Default-Value');

Where Clause

You can use whereArray() method to filter your data like so.

$items = \App\Item::whereArray('locales', 'en')->get();

// or

$items = \App\Item::where('id', 1)
    ->orWhereArray('locales', 'en')
    ->get();

Order by Clause

You can use array items name for ORDER BY like so.

$items = \App\Item::orderByArray('names', 'en')->get();         // asc
$items = \App\Item::orderByArray('names', 'en', 'asc')->get();

// or

$items = \App\Item::orderByArray('names', 'en', 'desc')->get();

Model

[Set]

$item->setModelArray('App\User', 1);   // Model ID
$item->saveArray();

[Set Array]

$item->setAllModelArray([
    'App\User' => [1, 2, 3, 4, 5]   // Model IDs
]);
$item->saveArray();

[Unset]

$item->unsetModelArray([
    'App\User' => [2, 3]   // Model IDs
]);
$item->saveArray();

[Clear]

$item->clearModelArray('App\User');
$item->saveArray();

// or

$item->clearModelArray([
    'App\User',
    'App\Item'
]);
$item->saveArray();

[Retrieve]

$users = $item->getModelArray('App\User');

License

This package is licensed under the MIT License.
Copyright 2016 Sukohi Kuhoh


All versions of eloquent-array with dependencies

PHP Build Version
Package Version
Requires laravel/framework Version ~5.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sukohi/eloquent-array contains the following files

Loading the files please wait ...