phplaravellivewires

Incorrect integer value: '{"id":1,"name":"Main Lab}' for column 'lab_id' at row 1


I get this error Incorrect integer value for column 'lab_id' at row 1

with dd($lab)

it returns 1

but if I fill the form and click submet it returns the error it should be gettin from mount function?

how can I fix that?

can any one help?


    public function submit()
    {
        $this->validate();
        $this->sample->received_at = now();
        $this->sample->lab_id = $this->lab;
        $this->sample->save();
        $this->message = "Sample {$this->samples->sample_id} Registered Successfully";
    }

   


Solution

  • Shouldn't it be $this->lab->id :

    $this->sample->lab_id = $this->lab;