@@ -3,12 +3,12 @@ |
||
| 3 | 3 | namespace plunner\Http\Controllers\Employees\Auth; |
| 4 | 4 | |
| 5 | 5 | use Illuminate\Http\Request; |
| 6 | -use plunner\Company; |
|
| 7 | -use plunner\employee; |
|
| 8 | -use plunner\Http\Controllers\Controller; |
|
| 9 | 6 | use Tymon\JWTAuth\Support\auth\AuthenticatesAndRegistersUsers; |
| 10 | 7 | use Tymon\JWTAuth\Support\auth\ThrottlesLogins; |
| 11 | 8 | use Validator; |
| 9 | +use plunner\Company; |
|
| 10 | +use plunner\Http\Controllers\Controller; |
|
| 11 | +use plunner\employee; |
|
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * Class AuthController |
@@ -42,13 +42,13 @@ discard block |
||
| 42 | 42 | * en = employee normal |
| 43 | 43 | * @var array |
| 44 | 44 | */ |
| 45 | - protected $custom = ['mode' => 'en']; |
|
| 45 | + protected $custom = [ 'mode' => 'en' ]; |
|
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * unique identifiers of the user |
| 49 | 49 | * @var array |
| 50 | 50 | */ |
| 51 | - protected $usernames = ['company_id', 'email']; |
|
| 51 | + protected $usernames = [ 'company_id', 'email' ]; |
|
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | 54 | * @var company |
@@ -61,13 +61,13 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | public function __construct() |
| 63 | 63 | { |
| 64 | - config(['auth.model' => \plunner\Employee::class]); |
|
| 65 | - config(['jwt.user' => \plunner\Employee::class]); |
|
| 64 | + config([ 'auth.model' => \plunner\Employee::class ]); |
|
| 65 | + config([ 'jwt.user' => \plunner\Employee::class ]); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | public function postRegister(Request $request) |
| 69 | 69 | { |
| 70 | - $this->validate($request, ['company' => 'required|exists:companies,name']); |
|
| 70 | + $this->validate($request, [ 'company' => 'required|exists:companies,name' ]); |
|
| 71 | 71 | $this->company = Company::whereName($request->input('company'))->firstOrFail(); |
| 72 | 72 | return $this->postRegisterOriginal($request); |
| 73 | 73 | } |
@@ -75,17 +75,17 @@ discard block |
||
| 75 | 75 | public function postLogin(Request $request) |
| 76 | 76 | { |
| 77 | 77 | //get company ID and impiled it in the request |
| 78 | - $this->validate($request, ['company' => 'required|exists:companies,name']); |
|
| 78 | + $this->validate($request, [ 'company' => 'required|exists:companies,name' ]); |
|
| 79 | 79 | $this->company = Company::whereName($request->input('company'))->firstOrFail(); |
| 80 | - $request->merge(['company_id' => $this->company->id]); |
|
| 80 | + $request->merge([ 'company_id' => $this->company->id ]); |
|
| 81 | 81 | |
| 82 | 82 | //remember me |
| 83 | - $this->validate($request, ['remember' => 'required|boolean']); |
|
| 83 | + $this->validate($request, [ 'remember' => 'required|boolean' ]); |
|
| 84 | 84 | if ($request->input('remember', false)) { |
| 85 | - config(['jwt.ttl' => '43200']); //30 days |
|
| 86 | - $this->custom = array_merge($this->custom, ['remember' => 'true']); |
|
| 85 | + config([ 'jwt.ttl' => '43200' ]); //30 days |
|
| 86 | + $this->custom = array_merge($this->custom, [ 'remember' => 'true' ]); |
|
| 87 | 87 | } else |
| 88 | - $this->custom = array_merge($this->custom, ['remember' => 'false']); |
|
| 88 | + $this->custom = array_merge($this->custom, [ 'remember' => 'false' ]); |
|
| 89 | 89 | |
| 90 | 90 | return $this->postLoginOriginal($request); |
| 91 | 91 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | { |
| 101 | 101 | return Validator::make($data, [ |
| 102 | 102 | 'name' => 'required|min:1|max:255', |
| 103 | - 'email' => 'required|email|max:255|unique:employees,email,NULL,id,company_id,' . $this->company->id, |
|
| 103 | + 'email' => 'required|email|max:255|unique:employees,email,NULL,id,company_id,'.$this->company->id, |
|
| 104 | 104 | 'password' => 'required|confirmed|min:6', |
| 105 | 105 | ]); |
| 106 | 106 | } |
@@ -114,9 +114,9 @@ discard block |
||
| 114 | 114 | protected function create(array $data) |
| 115 | 115 | { |
| 116 | 116 | return $this->company->save(new employee([ |
| 117 | - 'name' => $data['name'], |
|
| 118 | - 'email' => $data['email'], |
|
| 119 | - 'password' => bcrypt($data['password']), |
|
| 117 | + 'name' => $data[ 'name' ], |
|
| 118 | + 'email' => $data[ 'email' ], |
|
| 119 | + 'password' => bcrypt($data[ 'password' ]), |
|
| 120 | 120 | ])); |
| 121 | 121 | } |
| 122 | 122 | } |