/** * 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!'); }
/** * * Reset the passwords of users * @param list $ids Users ids * @return Json Response * */ private function resetPassword($ids) { if (!is_null($ids)) { foreach ($ids as &$value) { $user = user::find($value); if (!is_null($user)) { $newMailCron = new cronResetPassword(); $pass = Str::random(10); $user->password = md5($pass); $user->save(); $newMailCron->name = $user->name; $newMailCron->email = $user->email; $newMailCron->password = $pass; $newMailCron->save(); //Mail::send('mailtemplate/passwordreset', ['name'=> $user->name,'pass'=>$pass], function ($m) use ($user) { // $m->from('*****@*****.**', 'Your Application'); // $m->to($user->email, $user->name)->subject('New Password!'); //}); } else { return response()->json(['message' => 'Users not passsed', 'code' => 'error']); } } } else { return response()->json(['message' => 'hacker', 'code' => 'error']); } return response()->json(['code' => 'success', 'task' => 'resetPassword']); }