blue-twilight/app/Traits/ActivatesUsers.php

35 lines
876 B
PHP
Raw Permalink Normal View History

<?php
namespace App\Traits;
use App\Notifications\UserSelfActivated;
use App\User;
use App\UserActivity;
trait ActivatesUsers
{
private function logActivatedActivity(User $createdUser, $activityDateTime = null)
{
if (is_null($activityDateTime))
{
$activityDateTime = new \DateTime();
}
$userActivity = new UserActivity();
$userActivity->user_id = $createdUser->id;
$userActivity->activity_at = $activityDateTime;
$userActivity->type = 'user.created';
$userActivity->save();
}
private function sendUserActivatedEmails(User $createdUser)
{
$adminUsers = User::where('is_admin', true)->get();
/** @var User $adminUser */
foreach ($adminUsers as $adminUser)
{
$adminUser->notify(new UserSelfActivated($createdUser));
}
}
}