Link user to record.

Does Filament have some out of the box functionality which for example when you create an order, everyone can see who created the order? In other words: add the loggedin user to the order record? Or do I have to manually create the relation and add it to the order record?
Solution:
If you still want to solve this with Filament, you can do the following on the CreateRecord page: ```php protected function afterCreate(): void { $record = $this->getRecord();...
Jump to solution
3 Replies
Tobias Platen
Tobias Platen11mo ago
In Filament, there is nothing for that. But there are various Laravel packages that can do it. Take a look at wildside/userstamps, for example.
Solution
Tobias Platen
Tobias Platen11mo ago
If you still want to solve this with Filament, you can do the following on the CreateRecord page:
protected function afterCreate(): void
{
$record = $this->getRecord();
$record->user_id = Auth::user()->id;
$record->save();
}
protected function afterCreate(): void
{
$record = $this->getRecord();
$record->user_id = Auth::user()->id;
$record->save();
}
However, you should keep in mind that only models created from within Filament will have the user set.
JJSanders
JJSandersOP11mo ago
Ok thanks for your feedback
Want results from more Discord servers?
Add your server