Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated user observer class #172

Merged
merged 1 commit into from
Apr 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 13 additions & 14 deletions src/User/Observers/UserObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,37 @@

namespace AvoRed\Framework\User\Observers;

use AvoRed\Framework\Database\Contracts\ConfigurationModelInterface;
use AvoRed\Framework\Database\Contracts\UserGroupModelInterface;
use AvoRed\Framework\Widget\TotalCustomer;
use AvoRed\Framework\Database\Contracts\CustomerGroupModelInterface;
use AvoRed\Framework\Database\Repository\CustomerGroupRepository;

class UserObserver
{
/**
* UserGroup Repository for controller.
* @var \AvoRed\Framework\Database\Repository\UserGroupRepository
* @var CustomerGroupRepository
*/
protected $userGroupRepository;
protected $customerGroupRepository;

/**
* Construct for the AvoRed user group controller.
* @param \AvoRed\Framework\Database\Repository\UserGroupRepository $userGroupRepository
* @param CustomerGroupModelInterface $customerGroupRepository
*/
public function __construct(
UserGroupModelInterface $userGroupRepository
CustomerGroupModelInterface $customerGroupRepository
) {
$this->userGroupRepository = $userGroupRepository;
$this->customerGroupRepository = $customerGroupRepository;
}

/**
* Handle the User "created" event.
*
* @param mixed $user
* @param mixed $customer
* @return void
*/
public function created($user)
public function created($customer)
{
$userGroup = $this->userGroupRepository->getIsDefault();
$user->user_group_id = $userGroup->id;
$user->save();
$customerGroup = $this->customerGroupRepository->getIsDefault();
$customer->customer_group_id = $customerGroup->id;
$customer->save();
}
}