add relationships to record during the creation process

I have a TagsInput::make('tags') and I want to take each of the tags and do something like $record->tags()->attach([tags]) I would need access to the created record and the data from the tags input Where is a good place to do this?
2 Replies
Giant Robo
Giant RoboOP3w ago
protected function handleRecordCreation(array $data): Model
{
return static::getModel()::create($data);
}
protected function handleRecordCreation(array $data): Model
{
return static::getModel()::create($data);
}
I should do the syncing in here do you think? can I do '
$record = static::getModel()::create($data);
$record->tags()->attach(...)
`return //what to return?
$record = static::getModel()::create($data);
$record->tags()->attach(...)
`return //what to return?

Did you find this page helpful?