public function getActivateSchool($registration_code) { $school = Schools::where('registration_code', $registration_code)->where('active', 0); if ($school->count()) { $school = $school->first(); $school->active = 1; if ($school->save()) { $email_array = ['school_name' => $school->school_name, 'registration_code' => $school->registration_code, 'code_for_admin' => $school->code_for_admin, 'code_for_students' => $school->code_for_students, 'code_for_teachers' => $school->code_for_teachers, 'code_for_parents' => $school->code_for_parents]; if (!RequiredFunctions::checkIfTestEmail($school->email)) { //send email Mail::send('schools.emails.activate-school', $email_array, function ($message) use($school) { $message->to($school->email, $school->school_name)->subject('Register For Admin and Other Codes'); }); } return redirect(route('school-register'))->with('global', 'Your Account Have been activated. You have got mail with registration procedure explained.'); } } return redirect(route('school-register'))->with('global', 'Cant activate do after some time'); }
public function postRetrievePassword(Request $request) { $email = $request->input('email'); $validator = validator::make($request->all(), ['email' => 'required']); $account_sign_in_route = null; $account_create_route = null; if ($request->is(RequiredConstants::ADMIN_ROUTE)) { $account_create_route = route('account-admin-retrieve-password'); $account_sign_in_route = route('account-admin-sign-in'); } elseif ($request->is(RequiredConstants::USER_ROUTE)) { $account_create_route = route('account-user-retrieve-password'); $account_sign_in_route = route('account-user-sign-in'); } if ($validator->fails()) { $flash_data = 'You have some errors !!'; return redirect(route('account-user-retrieve-password'))->withErrors($validator->errors())->withInput()->withGlobal($flash_data); } else { $user = User::where('email', $email)->get()->first(); if ($user && $user->count() > 0) { if ($user->activated) { $user->reset_password_code = str_random(32); if ($user->save()) { // Send mail to the user if not the test Shop Id. $email_array = []; if (!RequiredFunctions::checkIfTestEmail($email)) { Mail::send('schools.emails.activate-school', $email_array, function ($message) use($user) { $message->to($user->email, 'Mr. Admin')->subject('Register For Admin and Other Codes'); }); } $flash_data = 'Thank You. You have been sent an email to reset your password.!!'; return redirect($account_sign_in_route)->withGlobal($flash_data); } else { $flash_data = 'Something went Wrong. Please Try again later!!'; return redirect($account_create_route)->withErrors($validator->errors())->withInput()->withGlobal($flash_data); } } else { $flash_data = 'User is not Activated !!'; return redirect($account_create_route)->withErrors($validator->errors())->withInput()->withGlobal($flash_data); } } else { $flash_data = 'Your Email is not Found. Retry with Correct Email Address!!'; return redirect($account_create_route)->withErrors($validator->errors())->withInput()->withGlobal($flash_data); } } }