feat: Included resources should not inherit parent
fixes issue with addfields, includes, excludefields
May need to install PIAC to fully test:
however basic models:
{
use HasFactory;
protected $fillable = [
'id',
'theme',
'sphere'
];
public function issues(): HasMany
{
return $this->hasMany(Issue::class);
}
public function subIssues(): HasMany
{
return $this->hasMany(SubIssue::class);
}
}
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Issue extends Model
{
use HasFactory;
protected $fillable = [
'id',
'theme_id',
'issue'
];
public function theme(): BelongsTo
{
return $this->belongsTo(Theme::class);
}
public function subIssues(): BelongsToMany
{
return $this->belongsToMany(SubIssue::class);
}
}
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
class SubIssue extends Model
{
use HasFactory;
protected $fillable = [
'id',
'issue_id',
'theme_id',
'subissue',
];
public function issues(): BelongsToMany
{
return $this->belongsToMany(Issue::class);
}
public function theme(): BelongsTo
{
return $this->belongsTo(Theme::class);
}
}
Mapping a resource call to Theme with an includes of issues,sub_issues ends up recursively mapping said relations,
this stops it by namespacing the relations as it goes down,
this opens the ability to also do include=relation,relation.sub-relation which was not previously allowed.