Yes, you can bulk update the attended field for all users in a particular class by using the updateExistingPivot method with a closure. Here's an example of how you can achieve this:
$oclass->users()->updateExistingPivot($userId, function ($pivot) {
$pivot->attended = true;
});
In this example, $oclass is the instance of the OrientationClass model, and $userId is the ID of the user you want to update. However, since you want to update all users in the class, you can omit the $userId parameter.
$oclass->users()->updateExistingPivot(null, function ($pivot) {
$pivot->attended = true;
});
This will update the attended field to true for all users associated with the $oclass model.
Note that the closure passed to updateExistingPivot receives the pivot model as an argument, allowing you to modify its properties. In this case, we're setting the attended property to true.
Make sure to replace users() with the appropriate method name that defines the relationship between the OrientationClass and User models in your code.