123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- <?php
- namespace App\Http\Controllers\TeacherAuth;
- use Validator;
- use App\Http\Controllers\Controller;
- use Illuminate\Http\Request;
- use Illuminate\Foundation\Auth\RegistersUsers;
- use Illuminate\Support\Facades\Auth;
- use App\Mail\SignUp;
- use App\User;
- use App\Models\Department;
- use Hash;
- use Mail;
- class RegisterController extends Controller
- {
- /*
- |--------------------------------------------------------------------------
- | Register Controller
- |--------------------------------------------------------------------------
- |
- | This controller handles the registration of new users as well as their
- | validation and creation. By default this controller uses a trait to
- | provide this functionality without requiring any additional code.
- |
- */
- //use RegistersUsers;
- /**
- * Where to redirect users after login / registration.
- *
- * @var string
- */
- //protected $redirectTo = '/login-v2';
- /**
- * Create a new controller instance.
- *
- * @return void
- */
- public function __construct()
- {
- $this->middleware('teacher.guest');
- }
- protected function validator(array $data)
- {
- return Validator::make($data, [
- 'firstname' => ['required', 'string', 'max:255'],
- 'lastname' => ['required', 'string', 'max:255'],
- 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
- 'password' => ['required', 'string', 'min:8', 'confirmed'],
- //'phonenumber' => ['required', 'string', 'max:255'],
- 'universityname' => ['required', 'string', 'max:255'],
- 'department' => ['required', 'string', 'max:255'],
- 'designation' => ['required', 'string', 'max:255'],
- 'universitywebsite' => ['required', 'string', 'max:255'],
- ]);
- }
- /**
- * Create a new user instance after a valid registration.
- *
- * @param array $data
- * @return User
- */
- protected function create(Request $req)
- {
- $user_data = User::create([
- 'first_name' => $req->firstname,
- 'last_name' => $req->lastname,
- 'password' => Hash::make($req->password),
- 'email' => $req->email,
- // 'phone_number' => $req->phonenumber,
- 'university_name' => $req->universityname,
- 'department' => $req->department,
- 'others_department' => $req->others_department,
- 'designation' => $req->designation,
- 'uni_website' => $req->universitywebsite,
- 'user_type' => $req->user_type,
- 'ref_no' => name_initials($req->firstname,$req->lastname).''.teacherRefNoGenerate(),
- ]);
- //Mail::to('test@mail.com')->send(new SignUp($data->id));
- // $data['name'] = $user_data->first_name.' '.$user_data->last_name;
- // $user_mail = $user_data->email;
- // $from = 'test@mail.com';
- // Mail::send('email.send_apply_student_teacher_email',$data, function ($message) use ($user_mail,$from) {
- // $message->from($from);
- // $message->to($user_mail)->subject('New Email Send to you');
- // });
- return redirect()->to("/login-v2")->with('success','Your registration successfully saved. Please check your email for verification login.');
- }
- /**
- * Show the application registration form.
- *
- * @return \Illuminate\Http\Response
- */
- public function showRegistrationForm()
- {
- $departments =Department::where('status',1)->orderBy('name','ASC')->get();
- return view('register-v2',compact('departments'));
- }
- /**
- * Get the guard to be used during registration.
- *
- * @return \Illuminate\Contracts\Auth\StatefulGuard
- */
- protected function guard()
- {
- return Auth::guard('teacher');
- }
- }
|