Repeater HasMany relationship error

Hi, I have an error when registering the fields of the HasMany relationship in my repeater in the database.

The models are as follows:

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

class CompetencyFramework extends Model
{
    use HasFactory;

    protected $fillable = [
        'title',
    ];

    public function competencies(): HasMany
    {
        return $this->hasMany(Competency::class);
    }
} 


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;

class Competency extends Model
{
    use HasFactory;

    protected $fillable = [
        'title',
        'competency_framework_id',
    ];

    public function competency_framework(): BelongsTo
    {
        return $this->belongsTo(CompetencyFramework::class);
    }
}


In my CompetencyFramework resource, I have this:
class CompetencyFrameworkResource extends Resource
{
    protected static ?string $model = CompetencyFramework::class;

    protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';

    protected static ?string $modelLabel = 'Référentiel';

    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                Forms\Components\Section::make()
                    ->schema([
                        Forms\Components\TextInput::make('title')
                            ->label('Intitulé')
                    ]),
                Forms\Components\Section::make('Compétences')
                    ->schema([
                        Forms\Components\Repeater::make('competencies')
                            ->relationship()
                            ->label('')
                            ->addActionLabel('Nouvelle compétence')
                            ->simple(Forms\Components\TextInput::make('title'))
                            ->defaultItems(0)
                    ])
            ]);
    }


Help would be much appreciated 🙂
image.png
01.png
Was this page helpful?