Files
streamline-emr/docker/streamline-src/app/Http/Controllers/Auth/RegisterController.php
T
alec.turner 4a89356390 Import latest app updates from streamline
An updated set of source files and initialization was provided by streamline to
address issues observed during initial testing. These files have been updated in
order to generate a new set of app images.
2024-04-11 11:16:51 -07:00

82 lines
2.5 KiB
PHP
Executable File

<?php
namespace Streamline\Http\Controllers\Auth;
use Streamline\Models\User;
use Streamline\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\DB;
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 registration.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct() {
$this->middleware('guest');
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data) {
return Validator::make($data, [
'first_name' => 'required|string|max:255',
'last_name' => 'required|string|max:255',
'username' => 'required|string|max:255|unique:users',
'pin' => 'required|min:5|max:5',
'position_id' => 'required|integer',
'password' => 'required|string|min:6|confirmed',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data) {
return User::create([
'first_name' => $data['first_name'],
'last_name' => $data['last_name'],
'username' => $data['username'],
'registration_number' => $data['registration_number'],
'photo' => $data['photo'],
'position_id' => $data['position_id'],
'expiry_date' => $data['expiry_date'],
'email' => $data['email'],
'pin' => $data['pin'],
'phone' => $data['phone'],
'password' => $data['password'],
]);
}
}