laravel attach by name code example
Example: laravel attach
//id for single
$user->reasons->attach($reasonId);
//array for multiple
$user->reasons->attach($reasonIds);
$user->save();
//id for single
$user->reasons->attach($reasonId);
//array for multiple
$user->reasons->attach($reasonIds);
$user->save();