/EloquentComposite

Composite Key handling for Eloquent

Primary LanguagePHPMIT LicenseMIT

EloquentComposite: Composite Handling for Eloquent

Latest Stable Version Total Downloads Latest Unstable Version License

Install Via Composer

composer require awkwardideas/eloquentcomposite

Add to config/app.php

Under Package Service Providers Add

AwkwardIdeas\EloquentComposite\EloquentCompositeServiceProvider::class,

Use statement on Model

In your model, replace this line:

use Illuminate\Database\Eloquent\Model

With this:

use AwkwardIdeas\EloquentComposite\Model;

Code use

In your model set the following:

protected $connection = '[your_connection_name_here]';
protected $table = '[your_table_name_here]';
protected $compositeKey = ['your', 'composite', 'key', 'columns'];

Then to update a specific column, use:

$this->UpdateWithComposite('column_name');