-
Notifications
You must be signed in to change notification settings - Fork 105
Open
Description
In getClassNameForRelationships methods, usage of class_basename allows to get the class without the FQN, causing an issue when multiple classes are called with the same base name in the project.
Example :
- model classes
App\Models\Product<- ParentApp\Models\ProductPack<- ChildApp\Models\ProductSimple<- Child
- resource class
App\Http\Resources\Product - creating this relation :
<?php
namespace App\Models;
use App\Models\Interfaces\ProductInterface;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Parental\HasParent;
class ProductPack extends Product implements ProductInterface
{
use HasParent;
public const TYPE = 'pack';
public function containedProducts(): BelongsToMany
{
return $this->belongsToMany(ProductSimple::class);
}
}Testing in tinker will output this error :
> \App\Models\ProductPack::first()->containedProducts;
[!] Aliasing 'Product' to 'App\Http\Resources\Product' for this Tinker session.
ArgumentCountError Too few arguments to function Illuminate\Http\Resources\Json\JsonResource::__construct(), 0 passed in vendor/tightenco/parental/src/HasParent.php on line 78 and exactly 1 expected.
Metadata
Metadata
Assignees
Labels
No labels