@@ -3,8 +3,8 @@ |
||
3 | 3 | namespace plunner\Http\Controllers\Companies\Groups; |
4 | 4 | |
5 | 5 | use Illuminate\Support\Facades\Response; |
6 | -use plunner\Group; |
|
7 | 6 | use plunner\Employee; |
7 | +use plunner\Group; |
|
8 | 8 | use plunner\Http\Controllers\Controller; |
9 | 9 | use plunner\Http\Requests\Companies\Groups\EmployeeRequest; |
10 | 10 |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function __construct() |
23 | 23 | { |
24 | - config(['auth.model' => \plunner\Company::class]); |
|
25 | - config(['jwt.user' => \plunner\Company::class]); |
|
24 | + config([ 'auth.model' => \plunner\Company::class ]); |
|
25 | + config([ 'jwt.user' => \plunner\Company::class ]); |
|
26 | 26 | $this->middleware('jwt.authandrefresh:mode-cn'); |
27 | 27 | } |
28 | 28 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | // |
54 | 54 | $group = Group::findOrFail($groupId); |
55 | 55 | $this->authorize($group); |
56 | - $id = $request->all()['id']; |
|
56 | + $id = $request->all()[ 'id' ]; |
|
57 | 57 | $group->employees()->attach($id); |
58 | 58 | return $group->employees; |
59 | 59 | } |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | $employee = Employee::findOrFail($employeeId); |
72 | 72 | $this->authorize($employee); |
73 | 73 | $group = Group::findOrFail($groupId); |
74 | - if(!$employee->belongsToGroup($group)) |
|
75 | - return Response::json(['error' => 'employId <> groupId'],404); |
|
74 | + if (!$employee->belongsToGroup($group)) |
|
75 | + return Response::json([ 'error' => 'employId <> groupId' ], 404); |
|
76 | 76 | $employee->groups()->detach($groupId); |
77 | 77 | return $group->employees; |
78 | 78 | } |
@@ -71,8 +71,9 @@ |
||
71 | 71 | $employee = Employee::findOrFail($employeeId); |
72 | 72 | $this->authorize($employee); |
73 | 73 | $group = Group::findOrFail($groupId); |
74 | - if(!$employee->belongsToGroup($group)) |
|
75 | - return Response::json(['error' => 'employId <> groupId'],404); |
|
74 | + if(!$employee->belongsToGroup($group)) { |
|
75 | + return Response::json(['error' => 'employId <> groupId'],404); |
|
76 | + } |
|
76 | 77 | $employee->groups()->detach($groupId); |
77 | 78 | return $group->employees; |
78 | 79 | } |
@@ -61,7 +61,7 @@ |
||
61 | 61 | */ |
62 | 62 | public function verifyEmployee(Employee $employee) |
63 | 63 | { |
64 | - $group = $this->groupsManaged()->whereHas('employees',function ($query) use ($employee) {$query->where('employees.id', $employee->id);})->first(); |
|
64 | + $group = $this->groupsManaged()->whereHas('employees', function($query) use ($employee) {$query->where('employees.id', $employee->id); })->first(); |
|
65 | 65 | |
66 | 66 | return (is_object($group) && $group->exists); |
67 | 67 | } |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function __construct() |
23 | 23 | { |
24 | - config(['auth.model' => \plunner\Company::class]); |
|
25 | - config(['jwt.user' => \plunner\Company::class]); |
|
24 | + config([ 'auth.model' => \plunner\Company::class ]); |
|
25 | + config([ 'jwt.user' => \plunner\Company::class ]); |
|
26 | 26 | $this->middleware('jwt.authandrefresh:mode-cn'); |
27 | 27 | } |
28 | 28 | |
@@ -53,8 +53,8 @@ discard block |
||
53 | 53 | // |
54 | 54 | $company = \Auth::user(); |
55 | 55 | $input = $request->all(); |
56 | - if(isset($input['password'])) |
|
57 | - $input['password'] = bcrypt($input['password']); |
|
56 | + if (isset($input[ 'password' ])) |
|
57 | + $input[ 'password' ] = bcrypt($input[ 'password' ]); |
|
58 | 58 | $employee = $company->employees()->create($input); |
59 | 59 | return $employee; |
60 | 60 | } |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | $employee = Employee::findOrFail($id); |
87 | 87 | $this->authorize($employee); |
88 | 88 | $input = $request->all(); |
89 | - if(isset($input['password'])) |
|
90 | - $input['password'] = bcrypt($input['password']); |
|
89 | + if (isset($input[ 'password' ])) |
|
90 | + $input[ 'password' ] = bcrypt($input[ 'password' ]); |
|
91 | 91 | $employee->update($input); |
92 | 92 | return $employee; |
93 | 93 | } |
@@ -53,8 +53,9 @@ discard block |
||
53 | 53 | // |
54 | 54 | $company = \Auth::user(); |
55 | 55 | $input = $request->all(); |
56 | - if(isset($input['password'])) |
|
57 | - $input['password'] = bcrypt($input['password']); |
|
56 | + if(isset($input['password'])) { |
|
57 | + $input['password'] = bcrypt($input['password']); |
|
58 | + } |
|
58 | 59 | $employee = $company->employees()->create($input); |
59 | 60 | return $employee; |
60 | 61 | } |
@@ -86,8 +87,9 @@ discard block |
||
86 | 87 | $employee = Employee::findOrFail($id); |
87 | 88 | $this->authorize($employee); |
88 | 89 | $input = $request->all(); |
89 | - if(isset($input['password'])) |
|
90 | - $input['password'] = bcrypt($input['password']); |
|
90 | + if(isset($input['password'])) { |
|
91 | + $input['password'] = bcrypt($input['password']); |
|
92 | + } |
|
91 | 93 | $employee->update($input); |
92 | 94 | return $employee; |
93 | 95 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * cn = company normal |
32 | 32 | * @var array |
33 | 33 | */ |
34 | - protected $custom = ['mode'=>'cn']; |
|
34 | + protected $custom = [ 'mode'=>'cn' ]; |
|
35 | 35 | |
36 | 36 | |
37 | 37 | /** |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function __construct() |
43 | 43 | { |
44 | - config(['auth.model' => \plunner\Company::class]); |
|
45 | - config(['jwt.user' => \plunner\Company::class]); |
|
46 | - config(['auth.password.table' => 'password_resets_companies', 'auth.password.email' => 'emails.companies.password']); |
|
44 | + config([ 'auth.model' => \plunner\Company::class ]); |
|
45 | + config([ 'jwt.user' => \plunner\Company::class ]); |
|
46 | + config([ 'auth.password.table' => 'password_resets_companies', 'auth.password.email' => 'emails.companies.password' ]); |
|
47 | 47 | } |
48 | 48 | } |
@@ -38,12 +38,12 @@ discard block |
||
38 | 38 | * en = employee normal |
39 | 39 | * @var array |
40 | 40 | */ |
41 | - protected $custom = ['mode'=>'en']; |
|
41 | + protected $custom = [ 'mode'=>'en' ]; |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * @var array |
45 | 45 | */ |
46 | - protected $username = ['email', 'company_id']; |
|
46 | + protected $username = [ 'email', 'company_id' ]; |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * @var company |
@@ -57,24 +57,24 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function __construct() |
59 | 59 | { |
60 | - config(['auth.model' => \plunner\Employee::class]); |
|
61 | - config(['jwt.user' => \plunner\Employee::class]); |
|
62 | - config(['auth.password.table' => 'password_resets_employees', 'auth.password.email' => 'emails.employees.password']); |
|
60 | + config([ 'auth.model' => \plunner\Employee::class ]); |
|
61 | + config([ 'jwt.user' => \plunner\Employee::class ]); |
|
62 | + config([ 'auth.password.table' => 'password_resets_employees', 'auth.password.email' => 'emails.employees.password' ]); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | public function postEmail(Request $request) |
66 | 66 | { |
67 | - $this->validate($request, ['company' => 'required|exists:companies,name']); |
|
67 | + $this->validate($request, [ 'company' => 'required|exists:companies,name' ]); |
|
68 | 68 | $this->company = Company::whereName($request->input('company'))->firstOrFail(); |
69 | - $request->merge(['company_id' => $this->company->id]); |
|
69 | + $request->merge([ 'company_id' => $this->company->id ]); |
|
70 | 70 | return $this->postEmailOriginal($request); |
71 | 71 | } |
72 | 72 | |
73 | 73 | public function postReset(Request $request) |
74 | 74 | { |
75 | - $this->validate($request, ['company' => 'required|exists:companies,name']); |
|
75 | + $this->validate($request, [ 'company' => 'required|exists:companies,name' ]); |
|
76 | 76 | $this->company = Company::whereName($request->input('company'))->firstOrFail(); |
77 | - $request->merge(['company_id' => $this->company->id]); |
|
77 | + $request->merge([ 'company_id' => $this->company->id ]); |
|
78 | 78 | return $this->postResetOriginal($request); |
79 | 79 | } |
80 | 80 |
@@ -22,7 +22,7 @@ |
||
22 | 22 | { |
23 | 23 | |
24 | 24 | // Don't validate CSRF when testing. |
25 | - if(env('APP_ENV') === 'testing') { |
|
25 | + if (env('APP_ENV') === 'testing') { |
|
26 | 26 | return true; |
27 | 27 | } |
28 | 28 |
@@ -18,36 +18,36 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * Companies |
20 | 20 | */ |
21 | -Route::group(['namespace' => 'Companies', 'prefix' => 'companies'], function() { |
|
21 | +Route::group([ 'namespace' => 'Companies', 'prefix' => 'companies' ], function() { |
|
22 | 22 | |
23 | 23 | //\Auth |
24 | 24 | |
25 | - Route::group(['namespace' => 'Auth'], function() { |
|
26 | - Route::group(['prefix' => 'auth'], function () { |
|
25 | + Route::group([ 'namespace' => 'Auth' ], function() { |
|
26 | + Route::group([ 'prefix' => 'auth' ], function() { |
|
27 | 27 | // Authentication routes... |
28 | - Route::post('login', ['as' => 'companies.auth.login','uses'=>'AuthController@postLogin']); |
|
28 | + Route::post('login', [ 'as' => 'companies.auth.login', 'uses'=>'AuthController@postLogin' ]); |
|
29 | 29 | |
30 | 30 | // Registration routes... |
31 | - Route::post('register', ['as' => 'companies.auth.register', 'uses'=>'AuthController@postRegister']); |
|
31 | + Route::post('register', [ 'as' => 'companies.auth.register', 'uses'=>'AuthController@postRegister' ]); |
|
32 | 32 | |
33 | 33 | }); |
34 | 34 | |
35 | - Route::group(['prefix' => 'password'], function () { |
|
35 | + Route::group([ 'prefix' => 'password' ], function() { |
|
36 | 36 | // Password reset link request routes... |
37 | - Route::post('email', ['as' => 'companies.auth.email', 'uses'=>'PasswordController@postEmail']); |
|
37 | + Route::post('email', [ 'as' => 'companies.auth.email', 'uses'=>'PasswordController@postEmail' ]); |
|
38 | 38 | |
39 | 39 | // Password reset routes... |
40 | - Route::post('reset', ['as' => 'companies.auth.reset', 'uses'=>'PasswordController@postReset']); |
|
40 | + Route::post('reset', [ 'as' => 'companies.auth.reset', 'uses'=>'PasswordController@postReset' ]); |
|
41 | 41 | }); |
42 | 42 | }); |
43 | 43 | |
44 | - Route::group(['namespace' => 'Employees'], function() { |
|
45 | - Route::resource('employees', 'EmployeesController', ['except' => ['create', 'edit']]); |
|
44 | + Route::group([ 'namespace' => 'Employees' ], function() { |
|
45 | + Route::resource('employees', 'EmployeesController', [ 'except' => [ 'create', 'edit' ] ]); |
|
46 | 46 | }); |
47 | 47 | |
48 | - Route::group(['namespace' => 'Groups'], function() { |
|
49 | - Route::resource('groups', 'GroupsController', ['except' => ['create', 'edit']]); |
|
50 | - Route::resource('groups.employees', 'EmployeesController', ['only' => ['store', 'index', 'destroy']]); |
|
48 | + Route::group([ 'namespace' => 'Groups' ], function() { |
|
49 | + Route::resource('groups', 'GroupsController', [ 'except' => [ 'create', 'edit' ] ]); |
|
50 | + Route::resource('groups.employees', 'EmployeesController', [ 'only' => [ 'store', 'index', 'destroy' ] ]); |
|
51 | 51 | }); |
52 | 52 | }); |
53 | 53 | |
@@ -55,25 +55,25 @@ discard block |
||
55 | 55 | /** |
56 | 56 | * Employees |
57 | 57 | */ |
58 | -Route::group(['namespace' => 'Employees', 'prefix' => 'employees'], function() { |
|
58 | +Route::group([ 'namespace' => 'Employees', 'prefix' => 'employees' ], function() { |
|
59 | 59 | //\Auth |
60 | 60 | |
61 | - Route::group(['namespace' => 'Auth'], function() { |
|
62 | - Route::group(['prefix' => 'auth'], function () { |
|
61 | + Route::group([ 'namespace' => 'Auth' ], function() { |
|
62 | + Route::group([ 'prefix' => 'auth' ], function() { |
|
63 | 63 | // Authentication routes... |
64 | - Route::post('login', ['as' => 'companies.auth.login', 'uses'=>'AuthController@postLogin']); |
|
64 | + Route::post('login', [ 'as' => 'companies.auth.login', 'uses'=>'AuthController@postLogin' ]); |
|
65 | 65 | |
66 | 66 | // Registration routes... |
67 | 67 | //Route::post('register', ['as' => 'companies.auth.register', 'uses'=>'AuthController@postRegister']); //the registration is managed by the company |
68 | 68 | |
69 | 69 | }); |
70 | 70 | |
71 | - Route::group(['prefix' => 'password'], function () { |
|
71 | + Route::group([ 'prefix' => 'password' ], function() { |
|
72 | 72 | // Password reset link request routes... |
73 | - Route::post('email', ['as' => 'companies.auth.email', 'uses'=>'PasswordController@postEmail']); |
|
73 | + Route::post('email', [ 'as' => 'companies.auth.email', 'uses'=>'PasswordController@postEmail' ]); |
|
74 | 74 | |
75 | 75 | // Password reset routes... |
76 | - Route::post('reset', ['as' => 'companies.auth.reset', 'uses'=>'PasswordController@postReset']); |
|
76 | + Route::post('reset', [ 'as' => 'companies.auth.reset', 'uses'=>'PasswordController@postReset' ]); |
|
77 | 77 | }); |
78 | 78 | }); |
79 | 79 | }); |
80 | 80 | \ No newline at end of file |
@@ -34,7 +34,7 @@ |
||
34 | 34 | return [ |
35 | 35 | 'name' => 'required|max:255', |
36 | 36 | 'email' => 'required|email|max:255|unique:employees,email,'.$this->route('employees').',id,company_id,'.$this->user()->id, |
37 | - 'password' => ((\Route::current()->getName() == 'companies.employees.store')?'required|':'').'confirmed|min:6', |
|
37 | + 'password' => ((\Route::current()->getName() == 'companies.employees.store') ? 'required|' : '').'confirmed|min:6', |
|
38 | 38 | ]; |
39 | 39 | } |
40 | 40 | } |
@@ -16,7 +16,7 @@ |
||
16 | 16 | /** |
17 | 17 | * @var array |
18 | 18 | */ |
19 | - protected $touches = ['calendar']; |
|
19 | + protected $touches = [ 'calendar' ]; |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |