8000 [Bugfix] Do not import model class in Eloquent adapter stub · tekord/laravel-json-api@601b51f · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Feb 17, 2023. It is now read-only.

Commit 601b51f

Browse files
committed
[Bugfix] Do not import model class in Eloquent adapter stub
This avoids collisions with the class name when using the legacy *not-by-resource* resolution. Fixes cloudcreativity#176.
1 parent 264a57b commit 601b51f

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ behaviour can be maintained by setting the `by-resource` config option to the st
2222

2323
### Fixed
2424
- Resolver was not correctly classifying the resource type when resolution was not by resource.
25+
- [#176](https://github.com/cloudcreativity/laravel-json-api/issues/176)
26+
Do not import model class in Eloquent adapter stub to avoid collisions with class name when using the legacy
27+
*not-by-resource* behaviour.
2528

2629
## [1.0.0-alpha.2] - 2018-05-06
2730

stubs/eloquent/adapter.stub

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use CloudCreativity\LaravelJsonApi\Eloquent\AbstractAdapter;
66
use CloudCreativity\LaravelJsonApi\Pagination\StandardStrategy;
77
use Illuminate\Database\Eloquent\Builder;
88
use Illuminate\Support\Collection;
9-
use DummyApplicationNamespace\DummyRecord;
109

1110
class DummyClass extends AbstractAdapter
1211
{
@@ -25,7 +24,7 @@ class DummyClass extends AbstractAdapter
2524
*/
2625
public function __construct(StandardStrategy $paging)
2726
{
28-
parent::__construct(new DummyRecord(), $paging);
27+
parent::__construct(new \DummyApplicationNamespace\DummyRecord(), $paging);
2928
}
3029

3130
/**

tests/lib/Integration/GeneratorsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,8 @@ private function assertEloquentAdapter()
343343
$content = $this->assertAdapter();
344344

345345
$this->assertContains('Eloquent\AbstractAdapter', $content);
346-
$this->assertContains('use DummyApp\Company;', $content);
347< 587B /td>-
$this->assertContains('parent::__construct(new Company(), $paging);', $content);
346+
$this->assertNotContains('use DummyApp\Company;', $content);
347+
$this->assertContains('parent::__construct(new \DummyApp\Company(), $paging);', $content);
348348
}
349349

350350
/**

0 commit comments

Comments
 (0)
0