id_user = $user->id; $userPointSale->populateRelation('user', $user); $userPointSale->id_point_sale = $pointSale->id; $userPointSale->populateRelation('pointSale', $pointSale); if($comment) { $userPointSale->comment = $comment; } return $userPointSale; } public function createUserPointSale(User $user, PointSale $pointSale, string $comment = null): UserPointSale { $userPointSale = $this->instanciateUserPointSale($user, $pointSale, $comment); $userPointSale->save(); return $userPointSale; } public function deleteByPointSale(PointSale $pointSale): void { UserPointSale::deleteAll(['id_point_sale' => $pointSale->id]); } }