awkwardideas/eloquentcomposite

Composite Key capabilities for Eloquent

2.0.2 2022-09-07 20:42 UTC

This package is auto-updated.

Last update: 2024-12-10 00:23:55 UTC


README

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');