@@ -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 | } |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @var array |
55 | 55 | */ |
56 | - protected $fillable = ['name', 'email', 'password']; |
|
56 | + protected $fillable = [ 'name', 'email', 'password' ]; |
|
57 | 57 | |
58 | 58 | /** |
59 | 59 | * The attributes excluded from the model's JSON form. |
60 | 60 | * |
61 | 61 | * @var array |
62 | 62 | */ |
63 | - protected $hidden = ['password', 'remember_token']; |
|
63 | + protected $hidden = [ 'password', 'remember_token' ]; |
|
64 | 64 | |
65 | 65 | /** |
66 | 66 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | public function belongsToGroup(Group $group) |
115 | 115 | { |
116 | 116 | $group = $this->groups()->where('id', $group->id)->first(); |
117 | - if(is_object($group) && $group->exists) |
|
117 | + if (is_object($group) && $group->exists) |
|
118 | 118 | return true; |
119 | 119 | return false; |
120 | 120 | } |
@@ -114,8 +114,9 @@ |
||
114 | 114 | public function belongsToGroup(Group $group) |
115 | 115 | { |
116 | 116 | $group = $this->groups()->where('id', $group->id)->first(); |
117 | - if(is_object($group) && $group->exists) |
|
118 | - return true; |
|
117 | + if(is_object($group) && $group->exists) { |
|
118 | + return true; |
|
119 | + } |
|
119 | 120 | return false; |
120 | 121 | } |
121 | 122 |
@@ -18,65 +18,65 @@ |
||
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 | //example |
54 | - Route::resource('example', 'ExampleController', ['except' => ['create', 'edit']]); //TODO remove |
|
54 | + Route::resource('example', 'ExampleController', [ 'except' => [ 'create', 'edit' ] ]); //TODO remove |
|
55 | 55 | }); |
56 | 56 | |
57 | 57 | |
58 | 58 | /** |
59 | 59 | * Employees |
60 | 60 | */ |
61 | -Route::group(['namespace' => 'Employees', 'prefix' => 'employees'], function() { |
|
61 | +Route::group([ 'namespace' => 'Employees', 'prefix' => 'employees' ], function() { |
|
62 | 62 | //\Auth |
63 | 63 | |
64 | - Route::group(['namespace' => 'Auth'], function() { |
|
65 | - Route::group(['prefix' => 'auth'], function () { |
|
64 | + Route::group([ 'namespace' => 'Auth' ], function() { |
|
65 | + Route::group([ 'prefix' => 'auth' ], function() { |
|
66 | 66 | // Authentication routes... |
67 | - Route::post('login', ['as' => 'companies.auth.login', 'uses'=>'AuthController@postLogin']); |
|
67 | + Route::post('login', [ 'as' => 'companies.auth.login', 'uses'=>'AuthController@postLogin' ]); |
|
68 | 68 | |
69 | 69 | // Registration routes... |
70 | 70 | //Route::post('register', ['as' => 'companies.auth.register', 'uses'=>'AuthController@postRegister']); //the registration is managed by the company |
71 | 71 | |
72 | 72 | }); |
73 | 73 | |
74 | - Route::group(['prefix' => 'password'], function () { |
|
74 | + Route::group([ 'prefix' => 'password' ], function() { |
|
75 | 75 | // Password reset link request routes... |
76 | - Route::post('email', ['as' => 'companies.auth.email', 'uses'=>'PasswordController@postEmail']); |
|
76 | + Route::post('email', [ 'as' => 'companies.auth.email', 'uses'=>'PasswordController@postEmail' ]); |
|
77 | 77 | |
78 | 78 | // Password reset routes... |
79 | - Route::post('reset', ['as' => 'companies.auth.reset', 'uses'=>'PasswordController@postReset']); |
|
79 | + Route::post('reset', [ 'as' => 'companies.auth.reset', 'uses'=>'PasswordController@postReset' ]); |
|
80 | 80 | }); |
81 | 81 | }); |
82 | 82 |