awkwardideas / eloquentcomposite
Composite Key capabilities for Eloquent
2.0.2
2022-09-07 20:42 UTC
Requires
- php: >=7.0
- illuminate/database: >=5.6 <10.0
Requires (Dev)
- ext-sqlite3: *
README
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');