| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
-
- namespace App\Http\Controllers\v3\Auth;
-
- use App\Http\Controllers\Controller;
- use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Auth;
- use Illuminate\Support\Facades\Log;
-
- use Hash;
- use Carbon\Carbon;
- use Validator;
-
- use App\LatestModel\Staff;
-
- class ForgotPasswordController extends Controller
- {
- /*
- |--------------------------------------------------------------------------
- | Password Reset Controller
- |--------------------------------------------------------------------------
- |
- | This controller is responsible for handling password reset emails and
- | includes a trait which assists in sending these notifications from
- | your application to your users. Feel free to explore this trait.
- |
- */
-
- use SendsPasswordResetEmails;
-
- /**
- * Create a new controller instance.
- *
- * @return void
- */
-
- public function checkEmail(Request $request){
- $this->validate($request, [
- 'email' => 'required|email',
- ]);
-
- $user = '';
- $roles_access = '';
- if($request->has('role_access')){
- if($request->role_access == 'contractor'){
- $roles_access = 'Contractor';
- }else if($request->role_access == 'customer-service'){
- $roles_access = 'Customer Service';
- }else if($request->role_access == 'marketing'){
- $roles_access = 'Marketing';
- }else if($request->role_access == 'dealer'){
- $roles_access = 'Dealer';
- }else if($request->role_access == 'sales'){
- $roles_access = 'Sales';
- }
- }
-
- if($request->has('password')){
-
- $validator = Validator::make($request->all(), [
- 'password' => 'min:8|confirmed',
- ]);
-
- $user = Staff::where('email', $request->email)->where('roles_access',$roles_access)->first();
- if (!empty($user)) {
- $encryptP = Hash::make($request->get('password'));
-
- $user->password = $encryptP;
- $user->save();
- $user->StaffDetail->password = $encryptP;
- $user->StaffDetail->save();
-
- return redirect('/v3')->with('success_msg', 'Success! update password');
-
- }else{
- return redirect()->back()->withInput()->with('error_msg','Staff id not found');
- }
- }else{
- $user = Staff::where('email', $request->email)->where('roles_access',$roles_access)->first();
- if (!empty($user)) {
- // return redirect()->back()->withInput()->with('success_msg', 'Success! update password');
- return redirect()->back()->withInput()->with('success_msg', 'Email found');
- }else{
- return redirect()->back()->withInput()->with('error_msg','Email / roles not found');
- }
- }
- }
- }
|