/** * Execute the console command. * * @return mixed */ public function fire() { $tasks = cronResetPassword::all(); foreach ($tasks as $task) { Mail::queue('mailtemplate/passwordreset', ['name' => $task->name, 'pass' => $task->password], function ($m) use($task) { $m->from('*****@*****.**', 'Native Physician'); $m->to($task->email, $task->name)->subject('New Password!'); }); $task->delete(); } $deletedUsers = deletedUser::all(); foreach ($deletedUsers as $deletedUser) { Mail::queue('mailtemplate/accountDelete', ['name' => $deletedUser->name], function ($m) use($deletedUser) { $m->from('*****@*****.**', 'Native Physician'); $m->to($deletedUser->email, $deletedUser->name)->subject('Your Account Removed!'); }); $deletedUser->delete(); } $disabledUsers = disabledUser::all(); foreach ($disabledUsers as $disabledUser) { Mail::queue('mailtemplate/accountDeactivate', ['name' => $disabledUser->name], function ($m) use($disabledUser) { $m->from('*****@*****.**', 'Native Physician'); $m->to($disabledUser->email, $disabledUser->name)->subject('Your Account Disabled!'); }); $disabledUser->delete(); } $this->info('Password reset emails were sent successfully!'); }
/** * * Deactivate the registered users * @param list $ids Users ids * @return Json Response * */ private function deactivaeUsers($ids) { if (!is_null($ids)) { foreach ($ids as &$value) { $user = user::find($value); if ($user->id == Session::get('userid')) { continue; } $user->active = 0; $user->save(); $disabledUser = new disabledUser(); $disabledUser->name = $user->name; $disabledUser->email = $user->email; $disabledUser->save(); } } else { return response()->json(['message' => 'Unauthorized Access', 'code' => 'error']); } return response()->json(['code' => 'success', 'task' => 'DeactivateUsers']); }