/laravel-data-binder

Bind and retrieve input data

Primary LanguagePHPMIT LicenseMIT

Bind and retrieve input data

The vesperabr/laravel-data-binder package provides an easy whay to bind and retrieve input data.

Installation

You can install the package via composer:

$ composer require vesperabr/laravel-data-binder

The package will automatically register itself.

Binding values

You can append values to the binding tree by two ways:

Using bind() method

use Vespera\DataBinder\Support\Facades\DataBinder;
DataBinder::bind(['foo' => 'bar'])

Using blade directives

@bind(['foo' => 'bar'])
    ...
@endbind

Pop data from binding

To remove the last data from binding tree just call pop() method.

use Vespera\DataBinder\Support\FacadesDataBinder;
DataBinder::pop();

Retrieving values from binding

To retrieve a value from binding tree use the DataValue facade.

use Vespera\DataBinder\Support\Facades\DataValue;
DataValue::get('foo');

You can also override the current bind data passing a second parameter.

$user = User::find(1);
DataValue::get('name', $user);

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.