F
Filamentβ€’4w ago
Chinese

problem with user_id

Cannot add or update a child row: a foreign key constraint fails
16 Replies
Chinese
ChineseOPβ€’4w ago
No description
Chinese
ChineseOPβ€’4w ago
No description
Chinese
ChineseOPβ€’4w ago
No description
Tim van Heugten
Tim van Heugtenβ€’4w ago
You are trying to insert a row without a user_id
Chinese
ChineseOPβ€’4w ago
I want to get my user_id from the users table.
No description
Chinese
ChineseOPβ€’4w ago
I worked in filament, but I forgot. I worked a year ago, and if you don't practice, you forget.
Lara Zeus
Lara Zeusβ€’4w ago
share the code. where is this happens? is this in a relation manager or a form? maybe you need a select for the user id? or you want the user_id from the session?
Chinese
ChineseOPβ€’4w ago
I want it to somehow, when a post is created, take the user_id that is logged in, and show my name after it.
Chinese
ChineseOPβ€’4w ago
Chinese
ChineseOPβ€’4w ago
That's how chatgpt gave me, and it still didn't work, maybe the project is compromised, I don't know Anyway, it's a project for college, and I have to present it in 10 minutes, I don't know if I'll continue it, maybe to practice.
ChesterS
ChesterSβ€’4w ago
Wow this thread is wild. ChatGPT + Limewire ?! What a combination of old and new!
Chinese
ChineseOPβ€’4w ago
Ahahhaha Very funny I don't use git It seems much more challenging to me that way, in case I make a mistake, everything will be screwed. if I use commits or branches, I can go back to the last commit Where is the challenge in trying to debug?
Illizian
Illizianβ€’4w ago
Download this rar from Limewire..... πŸ˜‚.... Yeah, no, thanks
Chinese
ChineseOPβ€’4w ago
do as you wish I am not a scoundrel, and I never will be. Because I have money. I couldn't find another file uploader, I found the first one when I searched
Illizian
Illizianβ€’4w ago
For the Resource, find the CreateRecord Page, and add a method like this:
protected function handleRecordCreation(array $data): Model
{
$data['user_id'] = request()->user()->id;

return static::getModel()::create($data);
}
protected function handleRecordCreation(array $data): Model
{
$data['user_id'] = request()->user()->id;

return static::getModel()::create($data);
}

Did you find this page helpful?