Support the ongoing development of Laravel.io →
Authentication Session Database

got a problem here. dunno how to fix

in user.php

#SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (prism.rfq_table, CONSTRAINT rfq_table_userid_foreign FOREIGN KEY (userid) REFERENCES users (id) ON DELETE CASCADE ON UPDATE CASCADE) (SQL: insert into rfq_table (projectStart, projectEnd, budgetMax, budgetMin, itemDetails, qty, itemName, updated_at, created_at) values (1996-03-04, 1992-03-04, 50, 200, lkdad, 21, lskadkasd, 2017-03-04 07:05:08, 2017-03-04 07:05:08))

RFQ Controller.php

public function store(Request $request)
{

        $user=Auth::user();
        $rfq= $user->rfq_table()->create($request->all());
        return redirect()->route('rfq.index');

 }

User.php


  public function rfq_table()

    {

        return $this->belongsTo(RFQ::class);

    }
Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

ndar0430 ndar0430 Joined 23 Feb 2017

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.