Answer the question
In order to leave comments, you need to log in
Synchronization/updating related laravel models, how to do it normally?
There are 2 related models, how to synchronize correctly?
class Site extends Model
{
public function phrase()
{
return $this->hasOne(Phrase::class, 'site_id', 'id');
}
}
$phrases = [];
foreach ($request->get('phrases') as $phrase) {
$phrases[] = (new Phrase());
}
$site->phrase()->sync($phrases);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question