Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vidhyaprakash85's avatar

Repeater using hasMany - Added records to pivottable but error coming

Package

Form builder

Package Version

v.3.2

How can we help you?

I have a project resource which contains the below code

migration

Schema::create('project_student', function (Blueprint $table) {
            $table->increments('id');
            $table->foreignId('project_id')->constrained();
            $table->foreignId('student_id')->constrained();
            $table->foreignId('created_by')->nullable();
            $table->foreignId('updated_by')->nullable();
            $table->foreignId('deleted_by')->nullable();
            $table->ipAddress('created_ip')->nullable();
            $table->ipAddress('updated_ip')->nullable();
            $table->ipAddress('deleted_ip')->nullable();
            $table->timestamps();
            $table->softDeletes();

ProjectResource

Project Model

class Project extends Model
{
    use HasFactory, LogsActivity, UserImpression;

    protected $fillable = ['semester_id', 'teacher_id', 'level', 'title', 'section', 'status'];

    protected $casts = [
        'status' => ProjectStatus::class,
        'level' => LevelStatus::class,
    ];

    public function teacher()
    {
        return $this->belongsTo(User::class, 'teacher_id');
    }

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

ProjectStudent pivot table

class ProjectStudent extends Pivot
{
    use HasFactory, LogsActivity, UserImpression, SoftDeletes;
    protected $table = 'project_student';
    protected $fillable = ['project_id', 'student_id'];
    public $timestamps = true;
  
    public function student(): BelongsTo
    {
        return $this->belongsTo(Student::class, 'student_id', 'id');
    }
}

The issue is records are adding to pivot table but i am getting error like this

SQLSTATE[42S22]: Column not found: 1054 Unknown column '' in 'where clause' (Connection: mysql, SQL: select * from `project_student` where `` = 0 and `` = 0 limit 1)

Can anyone please help me in this

This is error body

{
    "_token": "sXF3piffUErzr7zfiFIiiWeAdD8AD9kNSrEH4Pvn",
    "components": [
        {
            "snapshot": "{"data":{"data":[{"id":3,"semester_id":1,"teacher_id":3,"level":"Bachelor","title":"BTECH","section":"1","status":"submitted","created_by":2,"updated_by":null,"deleted_by":null,"created_ip":"127.0.0.1","updated_ip":null,"deleted_ip":null,"created_at":"2024-12-10T17:03:53.000000Z","updated_at":"2024-12-10T17:03:53.000000Z","deleted_at":null,"students":[{"record-5":[{"id":5,"project_id":3,"student_id":1,"created_by":2,"updated_by":null,"deleted_by":null,"created_ip":"127.0.0.1","updated_ip":null,"deleted_ip":null,"created_at":"2024-12-10T17:03:53.000000Z","updated_at":"2024-12-10T17:03:53.000000Z","deleted_at":null},{"s":"arr"}],"aecf0f96-c6a7-45cc-838b-cb9beb587aca":[{"student_id":null},{"s":"arr"}]},{"s":"arr"}]},{"s":"arr"}],"previousUrl":"http://project_store.test/project/projects","mountedActions":[[],{"s":"arr"}],"mountedActionsArguments":[[],{"s":"arr"}],"mountedActionsData":[[],{"s":"arr"}],"defaultAction":null,"defaultActionArguments":null,"componentFileAttachments":[[],{"s":"arr"}],"mountedFormComponentActions":[[],{"s":"arr"}],"mountedFormComponentActionsArguments":[[],{"s":"arr"}],"mountedFormComponentActionsData":[[],{"s":"arr"}],"mountedFormComponentActionsComponents":[[],{"s":"arr"}],"mountedInfolistActions":[[],{"s":"arr"}],"mountedInfolistActionsData":[[],{"s":"arr"}],"mountedInfolistActionsComponent":null,"mountedInfolistActionsInfolist":null,"activeRelationManager":null,"record":[null,{"class":"AppModelsProject","key":3,"s":"mdl"}],"savedDataHash":null},"memo":{"id":"mbSFmMf4WLB4UTXhkEJE","name":"app.filament.resources.project-resource.pages.edit-project","path":"project/projects/3/edit","method":"GET","children":[],"scripts":[],"assets":[],"errors":[],"locale":"en"},"checksum":"35df54c25dbc5c157860847c063dcc30c07c78a4359cd4f246679ae60c753d8e"}",
            "updates": {
                "data.students.aecf0f96-c6a7-45cc-838b-cb9beb587aca.student_id": "64"
            },
            "calls": [
                {
                    "path": "",
                    "method": "save",
                    "params": []
                }
            ]
        }
    ]
}
0 likes
0 replies

Please or to participate in this conversation.