-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created a positiblity to add custom relation type (#987)
* Created a positiblity to add custom relation type * Changed access modifier Co-authored-by: Markus Podar <[email protected]> * fixed hints from code review * Added Test for barryvdh/laravel-ide-helper#987 * composer fix-style * Clarify doc in config entry * Update CHANGELOG.md Co-authored-by: Markus Podar <[email protected]>
- Loading branch information
1 parent
abd42e7
commit 115a3ec
Showing
9 changed files
with
201 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
tests/Console/ModelsCommand/Relations/Traits/HasTestRelations.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Relations\Traits; | ||
|
||
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Relations\Types\SampleToManyRelationType; | ||
use Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Relations\Types\SampleToOneRelationType; | ||
|
||
trait HasTestRelations | ||
{ | ||
public function testToOneRelation($related) | ||
{ | ||
$instance = $this->newRelatedInstance($related); | ||
return new SampleToOneRelationType($instance->newQuery(), $this); | ||
} | ||
|
||
public function testToManyRelation($related) | ||
{ | ||
$instance = $this->newRelatedInstance($related); | ||
return new SampleToManyRelationType($instance->newQuery(), $this); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
tests/Console/ModelsCommand/Relations/Types/SampleToManyRelationType.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Relations\Types; | ||
|
||
use Illuminate\Database\Eloquent\Collection; | ||
use Illuminate\Database\Eloquent\Relations\Relation; | ||
|
||
class SampleToManyRelationType extends Relation | ||
{ | ||
public function addConstraints() | ||
{ | ||
// Fake | ||
} | ||
|
||
public function addEagerConstraints(array $models) | ||
{ | ||
// Fake | ||
} | ||
|
||
public function initRelation(array $models, $relation) | ||
{ | ||
// Fake | ||
} | ||
|
||
public function match(array $models, Collection $results, $relation) | ||
{ | ||
// Fake | ||
} | ||
|
||
public function getResults() | ||
{ | ||
// Fake | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
tests/Console/ModelsCommand/Relations/Types/SampleToOneRelationType.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Relations\Types; | ||
|
||
use Illuminate\Database\Eloquent\Collection; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Relations\Concerns\SupportsDefaultModels; | ||
use Illuminate\Database\Eloquent\Relations\Relation; | ||
|
||
/** | ||
* Sample for custom relation | ||
* | ||
* the relation is a big fake and only for testing of the docblock generation | ||
* | ||
* @package Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Relations | ||
*/ | ||
class SampleToOneRelationType extends Relation | ||
{ | ||
use SupportsDefaultModels; | ||
|
||
public function addConstraints() | ||
{ | ||
// Fake | ||
} | ||
|
||
public function addEagerConstraints(array $models) | ||
{ | ||
// Fake | ||
} | ||
|
||
public function initRelation(array $models, $relation) | ||
{ | ||
// Fake | ||
} | ||
|
||
public function match(array $models, Collection $results, $relation) | ||
{ | ||
// Fake | ||
} | ||
|
||
public function getResults() | ||
{ | ||
// Fake | ||
} | ||
|
||
protected function newRelatedInstanceFor(Model $parent) | ||
{ | ||
// Fake | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters