Skip to content

Commit 96a5d06

Browse files
- Add grumphp package and add tasks for the git pre-commit
1 parent 938ab80 commit 96a5d06

File tree

255 files changed

+3063
-2503
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

255 files changed

+3063
-2503
lines changed

app/Exceptions/Handler.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
namespace App\Exceptions;
44

55
use Exception;
6-
use Illuminate\Auth\Access\AuthorizationException;
6+
use Illuminate\Support\Facades\Log;
77
use Illuminate\Auth\AuthenticationException;
8+
use Illuminate\Validation\ValidationException;
9+
use Illuminate\Auth\Access\AuthorizationException;
810
use Illuminate\Database\Eloquent\ModelNotFoundException;
9-
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
11+
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
1012
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
1113
use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException;
12-
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
13-
use Spatie\Permission\Exceptions\UnauthorizedException;
14-
use Illuminate\Validation\ValidationException;
15-
use Illuminate\Support\Facades\Log;
14+
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
1615

1716
/**
1817
* Class Handler.
@@ -56,15 +55,13 @@ public function report(Exception $exception)
5655
*
5756
* @param \Illuminate\Http\Request $request
5857
* @param \Exception $exception
59-
* @return \Symfony\Component\HttpFoundation\Response
60-
*
6158
* @throws \Exception
59+
* @return \Symfony\Component\HttpFoundation\Response
6260
*/
6361
public function render($request, Exception $exception)
6462
{
6563
if (strpos($request->url(), '/api/') !== false) {
66-
67-
Log::debug('API Request Exception - '.$request->url().' - '.$exception->getMessage().(!empty($request->all()) ? ' - '.json_encode($request->except(['password'])) : ''));
64+
Log::debug('API Request Exception - '.$request->url().' - '.$exception->getMessage().(! empty($request->all()) ? ' - '.json_encode($request->except(['password'])) : ''));
6865

6966
if ($exception instanceof AuthorizationException) {
7067
return $this->setStatusCode(403)->respondWithError($exception->getMessage());
@@ -146,7 +143,7 @@ protected function respondWithError($message)
146143
{
147144
return $this->respond([
148145
'error' => [
149-
'message' => $message,
146+
'message' => $message,
150147
'status_code' => $this->getStatusCode(),
151148
],
152149
]);

app/Helpers/Auth/Auth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ public function flushTempSession()
1717
session()->forget('admin_user_name');
1818
session()->forget('temp_user_id');
1919
}
20-
}
20+
}

app/Helpers/General/HtmlHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace App\Helpers\General;
44

5-
use Illuminate\Contracts\Routing\UrlGenerator;
65
use Illuminate\Support\HtmlString;
6+
use Illuminate\Contracts\Routing\UrlGenerator;
77

88
/**
99
* Class HtmlHelper.

app/Helpers/helper.php

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
<?php
22

33
use Illuminate\Support\Str;
4-
use App\Models\Notification\Notification;
5-
use App\Models\Settings\Setting;
6-
use Carbon\Carbon as Carbon;
74

85
/**
96
* Henerate UUID.
@@ -15,8 +12,7 @@ function generateUuid()
1512
return Str::uuid();
1613
}
1714

18-
if (!function_exists('homeRoute')) {
19-
15+
if (! function_exists('homeRoute')) {
2016
/**
2117
* Return the route to the "home" page depending on authentication/authorization status.
2218
*
@@ -34,10 +30,8 @@ function homeRoute()
3430
}
3531
}
3632

37-
/*
38-
* Global helpers file with misc functions.
39-
*/
40-
if (!function_exists('app_name')) {
33+
// Global helpers file with misc functions.
34+
if (! function_exists('app_name')) {
4135
/**
4236
* Helper to grab the application name.
4337
*
@@ -49,7 +43,7 @@ function app_name()
4943
}
5044
}
5145

52-
if (!function_exists('access')) {
46+
if (! function_exists('access')) {
5347
/**
5448
* Access (lol) the Access:: facade as a simple function.
5549
*/
@@ -59,7 +53,7 @@ function access()
5953
}
6054
}
6155

62-
if (!function_exists('history')) {
56+
if (! function_exists('history')) {
6357
/**
6458
* Access the history facade anywhere.
6559
*/
@@ -69,7 +63,7 @@ function history()
6963
}
7064
}
7165

72-
if (!function_exists('gravatar')) {
66+
if (! function_exists('gravatar')) {
7367
/**
7468
* Access the gravatar helper.
7569
*/
@@ -79,8 +73,7 @@ function gravatar()
7973
}
8074
}
8175

82-
if (!function_exists('includeRouteFiles')) {
83-
76+
if (! function_exists('includeRouteFiles')) {
8477
/**
8578
* Loops through a folder and requires all PHP files
8679
* Searches sub-directories as well.
@@ -107,8 +100,7 @@ function includeRouteFiles($folder)
107100
}
108101
}
109102

110-
if (!function_exists('getRtlCss')) {
111-
103+
if (! function_exists('getRtlCss')) {
112104
/**
113105
* The path being passed is generated by Laravel Mix manifest file
114106
* The webpack plugin takes the css filenames and appends rtl before the .css extension
@@ -129,8 +121,7 @@ function getRtlCss($path)
129121
}
130122
}
131123

132-
133-
if (!function_exists('escapeSlashes')) {
124+
if (! function_exists('escapeSlashes')) {
134125
/**
135126
* Access the escapeSlashes helper.
136127
*/
@@ -144,14 +135,15 @@ function escapeSlashes($path)
144135
}
145136
}
146137

147-
if (!function_exists('getRouteUrl')) {
138+
if (! function_exists('getRouteUrl')) {
148139
/**
149140
* Converts querystring params to array and use it as route params and returns URL.
150141
*/
151142
function getRouteUrl($url, $url_type = 'route', $separator = '?')
152143
{
153144
$routeUrl = '';
154-
if (!empty($url)) {
145+
146+
if (! empty($url)) {
155147
if ($url_type == 'route') {
156148
if (strpos($url, $separator) !== false) {
157149
$urlArray = explode($separator, $url);
@@ -170,7 +162,7 @@ function getRouteUrl($url, $url_type = 'route', $separator = '?')
170162
}
171163
}
172164

173-
if (!function_exists('renderMenuItems')) {
165+
if (! function_exists('renderMenuItems')) {
174166
/**
175167
* render sidebar menu items after permission check.
176168
*/
@@ -180,7 +172,7 @@ function renderMenuItems($items, $viewName = 'backend.includes.partials.sidebar-
180172
// if(!empty($item->url) && !Route::has($item->url)) {
181173
// return;
182174
// }
183-
if (!empty($item->view_permission_id)) {
175+
if (! empty($item->view_permission_id)) {
184176
if (access()->allow($item->view_permission_id)) {
185177
echo view($viewName, compact('item'));
186178
}
@@ -191,9 +183,7 @@ function renderMenuItems($items, $viewName = 'backend.includes.partials.sidebar-
191183
}
192184
}
193185

194-
195-
if (!function_exists('checkDatabaseConnection')) {
196-
186+
if (! function_exists('checkDatabaseConnection')) {
197187
/**
198188
* @return bool
199189
*/

app/Http/Composers/Backend/SidebarComposer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace App\Http\Composers\Backend;
44

5-
use App\Repositories\Backend\Auth\UserRepository;
65
use Illuminate\View\View;
6+
use App\Repositories\Backend\Auth\UserRepository;
77

88
/**
99
* Class SidebarComposer.

app/Http/Controllers/Api/V1/APIController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ public function respondWithPagination($items, $data)
6666
{
6767
$data = array_merge($data, [
6868
'paginator' => [
69-
'total_count' => $items->total(),
70-
'total_pages' => ceil($items->total() / $items->perPage()),
69+
'total_count' => $items->total(),
70+
'total_pages' => ceil($items->total() / $items->perPage()),
7171
'current_page' => $items->currentPage(),
72-
'limit' => $items->perPage(),
72+
'limit' => $items->perPage(),
7373
],
7474
]);
7575

@@ -113,7 +113,7 @@ public function respondWithError($message)
113113
{
114114
return $this->respond([
115115
'error' => [
116-
'message' => $message,
116+
'message' => $message,
117117
'status_code' => $this->getStatusCode(),
118118
],
119119
]);

app/Http/Controllers/Api/V1/AuthController.php

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,37 @@
22

33
namespace App\Http\Controllers\API\V1;
44

5-
use App\Http\Controllers\API\V1\APIController;
5+
use Validator;
66
use Illuminate\Http\Request;
77
use Illuminate\Support\Facades\Auth;
8-
use Validator;
98

109
/**
1110
* @group Authentication
12-
*
11+
*
1312
* Class AuthController
14-
*
13+
*
1514
* Fullfills all aspects related to authenticate a user.
1615
*/
17-
class AuthController extends APIController
16+
class AuthController extends APIController
1817
{
1918
/**
2019
* Attempt to login the user.
21-
*
20+
*
2221
* If login is successfull, you get an api_token in response. Use that api_token to authenticate yourself for further api calls.
23-
*
24-
* @bodyParam email string required Your email id. Example: "[email protected]"
25-
* @bodyParam password string required Your Password. Example: "abc@123_4"
22+
*
23+
* @bodyParam email string required Your email id. Example: "[email protected]"
24+
* @bodyParam password string required Your Password. Example: "abc@123_4"
2625
*
2726
* @responseFile status=401 scenario="api_key not provided" responses/unauthenticated.json
2827
* @responseFile responses/auth/login.json
29-
*
28+
*
3029
* @param \Illuminate\Http\Request $request
3130
* @return \Illuminate\Http\JsonResponse
3231
*/
3332
public function login(Request $request)
3433
{
3534
$validation = Validator::make($request->all(), [
36-
'email' => 'required|email',
35+
'email' => 'required|email',
3736
'password' => 'required|min:4',
3837
]);
3938

@@ -44,12 +43,12 @@ public function login(Request $request)
4443
$credentials = $request->only(['email', 'password']);
4544

4645
try {
47-
if (!Auth::attempt($credentials)) {
46+
if (! Auth::attempt($credentials)) {
4847
return $this->throwValidation(trans('api.messages.login.failed'));
4948
}
5049

5150
$user = $request->user();
52-
51+
5352
$passportToken = $user->createToken('API Access Token');
5453

5554
// Save generated token
@@ -61,8 +60,8 @@ public function login(Request $request)
6160
}
6261

6362
return $this->respond([
64-
'message' => trans('api.messages.login.success'),
65-
'token' => $token,
63+
'message' => trans('api.messages.login.success'),
64+
'token' => $token,
6665
]);
6766
}
6867

@@ -71,7 +70,7 @@ public function login(Request $request)
7170
*
7271
* @responseFile status=401 scenario="api_key not provided" responses/unauthenticated.json
7372
* @responseFile responses/auth/me.json
74-
*
73+
*
7574
* @param \Illuminate\Http\Request $request
7675
* @return \Illuminate\Http\JsonResponse
7776
*/
@@ -82,12 +81,12 @@ public function me()
8281

8382
/**
8483
* Attempt to logout the user.
85-
*
84+
*
8685
* After successfull logut the token get invalidated and can not be used further.
8786
*
8887
* @responseFile status=401 scenario="api_key not provided" responses/unauthenticated.json
8988
* @responseFile responses/auth/logout.json
90-
*
89+
*
9190
* @param \Illuminate\Http\Request $request
9291
* @return \Illuminate\Http\JsonResponse
9392
*/
@@ -100,7 +99,7 @@ public function logout(Request $request)
10099
}
101100

102101
return $this->respond([
103-
'message' => trans('api.messages.logout.success'),
102+
'message' => trans('api.messages.logout.success'),
104103
]);
105104
}
106-
}
105+
}

0 commit comments

Comments
 (0)