Skip to content

Commit

Permalink
renamed trait to HasExtendedRelationships from LaravelExtendedRelatio…
Browse files Browse the repository at this point in the history
…nships
  • Loading branch information
MrPunyapal committed Apr 3, 2023
1 parent 3e2f413 commit 360d701
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ composer require mr-punyapal/laravel-extended-relationships

## Usage

First, include the `LaravelExtendedRelationships` trait in your model:
First, include the `HasExtendedRelationships` trait in your model:

```php

use Mrpunyapal\LaravelExtendedRelationships\LaravelExtendedRelationships;
use Mrpunyapal\LaravelExtendedRelationships\HasExtendedRelationships;

class Post extends Model {
use LaravelExtendedRelationships;
use HasExtendedRelationships;

//...
}
Expand Down Expand Up @@ -84,11 +84,11 @@ This allows you to define multiple relationships with just one method, and only

```php

use Mrpunyapal\LaravelExtendedRelationships\LaravelExtendedRelationships;
use Mrpunyapal\LaravelExtendedRelationships\HasExtendedRelationships;

class User extends Model{

use LaravelExtendedRelationships;
use HasExtendedRelationships;

public function audited(){
return $this->hasManyWithManyKeys(
Expand Down Expand Up @@ -130,11 +130,11 @@ If you have a column posts in your users table which stores an array of local ke

```php

use Mrpunyapal\LaravelExtendedRelationships\LaravelExtendedRelationships;
use Mrpunyapal\LaravelExtendedRelationships\HasExtendedRelationships;

class User extends Model
{
use LaravelExtendedRelationships;
use HasExtendedRelationships;

protected $casts=[
'posts' => 'array'
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
],
"require": {
"php": "^8.1",
"illuminate/contracts": "^10.0",
"illuminate/contracts": "^10.0"
},
"require-dev": {
"laravel/pint": "^1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Mrpunyapal\LaravelExtendedRelationships\Relations\HasManyWithManyKeys;
use Mrpunyapal\LaravelExtendedRelationships\Relations\HasManyWithColumnKeyArray;

trait LaravelExtendedRelationships
trait HasExtendedRelationships
{
/**
* @param string $related
Expand Down
2 changes: 1 addition & 1 deletion src/Relations/BelongsToManyWithManyKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function addEagerConstraints(array $models)
foreach ($localKeys as $localKey) {
$desireValues = array_merge($desireValues, $this->getKeys($models, $localKey) ?? []);
}
$this->query->WhereIn($foreignKey, array_filter(array_unique($desireValues)));
$this->query->whereIn($foreignKey, array_filter(array_unique($desireValues)));
}

/**
Expand Down
2 changes: 0 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Mrpunyapal\LaravelExtendedRelationships\Tests;

use Illuminate\Database\Eloquent\Factories\Factory;
use Orchestra\Testbench\TestCase as Orchestra;
use Mrpunyapal\LaravelExtendedRelationships\LaravelExtendedRelationshipsServiceProvider;

class TestCase extends Orchestra
{
Expand Down

0 comments on commit 360d701

Please sign in to comment.