From ffdf989166a5db7ae794abeb0142087185ce0db6 Mon Sep 17 00:00:00 2001 From: Laravel Shift Date: Mon, 30 Sep 2019 13:49:45 +0000 Subject: [PATCH 1/8] Adopt Laravel coding style The Laravel framework adopts the PSR-2 coding style with some additions. Laravel apps *should* adopt this coding style as well. However, Shift allows you to customize the adopted coding style through by using your [PHP CS Fixer][1] config within your project. You may use [Shift's .php_cs][2] file as a base. [1]: https://github.com/FriendsOfPHP/PHP-CS-Fixer [2]: https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200 --- app/Console/Commands/InstallAppCommand.php | 12 +++--- app/Exceptions/Handler.php | 2 +- app/Helpers/helpers.php | 42 +++++++++---------- .../Controllers/Api/V1/AuthController.php | 2 +- .../Api/V1/ForgotPasswordController.php | 2 +- .../Controllers/Api/V1/RegisterController.php | 2 +- .../Controllers/Api/V1/UsersController.php | 2 +- .../Backend/Search/SearchController.php | 2 +- .../Frontend/Auth/LoginController.php | 6 +-- .../Frontend/Auth/ResetPasswordController.php | 2 +- .../Frontend/Auth/SocialLoginController.php | 8 ++-- app/Http/Middleware/RouteNeedsPermission.php | 2 +- app/Http/Middleware/RouteNeedsRole.php | 2 +- app/Http/Middleware/SessionTimeout.php | 4 +- .../Responses/Backend/Blog/CreateResponse.php | 2 + .../Responses/Backend/Blog/EditResponse.php | 3 ++ app/Http/Responses/RedirectResponse.php | 1 + app/Http/Responses/ViewResponse.php | 2 +- app/Http/Utilities/FileUploads.php | 4 +- app/Http/Utilities/Notification.php | 6 ++- app/Http/Utilities/NotificationIos.php | 10 +++-- app/Http/Utilities/PushNotification.php | 8 ++-- .../Access/PasswordReset/PasswordReset.php | 2 + app/Models/Access/Role/Traits/RoleAccess.php | 2 +- .../User/Traits/Attribute/UserAttribute.php | 18 ++++++-- app/Models/Access/User/Traits/UserAccess.php | 4 +- app/Models/Access/User/User.php | 1 + .../Frontend/Auth/UserNeedsPasswordReset.php | 1 + app/Notifications/PasswordReset.php | 1 + .../Backend/Access/Role/RoleRepository.php | 10 ++--- .../Backend/Access/User/UserRepository.php | 8 ++-- .../Backend/Blogs/BlogsRepository.php | 2 +- .../History/EloquentHistoryRepository.php | 11 +++-- .../Notification/NotificationRepository.php | 1 + .../Backend/Settings/SettingsRepository.php | 4 +- .../Frontend/Access/User/UserRepository.php | 6 +-- .../Frontend/Pages/PagesRepository.php | 2 +- .../seeds/Access/PermissionUserSeeder.php | 4 +- routes/Backend/Helpers.php | 2 +- 39 files changed, 122 insertions(+), 83 deletions(-) diff --git a/app/Console/Commands/InstallAppCommand.php b/app/Console/Commands/InstallAppCommand.php index be14862c..9c67b580 100644 --- a/app/Console/Commands/InstallAppCommand.php +++ b/app/Console/Commands/InstallAppCommand.php @@ -94,7 +94,7 @@ public function handle() $this->error('Missing '.ucfirst($missing_extension).' extension'); } - if (!file_exists('.env')) { + if (! file_exists('.env')) { File::copy('.env.example', '.env'); } @@ -149,7 +149,7 @@ protected function setDatabaseInfo() $this->username = env('DB_USERNAME'); $this->password = env('DB_PASSWORD'); - while (!checkDatabaseConnection()) { + while (! checkDatabaseConnection()) { // Ask for database details $this->host = $this->ask('Enter a host name?', config('config-variables.default_db_host')); $this->port = $this->ask('Enter a database port?', config('config-variables.default_db_port')); @@ -173,7 +173,7 @@ protected function setDatabaseInfo() $contents = preg_replace('/('.preg_quote('DB_USERNAME=').')(.*)/', 'DB_USERNAME='.$this->username, $contents); $contents = preg_replace('/('.preg_quote('DB_PASSWORD=').')(.*)/', 'DB_PASSWORD='.$this->password, $contents); - if (!$contents) { + if (! $contents) { throw new Exception('Error while writing credentials to .env file.'); } @@ -187,7 +187,7 @@ protected function setDatabaseInfo() // Clear DB name in config unset($this->laravel['config']['database.connections.mysql.database']); - if (!checkDatabaseConnection()) { + if (! checkDatabaseConnection()) { $this->error('Can not connect to database!'); } else { $this->info('Connected successfully!'); @@ -242,7 +242,7 @@ protected function getKeyFile() */ protected function createDatabase($database) { - if (!$database) { + if (! $database) { $this->info('Skipping creation of database as env(DB_DATABASE) is empty'); return; @@ -271,7 +271,7 @@ protected function createDatabase($database) */ protected function dumpDB($database) { - if (!empty($database)) { + if (! empty($database)) { // Force the new login to be used DB::purge(); diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index e1cb0956..15e6bbe9 100755 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -54,7 +54,7 @@ public function report(Exception $exception) public function render($request, Exception $exception) { if (strpos($request->url(), '/api/') !== false) { - \Log::debug('API Request Exception - '.$request->url().' - '.$exception->getMessage().(!empty($request->all()) ? ' - '.json_encode($request->except(['password'])) : '')); + \Log::debug('API Request Exception - '.$request->url().' - '.$exception->getMessage().(! empty($request->all()) ? ' - '.json_encode($request->except(['password'])) : '')); if ($exception instanceof AuthorizationException) { return $this->setStatusCode(403)->respondWithError($exception->getMessage()); diff --git a/app/Helpers/helpers.php b/app/Helpers/helpers.php index 801cfe23..fb77b7b9 100644 --- a/app/Helpers/helpers.php +++ b/app/Helpers/helpers.php @@ -15,7 +15,7 @@ function generateUuid() return uuid::uuid4(); } -if (!function_exists('homeRoute')) { +if (! function_exists('homeRoute')) { /** * Return the route to the "home" page depending on authentication/authorization status. @@ -37,7 +37,7 @@ function homeRoute() /* * Global helpers file with misc functions. */ -if (!function_exists('app_name')) { +if (! function_exists('app_name')) { /** * Helper to grab the application name. * @@ -49,7 +49,7 @@ function app_name() } } -if (!function_exists('access')) { +if (! function_exists('access')) { /** * Access (lol) the Access:: facade as a simple function. */ @@ -59,7 +59,7 @@ function access() } } -if (!function_exists('history')) { +if (! function_exists('history')) { /** * Access the history facade anywhere. */ @@ -69,7 +69,7 @@ function history() } } -if (!function_exists('gravatar')) { +if (! function_exists('gravatar')) { /** * Access the gravatar helper. */ @@ -79,7 +79,7 @@ function gravatar() } } -if (!function_exists('includeRouteFiles')) { +if (! function_exists('includeRouteFiles')) { /** * Loops through a folder and requires all PHP files @@ -107,7 +107,7 @@ function includeRouteFiles($folder) } } -if (!function_exists('getRtlCss')) { +if (! function_exists('getRtlCss')) { /** * The path being passed is generated by Laravel Mix manifest file @@ -129,7 +129,7 @@ function getRtlCss($path) } } -if (!function_exists('settings')) { +if (! function_exists('settings')) { /** * Access the settings helper. */ @@ -137,13 +137,13 @@ function settings() { // Settings Details $settings = Setting::latest()->first(); - if (!empty($settings)) { + if (! empty($settings)) { return $settings; } } } -if (!function_exists('createNotification')) { +if (! function_exists('createNotification')) { /** * create new notification. * @@ -165,7 +165,7 @@ function createNotification($message, $userId) } } -if (!function_exists('escapeSlashes')) { +if (! function_exists('escapeSlashes')) { /** * Access the escapeSlashes helper. */ @@ -179,7 +179,7 @@ function escapeSlashes($path) } } -if (!function_exists('getMenuItems')) { +if (! function_exists('getMenuItems')) { /** * Converts items (json string) to array and return array. */ @@ -187,11 +187,11 @@ function getMenuItems($type = 'backend', $id = null) { $menu = new \App\Models\Menu\Menu(); $menu = $menu->where('type', $type); - if (!empty($id)) { + if (! empty($id)) { $menu = $menu->where('id', $id); } $menu = $menu->first(); - if (!empty($menu) && !empty($menu->items)) { + if (! empty($menu) && ! empty($menu->items)) { return json_decode($menu->items); } @@ -199,14 +199,14 @@ function getMenuItems($type = 'backend', $id = null) } } -if (!function_exists('getRouteUrl')) { +if (! function_exists('getRouteUrl')) { /** * Converts querystring params to array and use it as route params and returns URL. */ function getRouteUrl($url, $url_type = 'route', $separator = '?') { $routeUrl = ''; - if (!empty($url)) { + if (! empty($url)) { if ($url_type == 'route') { if (strpos($url, $separator) !== false) { $urlArray = explode($separator, $url); @@ -225,7 +225,7 @@ function getRouteUrl($url, $url_type = 'route', $separator = '?') } } -if (!function_exists('renderMenuItems')) { +if (! function_exists('renderMenuItems')) { /** * render sidebar menu items after permission check. */ @@ -235,7 +235,7 @@ function renderMenuItems($items, $viewName = 'backend.includes.partials.sidebar- // if(!empty($item->url) && !Route::has($item->url)) { // return; // } - if (!empty($item->view_permission_id)) { + if (! empty($item->view_permission_id)) { if (access()->allow($item->view_permission_id)) { echo view($viewName, compact('item')); } @@ -246,7 +246,7 @@ function renderMenuItems($items, $viewName = 'backend.includes.partials.sidebar- } } -if (!function_exists('isActiveMenuItem')) { +if (! function_exists('isActiveMenuItem')) { /** * checks if current URL is of current menu/sub-menu. */ @@ -259,7 +259,7 @@ function isActiveMenuItem($item, $separator = '?') if (Active::checkRoutePattern($item->clean_url)) { return true; } - if (!empty($item->children)) { + if (! empty($item->children)) { foreach ($item->children as $child) { $child->clean_url = $child->url; if (strpos($child->url, $separator) !== false) { @@ -275,7 +275,7 @@ function isActiveMenuItem($item, $separator = '?') } } -if (!function_exists('checkDatabaseConnection')) { +if (! function_exists('checkDatabaseConnection')) { /** * @return bool diff --git a/app/Http/Controllers/Api/V1/AuthController.php b/app/Http/Controllers/Api/V1/AuthController.php index ad431484..dd953a98 100644 --- a/app/Http/Controllers/Api/V1/AuthController.php +++ b/app/Http/Controllers/Api/V1/AuthController.php @@ -29,7 +29,7 @@ public function login(Request $request) $credentials = $request->only(['email', 'password']); try { - if (!Auth::attempt($credentials)) { + if (! Auth::attempt($credentials)) { return $this->throwValidation(trans('api.messages.login.failed')); } diff --git a/app/Http/Controllers/Api/V1/ForgotPasswordController.php b/app/Http/Controllers/Api/V1/ForgotPasswordController.php index ddaefd73..8bd3a3b1 100644 --- a/app/Http/Controllers/Api/V1/ForgotPasswordController.php +++ b/app/Http/Controllers/Api/V1/ForgotPasswordController.php @@ -39,7 +39,7 @@ public function sendResetLinkEmail(Request $request) $user = $this->repository->findByEmail($request->get('email')); - if (!$user) { + if (! $user) { return $this->respondNotFound(trans('api.messages.forgot_password.validation.email_not_found')); } diff --git a/app/Http/Controllers/Api/V1/RegisterController.php b/app/Http/Controllers/Api/V1/RegisterController.php index 77e9dcb3..cc804bd5 100644 --- a/app/Http/Controllers/Api/V1/RegisterController.php +++ b/app/Http/Controllers/Api/V1/RegisterController.php @@ -45,7 +45,7 @@ public function register(Request $request) $user = $this->repository->create($request->all()); - if (!Config::get('api.register.release_token')) { + if (! Config::get('api.register.release_token')) { return $this->respondCreated([ 'message' => trans('api.messages.registeration.success'), ]); diff --git a/app/Http/Controllers/Api/V1/UsersController.php b/app/Http/Controllers/Api/V1/UsersController.php index 2b6c5374..718d9d0a 100644 --- a/app/Http/Controllers/Api/V1/UsersController.php +++ b/app/Http/Controllers/Api/V1/UsersController.php @@ -124,7 +124,7 @@ public function deleteAll(Request $request) { $ids = $request->get('ids'); - if (isset($ids) && !empty($ids)) { + if (isset($ids) && ! empty($ids)) { $result = $this->repository->deleteAll($ids); } diff --git a/app/Http/Controllers/Backend/Search/SearchController.php b/app/Http/Controllers/Backend/Search/SearchController.php index 358b66bd..20b71387 100755 --- a/app/Http/Controllers/Backend/Search/SearchController.php +++ b/app/Http/Controllers/Backend/Search/SearchController.php @@ -17,7 +17,7 @@ class SearchController extends Controller */ public function index(Request $request) { - if (!$request->filled('q')) { + if (! $request->filled('q')) { return redirect() ->route('admin.dashboard') ->withFlashDanger(trans('strings.backend.search.empty')); diff --git a/app/Http/Controllers/Frontend/Auth/LoginController.php b/app/Http/Controllers/Frontend/Auth/LoginController.php index e9138986..14f49791 100755 --- a/app/Http/Controllers/Frontend/Auth/LoginController.php +++ b/app/Http/Controllers/Frontend/Auth/LoginController.php @@ -71,11 +71,11 @@ protected function authenticated(Request $request, $user) /* * Check to see if the users account is confirmed and active */ - if (!$user->isConfirmed()) { + if (! $user->isConfirmed()) { access()->logout(); throw new GeneralException(trans('exceptions.frontend.auth.confirmation.resend', ['user_id' => $user->id]), true); - } elseif (!$user->isActive()) { + } elseif (! $user->isActive()) { access()->logout(); throw new GeneralException(trans('exceptions.frontend.auth.deactivated')); @@ -139,7 +139,7 @@ public function logout(Request $request) public function logoutAs() { //If for some reason route is getting hit without someone already logged in - if (!access()->user()) { + if (! access()->user()) { return redirect()->route('frontend.auth.login'); } diff --git a/app/Http/Controllers/Frontend/Auth/ResetPasswordController.php b/app/Http/Controllers/Frontend/Auth/ResetPasswordController.php index 91eca980..0d354c9c 100755 --- a/app/Http/Controllers/Frontend/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Frontend/Auth/ResetPasswordController.php @@ -50,7 +50,7 @@ public function redirectPath() */ public function showResetForm($token = null) { - if (!$token) { + if (! $token) { return redirect()->route('frontend.auth.password.email'); } diff --git a/app/Http/Controllers/Frontend/Auth/SocialLoginController.php b/app/Http/Controllers/Frontend/Auth/SocialLoginController.php index bee119a3..47182b8a 100755 --- a/app/Http/Controllers/Frontend/Auth/SocialLoginController.php +++ b/app/Http/Controllers/Frontend/Auth/SocialLoginController.php @@ -51,7 +51,7 @@ public function login(Request $request, $provider) $user = null; // If the provider is not an acceptable third party than kick back - if (!in_array($provider, $this->helper->getAcceptedProviders())) { + if (! in_array($provider, $this->helper->getAcceptedProviders())) { return redirect()->route('frontend.index')->withFlashDanger(trans('auth.socialite.unacceptable', ['provider' => $provider])); } @@ -60,7 +60,7 @@ public function login(Request $request, $provider) * It's redirected to the provider and then back here, where request is populated * So it then continues creating the user */ - if (!$request->all()) { + if (! $request->all()) { return $this->getAuthorizationFirst($provider); } @@ -71,12 +71,12 @@ public function login(Request $request, $provider) return redirect()->route('frontend.index')->withFlashDanger($e->getMessage()); } - if (is_null($user) || !isset($user)) { + if (is_null($user) || ! isset($user)) { return redirect()->route('frontend.index')->withFlashDanger(trans('exceptions.frontend.auth.unknown')); } // Check to see if they are active. - if (!$user->isActive()) { + if (! $user->isActive()) { throw new GeneralException(trans('exceptions.frontend.auth.deactivated')); } diff --git a/app/Http/Middleware/RouteNeedsPermission.php b/app/Http/Middleware/RouteNeedsPermission.php index 16f6a0db..648d9dd3 100755 --- a/app/Http/Middleware/RouteNeedsPermission.php +++ b/app/Http/Middleware/RouteNeedsPermission.php @@ -32,7 +32,7 @@ public function handle($request, Closure $next, $permission, $needsAll = false) $access = access()->allow($permission); } - if (!$access) { + if (! $access) { return redirect() ->route('frontend.index') ->withFlashDanger(trans('auth.general_error')); diff --git a/app/Http/Middleware/RouteNeedsRole.php b/app/Http/Middleware/RouteNeedsRole.php index e7b83f16..ec231b59 100755 --- a/app/Http/Middleware/RouteNeedsRole.php +++ b/app/Http/Middleware/RouteNeedsRole.php @@ -32,7 +32,7 @@ public function handle($request, Closure $next, $role, $needsAll = false) $access = access()->hasRole($role); } - if (!$access) { + if (! $access) { return redirect() ->route('frontend.index') ->withFlashDanger(trans('auth.general_error')); diff --git a/app/Http/Middleware/SessionTimeout.php b/app/Http/Middleware/SessionTimeout.php index 8be173d2..9d92fc9d 100755 --- a/app/Http/Middleware/SessionTimeout.php +++ b/app/Http/Middleware/SessionTimeout.php @@ -43,10 +43,10 @@ public function handle($request, Closure $next) //Cookie Name for when 'remember me' is checked $remember_cookie = \Auth::guard()->getRecallerName(); - if (!Cookie::has($remember_cookie) && config('session.timeout_status')) { + if (! Cookie::has($remember_cookie) && config('session.timeout_status')) { $isLoggedIn = $request->path() != '/logout'; - if (!session('lastActivityTime')) { + if (! session('lastActivityTime')) { $this->session->put('lastActivityTime', time()); } elseif (time() - $this->session->get('lastActivityTime') > $this->timeout) { $this->session->forget('lastActivityTime'); diff --git a/app/Http/Responses/Backend/Blog/CreateResponse.php b/app/Http/Responses/Backend/Blog/CreateResponse.php index 65a6e462..77cdeb79 100644 --- a/app/Http/Responses/Backend/Blog/CreateResponse.php +++ b/app/Http/Responses/Backend/Blog/CreateResponse.php @@ -7,7 +7,9 @@ class CreateResponse implements Responsable { protected $status; + protected $blogTags; + protected $blogCategories; public function __construct($status, $blogCategories, $blogTags) diff --git a/app/Http/Responses/Backend/Blog/EditResponse.php b/app/Http/Responses/Backend/Blog/EditResponse.php index 3366375a..969ab3d2 100644 --- a/app/Http/Responses/Backend/Blog/EditResponse.php +++ b/app/Http/Responses/Backend/Blog/EditResponse.php @@ -7,8 +7,11 @@ class EditResponse implements Responsable { protected $blog; + protected $status; + protected $blogTags; + protected $blogCategories; public function __construct($blog, $status, $blogCategories, $blogTags) diff --git a/app/Http/Responses/RedirectResponse.php b/app/Http/Responses/RedirectResponse.php index 898803a1..02098e7b 100644 --- a/app/Http/Responses/RedirectResponse.php +++ b/app/Http/Responses/RedirectResponse.php @@ -7,6 +7,7 @@ class RedirectResponse implements Responsable { protected $route; + protected $message; public function __construct($route, $message) diff --git a/app/Http/Responses/ViewResponse.php b/app/Http/Responses/ViewResponse.php index 1e31d525..53f52fb1 100644 --- a/app/Http/Responses/ViewResponse.php +++ b/app/Http/Responses/ViewResponse.php @@ -35,7 +35,7 @@ public function __construct($view, $with = []) */ public function toResponse($request) { - if (!empty($this->with)) { + if (! empty($this->with)) { return view($this->view)->with($this->with); } diff --git a/app/Http/Utilities/FileUploads.php b/app/Http/Utilities/FileUploads.php index 8e422fa6..957eef16 100755 --- a/app/Http/Utilities/FileUploads.php +++ b/app/Http/Utilities/FileUploads.php @@ -368,7 +368,7 @@ public function moveFile($source, $destination) $destination = $filePath.DIRECTORY_SEPARATOR.$destination; if (File::exists($source)) { $dir = dirname($destination); - if (!is_dir($dir)) { + if (! is_dir($dir)) { mkdir($dir, 0777, true); } @@ -393,7 +393,7 @@ public function copyFile($source, $destination) $destination = $filePath.DIRECTORY_SEPARATOR.$destination; if (File::exists($source)) { $dir = dirname($destination); - if (!is_dir($dir)) { + if (! is_dir($dir)) { mkdir($dir, 0777, true); } diff --git a/app/Http/Utilities/Notification.php b/app/Http/Utilities/Notification.php index 895ff621..9e33f87c 100755 --- a/app/Http/Utilities/Notification.php +++ b/app/Http/Utilities/Notification.php @@ -18,9 +18,13 @@ abstract class Notification { protected $_message = null; + protected $_devices = null; + protected $_response = null; + protected $_body = null; + protected static $_url = null; /* @@ -126,7 +130,7 @@ public function setOptions(array $options) public function raiseerror($errorCode) { $codeValue = $this->getErrorMessages(); - if (!isset($codeValue[$errorCode])) { + if (! isset($codeValue[$errorCode])) { $errorException = 'Erro code '.$errorCode; } else { $errorException = $codeValue[$errorCode]; diff --git a/app/Http/Utilities/NotificationIos.php b/app/Http/Utilities/NotificationIos.php index a1e0c49d..0e96dad2 100755 --- a/app/Http/Utilities/NotificationIos.php +++ b/app/Http/Utilities/NotificationIos.php @@ -7,11 +7,15 @@ class NotificationIos extends Notification const BADGE_ID = 0; protected $_passPhrase = null; // for authentication of .pem file or password of .pem file + protected $_pemFile = null; // for send notificetion .pem file is must add in that code + protected static $_url = 'ssl://gateway.sandbox.push.apple.com:2195'; // url for send push message const ERROR_PEM_NOTACCESSIBLE = 1; // exception error for file not get + const ERROR_PASSPHRASE_EMPTY = 2; // exception error for passphrese empty + const ERROR_CONNECTION_FAILED = 3; // exception error for connection failed protected $sendNotification = 1; // exception error for connection failed @@ -50,7 +54,7 @@ protected function _send($deviceId, $message, $sendOptions = []) stream_context_set_option($ctx, 'ssl', 'passphrase', $this->_passPhrase); $fp = stream_socket_client(self::$_url, $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx); - if (!$fp) { + if (! $fp) { $this->raiseerror(self::ERROR_CONNECTION_FAILED); } //return 'Connected to APNS' . PHP_EOL; @@ -68,7 +72,7 @@ protected function _send($deviceId, $message, $sendOptions = []) $result = fwrite($fp, $msg, strlen($msg)); } //echo "
-------
"; - if (!$result) { + if (! $result) { return 'Message not delivered'.PHP_EOL; } else { return 'Message successfully delivered'.PHP_EOL; @@ -103,7 +107,7 @@ public function setPemFile($pemFile = 'apns_baseproject_dev.pem') // echo $_SERVER['DOCUMENT_ROOT'].'/app/Http/Controllers/Utilities/'.$pemFile;exit; //echo dirname(__FILE__); exit; // echo file_get_contents(dirname(__FILE__).'/'.$pemFile); exit; - if (!(file_exists($newPemFilePath)) && !(is_readable($newPemFilePath))) { + if (! (file_exists($newPemFilePath)) && ! (is_readable($newPemFilePath))) { $error = $this->raiseerror(self::ERROR_PEM_NOTACCESSIBLE); } $this->_pemFile = $newPemFilePath; diff --git a/app/Http/Utilities/PushNotification.php b/app/Http/Utilities/PushNotification.php index 269cbf42..c10e4f45 100755 --- a/app/Http/Utilities/PushNotification.php +++ b/app/Http/Utilities/PushNotification.php @@ -28,10 +28,12 @@ public function _pushNotification($msg, $type, $devicetoken) return $this->_pushToIos($devicetoken, $msg); return true; + break; case 'android': return $this->_pushToAndroid($devicetoken, $msg); + break; default: @@ -59,7 +61,7 @@ public function _pushNotification($msg, $type, $devicetoken) */ public function _pushToAndroid($registrationIds, $msg) { - if (!is_array($registrationIds)) { + if (! is_array($registrationIds)) { $registrationIds = [$registrationIds]; } $fields = [ @@ -106,7 +108,7 @@ public function _pushtoios($devicetoken, $message) //$fp = stream_socket_client('ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ctx); - if (!$fp) { + if (! $fp) { exit("Failed to connect amarnew: $err $errstr".PHP_EOL); } @@ -120,7 +122,7 @@ public function _pushtoios($devicetoken, $message) $result = fwrite($fp, $msg, strlen($msg)); - if (!$result) { + if (! $result) { return false; } else { return true; diff --git a/app/Models/Access/PasswordReset/PasswordReset.php b/app/Models/Access/PasswordReset/PasswordReset.php index a2c49793..d3ca7699 100755 --- a/app/Models/Access/PasswordReset/PasswordReset.php +++ b/app/Models/Access/PasswordReset/PasswordReset.php @@ -10,7 +10,9 @@ class PasswordReset extends BaseModel { public $timestamps = false; + protected $table = 'password_resets'; + protected $fillable = [ 'email', 'token', diff --git a/app/Models/Access/Role/Traits/RoleAccess.php b/app/Models/Access/Role/Traits/RoleAccess.php index cbac1bd5..bae9cc53 100755 --- a/app/Models/Access/Role/Traits/RoleAccess.php +++ b/app/Models/Access/Role/Traits/RoleAccess.php @@ -16,7 +16,7 @@ trait RoleAccess */ public function savePermissions($inputPermissions) { - if (!empty($inputPermissions)) { + if (! empty($inputPermissions)) { $this->permissions()->sync($inputPermissions); } else { $this->permissions()->detach(); diff --git a/app/Models/Access/User/Traits/Attribute/UserAttribute.php b/app/Models/Access/User/Traits/Attribute/UserAttribute.php index 8216082f..f511e16a 100755 --- a/app/Models/Access/User/Traits/Attribute/UserAttribute.php +++ b/app/Models/Access/User/Traits/Attribute/UserAttribute.php @@ -20,7 +20,7 @@ public function canChangeEmail() */ public function canChangePassword() { - return !app('session')->has(config('access.socialite_session_name')); + return ! app('session')->has(config('access.socialite_session_name')); } /** @@ -62,7 +62,7 @@ public function getPictureAttribute() */ public function getPicture($size = false) { - if (!$size) { + if (! $size) { $size = config('gravatar.default.size'); } @@ -151,6 +151,7 @@ public function getStatusButtonAttribute($class) return ''.$name.''; } + break; case 1: @@ -159,6 +160,7 @@ public function getStatusButtonAttribute($class) return ''.$name.''; } + break; default: @@ -174,7 +176,7 @@ public function getStatusButtonAttribute($class) */ public function getConfirmedButtonAttribute($class) { - if (!$this->isConfirmed() && access()->allow('edit-user')) { + if (! $this->isConfirmed() && access()->allow('edit-user')) { return ' '; } @@ -226,7 +228,7 @@ public function getLoginAsButtonAttribute($class) /* * If the admin is currently NOT spoofing a user */ - if (access()->allow('login-as-user') && (!session()->has('admin_user_id') || !session()->has('temp_user_id'))) { + if (access()->allow('login-as-user') && (! session()->has('admin_user_id') || ! session()->has('temp_user_id'))) { //Won't break, but don't let them "Login As" themselves if ($this->id != access()->id()) { return ' [ - 'driver' => 'database', - 'table' => 'cache', + 'driver' => 'database', + 'table' => 'cache', 'connection' => null, ], 'file' => [ 'driver' => 'file', - 'path' => storage_path('framework/cache/data'), + 'path' => storage_path('framework/cache/data'), ], 'memcached' => [ - 'driver' => 'memcached', + 'driver' => 'memcached', 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), - 'sasl' => [ + 'sasl' => [ env('MEMCACHED_USERNAME'), env('MEMCACHED_PASSWORD'), ], 'options' => [ - // Memcached::OPT_CONNECT_TIMEOUT => 2000, + // Memcached::OPT_CONNECT_TIMEOUT => 2000, ], 'servers' => [ [ - 'host' => env('MEMCACHED_HOST', '127.0.0.1'), - 'port' => env('MEMCACHED_PORT', 11211), + 'host' => env('MEMCACHED_HOST', '127.0.0.1'), + 'port' => env('MEMCACHED_PORT', 11211), 'weight' => 100, ], ], ], 'redis' => [ - 'driver' => 'redis', - 'connection' => 'default', + 'driver' => 'redis', + 'connection' => 'cache', + ], + + 'dynamodb' => [ + 'driver' => 'dynamodb', + 'key' => env('AWS_ACCESS_KEY_ID'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), + 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), + 'endpoint' => env('DYNAMODB_ENDPOINT'), ], ], @@ -86,6 +98,6 @@ | */ - 'prefix' => 'laravel', + 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'), ]; diff --git a/config/filesystems.php b/config/filesystems.php index f99803df..ec6a7cec 100755 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -13,7 +13,7 @@ | */ - 'default' => 'local', + 'default' => env('FILESYSTEM_DRIVER', 'local'), /* |-------------------------------------------------------------------------- @@ -26,7 +26,7 @@ | */ - 'cloud' => 's3', + 'cloud' => env('FILESYSTEM_CLOUD', 's3'), /* |-------------------------------------------------------------------------- @@ -37,7 +37,7 @@ | may even configure multiple disks of the same driver. Defaults have | been setup for each driver as an example of the required options. | - | Supported Drivers: "local", "ftp", "s3", "rackspace" + | Supported Drivers: "local", "ftp", "sftp", "s3" | */ @@ -45,22 +45,23 @@ 'local' => [ 'driver' => 'local', - 'root' => storage_path('app'), + 'root' => storage_path('app'), ], 'public' => [ - 'driver' => 'local', - 'root' => storage_path('app/public'), - 'url' => env('APP_URL').'/storage', + 'driver' => 'local', + 'root' => storage_path('app/public'), + 'url' => env('APP_URL').'/storage', 'visibility' => 'public', ], 's3' => [ 'driver' => 's3', - 'key' => env('AWS_KEY'), - 'secret' => env('AWS_SECRET'), - 'region' => env('AWS_REGION'), + 'key' => env('AWS_ACCESS_KEY_ID'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'region' => env('AWS_DEFAULT_REGION'), 'bucket' => env('AWS_BUCKET'), + 'url' => env('AWS_URL'), ], ], diff --git a/config/logging.php b/config/logging.php index e0a412a7..0df82129 100644 --- a/config/logging.php +++ b/config/logging.php @@ -1,5 +1,9 @@ [ 'stack' => [ - 'driver' => 'stack', - 'channels' => ['single'], + 'driver' => 'stack', + 'channels' => ['daily'], + 'ignore_exceptions' => false, ], 'single' => [ 'driver' => 'single', - 'path' => storage_path('logs/laravel.log'), - 'level' => 'debug', + 'path' => storage_path('logs/laravel.log'), + 'level' => 'debug', ], 'daily' => [ 'driver' => 'daily', - 'path' => storage_path('logs/laravel.log'), - 'level' => 'debug', - 'days' => 7, + 'path' => storage_path('logs/laravel.log'), + 'level' => 'debug', + 'days' => 14, ], 'slack' => [ - 'driver' => 'slack', - 'url' => env('LOG_SLACK_WEBHOOK_URL'), + 'driver' => 'slack', + 'url' => env('LOG_SLACK_WEBHOOK_URL'), 'username' => 'Laravel Log', - 'emoji' => ':boom:', - 'level' => 'critical', + 'emoji' => ':boom:', + 'level' => 'critical', + ], + + 'papertrail' => [ + 'driver' => 'monolog', + 'level' => 'debug', + 'handler' => SyslogUdpHandler::class, + 'handler_with' => [ + 'host' => env('PAPERTRAIL_URL'), + 'port' => env('PAPERTRAIL_PORT'), + ], + ], + + 'stderr' => [ + 'driver' => 'monolog', + 'handler' => StreamHandler::class, + 'formatter' => env('LOG_STDERR_FORMATTER'), + 'with' => [ + 'stream' => 'php://stderr', + ], ], 'syslog' => [ 'driver' => 'syslog', - 'level' => 'debug', + 'level' => 'debug', ], 'errorlog' => [ 'driver' => 'errorlog', - 'level' => 'debug', + 'level' => 'debug', + ], + + 'null' => [ + 'driver' => 'monolog', + 'handler' => NullHandler::class, ], ], diff --git a/config/queue.php b/config/queue.php index 3a5de83f..3a30d6c6 100755 --- a/config/queue.php +++ b/config/queue.php @@ -4,18 +4,16 @@ /* |-------------------------------------------------------------------------- - | Default Queue Driver + | Default Queue Connection Name |-------------------------------------------------------------------------- | | Laravel's queue API supports an assortment of back-ends via a single | API, giving you convenient access to each back-end using the same - | syntax for each one. Here you may set the default queue driver. - | - | Supported: "sync", "database", "beanstalkd", "sqs", "redis", "null" + | syntax for every one. Here you may define a default connection. | */ - 'default' => env('QUEUE_DRIVER', 'sync'), + 'default' => env('QUEUE_CONNECTION', 'sync'), /* |-------------------------------------------------------------------------- @@ -26,6 +24,8 @@ | is used by your application. A default configuration has been added | for each back-end shipped with Laravel. You are free to add more. | + | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" + | */ 'connections' => [ @@ -35,33 +35,35 @@ ], 'database' => [ - 'driver' => 'database', - 'table' => 'jobs', - 'queue' => 'default', + 'driver' => 'database', + 'table' => 'jobs', + 'queue' => 'default', 'retry_after' => 90, ], 'beanstalkd' => [ - 'driver' => 'beanstalkd', - 'host' => 'localhost', - 'queue' => 'default', + 'driver' => 'beanstalkd', + 'host' => 'localhost', + 'queue' => 'default', 'retry_after' => 90, + 'block_for' => 0, ], 'sqs' => [ 'driver' => 'sqs', - 'key' => 'your-public-key', - 'secret' => 'your-secret-key', - 'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id', - 'queue' => 'your-queue-name', - 'region' => 'us-east-1', + 'key' => env('AWS_ACCESS_KEY_ID'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), + 'queue' => env('SQS_QUEUE', 'your-queue-name'), + 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), ], 'redis' => [ - 'driver' => 'redis', - 'connection' => 'default', - 'queue' => 'default', + 'driver' => 'redis', + 'connection' => 'default', + 'queue' => env('REDIS_QUEUE', 'default'), 'retry_after' => 90, + 'block_for' => null, ], ], @@ -78,8 +80,9 @@ */ 'failed' => [ + 'driver' => env('QUEUE_FAILED_DRIVER', 'database'), 'database' => env('DB_CONNECTION', 'mysql'), - 'table' => 'failed_jobs', + 'table' => 'failed_jobs', ], ]; From 50e49ccc9845f5b05b91faab3f7c9b5fc4e7cd52 Mon Sep 17 00:00:00 2001 From: Laravel Shift Date: Mon, 30 Sep 2019 13:49:51 +0000 Subject: [PATCH 4/8] Default config files In an effort to make upgrading the constantly changing config files easier, Shift defaulted them so you can review the commit diff for changes. Moving forward, you should use ENV variables or create a separate config file to allow the core config files to remain automatically upgradeable. --- config/database.php | 106 +++++++++++++++++++++++++++++--------------- config/mail.php | 23 +++++++--- config/services.php | 95 +++++---------------------------------- 3 files changed, 98 insertions(+), 126 deletions(-) diff --git a/config/database.php b/config/database.php index 7e50442e..199382d0 100755 --- a/config/database.php +++ b/config/database.php @@ -1,6 +1,9 @@ [ + 'sqlite' => [ - 'driver' => 'sqlite', - 'database' => env('DB_DATABASE', database_path('database.sqlite')), - 'foreign_key_constraints' => true, - 'prefix' => '', + 'driver' => 'sqlite', + 'url' => env('DATABASE_URL'), + 'database' => env('DB_DATABASE', database_path('database.sqlite')), + 'prefix' => '', + 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), ], 'mysql' => [ - 'driver' => 'mysql', - 'host' => env('DB_HOST', '127.0.0.1'), - 'port' => env('DB_PORT', '3306'), - 'database' => env('DB_DATABASE', 'forge'), - 'username' => env('DB_USERNAME', 'forge'), - 'password' => env('DB_PASSWORD', ''), + 'driver' => 'mysql', + 'url' => env('DATABASE_URL'), + 'host' => env('DB_HOST', '127.0.0.1'), + 'port' => env('DB_PORT', '3306'), + 'database' => env('DB_DATABASE', 'forge'), + 'username' => env('DB_USERNAME', 'forge'), + 'password' => env('DB_PASSWORD', ''), 'unix_socket' => env('DB_SOCKET', ''), - 'charset' => 'utf8mb4', - 'collation' => 'utf8mb4_unicode_ci', - 'prefix' => '', - 'strict' => false, //If you set strict to true, then make sure to enable which modes you want to enable by looking at 'modes' key in this config - 'engine' => null, - 'modes' => [ - // "ONLY_FULL_GROUP_BY", - // "STRICT_TRANS_TABLES", - // "NO_ZERO_IN_DATE", - // "NO_ZERO_DATE", - // "ERROR_FOR_DIVISION_BY_ZERO", - // "NO_AUTO_CREATE_USER", - // "NO_ENGINE_SUBSTITUTION", - ], + 'charset' => 'utf8mb4', + 'collation' => 'utf8mb4_unicode_ci', + 'prefix' => '', + 'prefix_indexes' => true, + 'strict' => true, + 'engine' => null, + 'options' => extension_loaded('pdo_mysql') ? array_filter([ + PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), + ]) : [], ], 'pgsql' => [ - 'driver' => 'pgsql', - 'host' => env('DB_HOST', '127.0.0.1'), - 'port' => env('DB_PORT', '5432'), + 'driver' => 'pgsql', + 'url' => env('DATABASE_URL'), + 'host' => env('DB_HOST', '127.0.0.1'), + 'port' => env('DB_PORT', '5432'), + 'database' => env('DB_DATABASE', 'forge'), + 'username' => env('DB_USERNAME', 'forge'), + 'password' => env('DB_PASSWORD', ''), + 'charset' => 'utf8', + 'prefix' => '', + 'prefix_indexes' => true, + 'schema' => 'public', + 'sslmode' => 'prefer', + ], + + 'sqlsrv' => [ + 'driver' => 'sqlsrv', + 'url' => env('DATABASE_URL'), + 'host' => env('DB_HOST', 'localhost'), + 'port' => env('DB_PORT', '1433'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), - 'charset' => 'utf8', - 'prefix' => '', - 'schema' => 'public', - 'sslmode' => 'prefer', + 'charset' => 'utf8', + 'prefix' => '', + 'prefix_indexes' => true, ], + ], /* @@ -95,19 +112,36 @@ |-------------------------------------------------------------------------- | | Redis is an open source, fast, and advanced key-value store that also - | provides a richer set of commands than a typical key-value systems + | provides a richer body of commands than a typical key-value system | such as APC or Memcached. Laravel makes it easy to dig right in. | */ 'redis' => [ - 'client' => 'predis', + + 'client' => env('REDIS_CLIENT', 'phpredis'), + + 'options' => [ + 'cluster' => env('REDIS_CLUSTER', 'redis'), + 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), + ], 'default' => [ - 'host' => env('REDIS_HOST', '127.0.0.1'), + 'url' => env('REDIS_URL'), + 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD', null), - 'port' => env('REDIS_PORT', 6379), - 'database' => 0, + 'port' => env('REDIS_PORT', 6379), + 'database' => env('REDIS_DB', 0), ], + + 'cache' => [ + 'url' => env('REDIS_URL'), + 'host' => env('REDIS_HOST', '127.0.0.1'), + 'password' => env('REDIS_PASSWORD', null), + 'port' => env('REDIS_PORT', 6379), + 'database' => env('REDIS_CACHE_DB', 1), + ], + ], + ]; diff --git a/config/mail.php b/config/mail.php index e2a0a4b4..3c65eb3f 100755 --- a/config/mail.php +++ b/config/mail.php @@ -11,8 +11,8 @@ | sending of e-mail. You may specify which one you're using throughout | your application here. By default, Laravel is setup for SMTP mail. | - | Supported: "smtp", "sendmail", "mailgun", "mandrill", "ses", - | "sparkpost", "log", "array" + | Supported: "smtp", "sendmail", "mailgun", "ses", + | "postmark", "log", "array" | */ @@ -29,7 +29,7 @@ | */ - 'host' => env('MAIL_HOST', 'smtp.gmail.com'), + 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), /* |-------------------------------------------------------------------------- @@ -56,8 +56,8 @@ */ 'from' => [ - 'address' => env('MAIL_FROM', 'viral.solani@gmail.com'), - 'name' => env('MAIL_FROM_NAME', 'Admin'), + 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), + 'name' => env('MAIL_FROM_NAME', 'Example'), ], /* @@ -120,4 +120,17 @@ ], ], + /* + |-------------------------------------------------------------------------- + | Log Channel + |-------------------------------------------------------------------------- + | + | If you are using the "log" driver, you may specify the logging channel + | if you prefer to keep mail messages separate from other log entries + | for simpler reading. Otherwise, the default channel will be used. + | + */ + + 'log_channel' => env('MAIL_LOG_CHANNEL'), + ]; diff --git a/config/services.php b/config/services.php index b0060db3..2a1d616c 100755 --- a/config/services.php +++ b/config/services.php @@ -1,7 +1,5 @@ [ 'domain' => env('MAILGUN_DOMAIN'), 'secret' => env('MAILGUN_SECRET'), + 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), ], - 'ses' => [ - 'key' => env('SES_KEY'), - 'secret' => env('SES_SECRET'), - 'region' => 'us-east-1', - ], - - 'sparkpost' => [ - 'secret' => env('SPARKPOST_SECRET'), - ], - - 'stripe' => [ - 'model' => User::class, - 'key' => env('STRIPE_KEY'), - 'secret' => env('STRIPE_SECRET'), + 'postmark' => [ + 'token' => env('POSTMARK_TOKEN'), ], - /* - * Socialite Credentials - * Redirect URL's need to be the same as specified on each network you set up this application on - * as well as conform to the route: - * http://localhost/public/login/SERVICE - * Where service can github, facebook, twitter, google, linkedin, or bitbucket - * Docs: https://github.com/laravel/socialite - * Make sure 'scopes' and 'with' are arrays, if their are none, use empty arrays [] - */ - 'bitbucket' => [ - 'client_id' => env('BITBUCKET_CLIENT_ID'), - 'client_secret' => env('BITBUCKET_CLIENT_SECRET'), - 'redirect' => env('BITBUCKET_REDIRECT'), - 'scopes' => [], - 'with' => [], - ], - - 'facebook' => [ - 'client_id' => env('FACEBOOK_CLIENT_ID'), - 'client_secret' => env('FACEBOOK_CLIENT_SECRET'), - 'redirect' => env('FACEBOOK_REDIRECT'), - 'scopes' => [], - 'with' => [], - 'fields' => [], - ], - - 'github' => [ - 'client_id' => env('GITHUB_CLIENT_ID'), - 'client_secret' => env('GITHUB_CLIENT_SECRET'), - 'redirect' => env('GITHUB_REDIRECT'), - 'scopes' => [], - 'with' => [], - ], - - 'google' => [ - 'client_id' => env('GOOGLE_CLIENT_ID'), - 'client_secret' => env('GOOGLE_CLIENT_SECRET'), - 'redirect' => env('GOOGLE_REDIRECT'), - - /* - * Only allows google to grab email address - * Default scopes array also has: 'https://www.googleapis.com/auth/plus.login' - * https://medium.com/@njovin/fixing-laravel-socialite-s-google-permissions-2b0ef8c18205 - */ - 'scopes' => [ - 'https://www.googleapis.com/auth/plus.me', - 'https://www.googleapis.com/auth/plus.profile.emails.read', - ], - - 'with' => [], - ], - - 'linkedin' => [ - 'client_id' => env('LINKEDIN_CLIENT_ID'), - 'client_secret' => env('LINKEDIN_CLIENT_SECRET'), - 'redirect' => env('LINKEDIN_REDIRECT'), - 'scopes' => [], - 'with' => [], - 'fields' => [], + 'ses' => [ + 'key' => env('AWS_ACCESS_KEY_ID'), + 'secret' => env('AWS_SECRET_ACCESS_KEY'), + 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), ], - 'twitter' => [ - 'client_id' => env('TWITTER_CLIENT_ID'), - 'client_secret' => env('TWITTER_CLIENT_SECRET'), - 'redirect' => env('TWITTER_REDIRECT'), - 'scopes' => [], - 'with' => [], - ], ]; From 4907509a21f0173b563e1dda2591fc85e9c2d310 Mon Sep 17 00:00:00 2001 From: Laravel Shift Date: Mon, 30 Sep 2019 13:49:51 +0000 Subject: [PATCH 5/8] Shift Laravel dependencies --- composer.json | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index d7724c19..2f78b9eb 100644 --- a/composer.json +++ b/composer.json @@ -11,8 +11,8 @@ "license": "MIT", "type": "project", "require": { - "php": ">=7.1.3", - "arcanedev/log-viewer": "^4.5", + "php": "^7.2", + "arcanedev/log-viewer": "^5.0", "arcanedev/no-captcha": "^9.0", "beyondcode/laravel-self-diagnosis": "^1.2", "creativeorange/gravatar": "~1.0", @@ -20,24 +20,25 @@ "doctrine/dbal": "^2.9", "fideloper/proxy": "^4.0", "hieu-le/active": "^3.5", - "laravel/framework": "5.8.*", - "laravel/passport": "^7.2", - "laravel/socialite": "^4.1", + "laravel/framework": "^6.0", + "laravel/passport": "^7.3.3", + "laravel/socialite": "^4.2", "laravel/tinker": "~1.0", - "laravelcollective/html": "^5.4.0", - "spatie/laravel-cors": "^1.2", + "laravelcollective/html": "6.0.*", + "spatie/laravel-cors": "^1.6", "unisharp/laravel-filemanager": "~1.8", "yajra/laravel-datatables-oracle": "~9.0" }, "require-dev": { "bvipul/generator": "^5.8.2", - "codedungeon/phpunit-result-printer": "^0.26.1", - "filp/whoops": "^2.0", + "codedungeon/phpunit-result-printer": "^0.26", "friendsofphp/php-cs-fixer": "^2.14", "fzaninotto/faker": "^1.4", - "laravel/telescope": "^2.0", + "laravel/telescope": "^2.1", "mockery/mockery": "^1.0", - "phpunit/phpunit": "^8.0" + "phpunit/phpunit": "^8.0", + "facade/ignition": "^1.4", + "nunomaduro/collision": "^3.0" }, "config": { "optimize-autoloader": true, @@ -116,4 +117,4 @@ "npm audit" ] } -} +} \ No newline at end of file From c5ed06bace42f469e9bbfcda8385866af013b5c6 Mon Sep 17 00:00:00 2001 From: Laravel Shift Date: Mon, 30 Sep 2019 13:49:58 +0000 Subject: [PATCH 6/8] Shift cleanup --- app/Console/Commands/InstallAppCommand.php | 2 +- app/Repositories/Backend/Blogs/BlogsRepository.php | 2 +- app/Repositories/Backend/Pages/PagesRepository.php | 2 +- database/factories/PageFactory.php | 2 +- database/factories/UserFactory.php | 2 +- routes/Backend/Helpers.php | 1 + 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/Console/Commands/InstallAppCommand.php b/app/Console/Commands/InstallAppCommand.php index b4c5ef7c..cadebf3d 100644 --- a/app/Console/Commands/InstallAppCommand.php +++ b/app/Console/Commands/InstallAppCommand.php @@ -2,13 +2,13 @@ namespace App\Console\Commands; -use Illuminate\Support\Str; use Exception; use Illuminate\Console\Command; use Illuminate\Filesystem\Filesystem; use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\File; +use Illuminate\Support\Str; use PDOException; use Symfony\Component\Console\Helper\SymfonyQuestionHelper; use Symfony\Component\Console\Question\Question; diff --git a/app/Repositories/Backend/Blogs/BlogsRepository.php b/app/Repositories/Backend/Blogs/BlogsRepository.php index 658795fb..6ea21471 100755 --- a/app/Repositories/Backend/Blogs/BlogsRepository.php +++ b/app/Repositories/Backend/Blogs/BlogsRepository.php @@ -2,7 +2,6 @@ namespace App\Repositories\Backend\Blogs; -use Illuminate\Support\Str; use App\Events\Backend\Blogs\BlogCreated; use App\Events\Backend\Blogs\BlogDeleted; use App\Events\Backend\Blogs\BlogUpdated; @@ -16,6 +15,7 @@ use Carbon\Carbon; use DB; use Illuminate\Support\Facades\Storage; +use Illuminate\Support\Str; /** * Class BlogsRepository. diff --git a/app/Repositories/Backend/Pages/PagesRepository.php b/app/Repositories/Backend/Pages/PagesRepository.php index 0c864292..deb89bd2 100644 --- a/app/Repositories/Backend/Pages/PagesRepository.php +++ b/app/Repositories/Backend/Pages/PagesRepository.php @@ -2,13 +2,13 @@ namespace App\Repositories\Backend\Pages; -use Illuminate\Support\Str; use App\Events\Backend\Pages\PageCreated; use App\Events\Backend\Pages\PageDeleted; use App\Events\Backend\Pages\PageUpdated; use App\Exceptions\GeneralException; use App\Models\Page\Page; use App\Repositories\BaseRepository; +use Illuminate\Support\Str; /** * Class PagesRepository. diff --git a/database/factories/PageFactory.php b/database/factories/PageFactory.php index c0fbb374..922c0e8b 100644 --- a/database/factories/PageFactory.php +++ b/database/factories/PageFactory.php @@ -1,9 +1,9 @@ define(Page::class, function (Faker $faker) { $title = $faker->sentence; diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 04c72190..2ae833f6 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -1,8 +1,8 @@ define(User::class, function (Generator $faker) { static $password; diff --git a/routes/Backend/Helpers.php b/routes/Backend/Helpers.php index 4ef18707..cf688c00 100644 --- a/routes/Backend/Helpers.php +++ b/routes/Backend/Helpers.php @@ -1,4 +1,5 @@ Date: Mon, 30 Sep 2019 13:49:59 +0000 Subject: [PATCH 7/8] Shift return type of base TestCase methods From the [PHPUnit 8 release notes][1], the `TestCase` methods below now declare a `void` return type: - `setUpBeforeClass()` - `setUp()` - `assertPreConditions()` - `assertPostConditions()` - `tearDown()` - `tearDownAfterClass()` - `onNotSuccessfulTest()` [1]: https://phpunit.de/announcements/phpunit-8.html --- tests/BrowserKitTestCase.php | 4 ++-- tests/TestCase.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/BrowserKitTestCase.php b/tests/BrowserKitTestCase.php index 37c3af38..b35d8be5 100644 --- a/tests/BrowserKitTestCase.php +++ b/tests/BrowserKitTestCase.php @@ -50,7 +50,7 @@ abstract class BrowserKitTestCase extends BaseTestCase */ protected $userRole; - public function setUp(): void + protected function setUp(): void { parent::setUp(); @@ -76,7 +76,7 @@ public function setUp(): void $this->userRole = Role::find(3); } - public function tearDown(): void + protected function tearDown(): void { $this->beforeApplicationDestroyed(function () { DB::disconnect(); diff --git a/tests/TestCase.php b/tests/TestCase.php index fd7bade6..543c24a0 100755 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -54,7 +54,7 @@ public function signIn($user = null) /** * Set up tests. */ - public function setUp(): void + protected function setUp(): void { parent::setUp(); @@ -80,7 +80,7 @@ public function setUp(): void $this->userRole = Role::find(3); } - public function tearDown(): void + protected function tearDown(): void { $this->beforeApplicationDestroyed(function () { DB::disconnect(); From 9312bbdf9aa30d6b2cc899a4be81cfb6395c8327 Mon Sep 17 00:00:00 2001 From: Viral Solani Date: Mon, 30 Sep 2019 13:50:36 +0000 Subject: [PATCH 8/8] Apply fixes from StyleCI --- app/Console/Commands/InstallAppCommand.php | 12 +-- app/Exceptions/Handler.php | 2 +- app/Helpers/helpers.php | 42 ++++----- .../Controllers/Api/V1/AuthController.php | 2 +- .../Api/V1/ForgotPasswordController.php | 2 +- .../Controllers/Api/V1/RegisterController.php | 2 +- .../Controllers/Api/V1/UsersController.php | 2 +- .../Backend/Search/SearchController.php | 2 +- .../Frontend/Auth/LoginController.php | 6 +- .../Frontend/Auth/ResetPasswordController.php | 2 +- .../Frontend/Auth/SocialLoginController.php | 8 +- app/Http/Middleware/RouteNeedsPermission.php | 2 +- app/Http/Middleware/RouteNeedsRole.php | 2 +- app/Http/Middleware/SessionTimeout.php | 4 +- app/Http/Responses/ViewResponse.php | 2 +- app/Http/Utilities/FileUploads.php | 4 +- app/Http/Utilities/Notification.php | 2 +- app/Http/Utilities/NotificationIos.php | 6 +- app/Http/Utilities/PushNotification.php | 6 +- app/Models/Access/Role/Traits/RoleAccess.php | 2 +- .../User/Traits/Attribute/UserAttribute.php | 8 +- app/Models/Access/User/Traits/UserAccess.php | 4 +- .../Backend/Access/Role/RoleRepository.php | 10 +-- .../Backend/Access/User/UserRepository.php | 6 +- .../Backend/Blogs/BlogsRepository.php | 2 +- .../History/EloquentHistoryRepository.php | 6 +- .../Backend/Settings/SettingsRepository.php | 4 +- .../Frontend/Access/User/UserRepository.php | 6 +- .../Frontend/Pages/PagesRepository.php | 2 +- config/broadcasting.php | 12 +-- config/cache.php | 26 +++--- config/database.php | 90 +++++++++---------- config/filesystems.php | 12 +-- config/logging.php | 40 ++++----- config/mail.php | 2 +- config/queue.php | 30 +++---- config/services.php | 6 +- .../seeds/Access/PermissionUserSeeder.php | 4 +- 38 files changed, 191 insertions(+), 191 deletions(-) diff --git a/app/Console/Commands/InstallAppCommand.php b/app/Console/Commands/InstallAppCommand.php index cadebf3d..db0f0f26 100644 --- a/app/Console/Commands/InstallAppCommand.php +++ b/app/Console/Commands/InstallAppCommand.php @@ -95,7 +95,7 @@ public function handle() $this->error('Missing '.ucfirst($missing_extension).' extension'); } - if (! file_exists('.env')) { + if (!file_exists('.env')) { File::copy('.env.example', '.env'); } @@ -150,7 +150,7 @@ protected function setDatabaseInfo() $this->username = env('DB_USERNAME'); $this->password = env('DB_PASSWORD'); - while (! checkDatabaseConnection()) { + while (!checkDatabaseConnection()) { // Ask for database details $this->host = $this->ask('Enter a host name?', config('config-variables.default_db_host')); $this->port = $this->ask('Enter a database port?', config('config-variables.default_db_port')); @@ -174,7 +174,7 @@ protected function setDatabaseInfo() $contents = preg_replace('/('.preg_quote('DB_USERNAME=').')(.*)/', 'DB_USERNAME='.$this->username, $contents); $contents = preg_replace('/('.preg_quote('DB_PASSWORD=').')(.*)/', 'DB_PASSWORD='.$this->password, $contents); - if (! $contents) { + if (!$contents) { throw new Exception('Error while writing credentials to .env file.'); } @@ -188,7 +188,7 @@ protected function setDatabaseInfo() // Clear DB name in config unset($this->laravel['config']['database.connections.mysql.database']); - if (! checkDatabaseConnection()) { + if (!checkDatabaseConnection()) { $this->error('Can not connect to database!'); } else { $this->info('Connected successfully!'); @@ -243,7 +243,7 @@ protected function getKeyFile() */ protected function createDatabase($database) { - if (! $database) { + if (!$database) { $this->info('Skipping creation of database as env(DB_DATABASE) is empty'); return; @@ -272,7 +272,7 @@ protected function createDatabase($database) */ protected function dumpDB($database) { - if (! empty($database)) { + if (!empty($database)) { // Force the new login to be used DB::purge(); diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 15e6bbe9..e1cb0956 100755 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -54,7 +54,7 @@ public function report(Exception $exception) public function render($request, Exception $exception) { if (strpos($request->url(), '/api/') !== false) { - \Log::debug('API Request Exception - '.$request->url().' - '.$exception->getMessage().(! empty($request->all()) ? ' - '.json_encode($request->except(['password'])) : '')); + \Log::debug('API Request Exception - '.$request->url().' - '.$exception->getMessage().(!empty($request->all()) ? ' - '.json_encode($request->except(['password'])) : '')); if ($exception instanceof AuthorizationException) { return $this->setStatusCode(403)->respondWithError($exception->getMessage()); diff --git a/app/Helpers/helpers.php b/app/Helpers/helpers.php index fb77b7b9..801cfe23 100644 --- a/app/Helpers/helpers.php +++ b/app/Helpers/helpers.php @@ -15,7 +15,7 @@ function generateUuid() return uuid::uuid4(); } -if (! function_exists('homeRoute')) { +if (!function_exists('homeRoute')) { /** * Return the route to the "home" page depending on authentication/authorization status. @@ -37,7 +37,7 @@ function homeRoute() /* * Global helpers file with misc functions. */ -if (! function_exists('app_name')) { +if (!function_exists('app_name')) { /** * Helper to grab the application name. * @@ -49,7 +49,7 @@ function app_name() } } -if (! function_exists('access')) { +if (!function_exists('access')) { /** * Access (lol) the Access:: facade as a simple function. */ @@ -59,7 +59,7 @@ function access() } } -if (! function_exists('history')) { +if (!function_exists('history')) { /** * Access the history facade anywhere. */ @@ -69,7 +69,7 @@ function history() } } -if (! function_exists('gravatar')) { +if (!function_exists('gravatar')) { /** * Access the gravatar helper. */ @@ -79,7 +79,7 @@ function gravatar() } } -if (! function_exists('includeRouteFiles')) { +if (!function_exists('includeRouteFiles')) { /** * Loops through a folder and requires all PHP files @@ -107,7 +107,7 @@ function includeRouteFiles($folder) } } -if (! function_exists('getRtlCss')) { +if (!function_exists('getRtlCss')) { /** * The path being passed is generated by Laravel Mix manifest file @@ -129,7 +129,7 @@ function getRtlCss($path) } } -if (! function_exists('settings')) { +if (!function_exists('settings')) { /** * Access the settings helper. */ @@ -137,13 +137,13 @@ function settings() { // Settings Details $settings = Setting::latest()->first(); - if (! empty($settings)) { + if (!empty($settings)) { return $settings; } } } -if (! function_exists('createNotification')) { +if (!function_exists('createNotification')) { /** * create new notification. * @@ -165,7 +165,7 @@ function createNotification($message, $userId) } } -if (! function_exists('escapeSlashes')) { +if (!function_exists('escapeSlashes')) { /** * Access the escapeSlashes helper. */ @@ -179,7 +179,7 @@ function escapeSlashes($path) } } -if (! function_exists('getMenuItems')) { +if (!function_exists('getMenuItems')) { /** * Converts items (json string) to array and return array. */ @@ -187,11 +187,11 @@ function getMenuItems($type = 'backend', $id = null) { $menu = new \App\Models\Menu\Menu(); $menu = $menu->where('type', $type); - if (! empty($id)) { + if (!empty($id)) { $menu = $menu->where('id', $id); } $menu = $menu->first(); - if (! empty($menu) && ! empty($menu->items)) { + if (!empty($menu) && !empty($menu->items)) { return json_decode($menu->items); } @@ -199,14 +199,14 @@ function getMenuItems($type = 'backend', $id = null) } } -if (! function_exists('getRouteUrl')) { +if (!function_exists('getRouteUrl')) { /** * Converts querystring params to array and use it as route params and returns URL. */ function getRouteUrl($url, $url_type = 'route', $separator = '?') { $routeUrl = ''; - if (! empty($url)) { + if (!empty($url)) { if ($url_type == 'route') { if (strpos($url, $separator) !== false) { $urlArray = explode($separator, $url); @@ -225,7 +225,7 @@ function getRouteUrl($url, $url_type = 'route', $separator = '?') } } -if (! function_exists('renderMenuItems')) { +if (!function_exists('renderMenuItems')) { /** * render sidebar menu items after permission check. */ @@ -235,7 +235,7 @@ function renderMenuItems($items, $viewName = 'backend.includes.partials.sidebar- // if(!empty($item->url) && !Route::has($item->url)) { // return; // } - if (! empty($item->view_permission_id)) { + if (!empty($item->view_permission_id)) { if (access()->allow($item->view_permission_id)) { echo view($viewName, compact('item')); } @@ -246,7 +246,7 @@ function renderMenuItems($items, $viewName = 'backend.includes.partials.sidebar- } } -if (! function_exists('isActiveMenuItem')) { +if (!function_exists('isActiveMenuItem')) { /** * checks if current URL is of current menu/sub-menu. */ @@ -259,7 +259,7 @@ function isActiveMenuItem($item, $separator = '?') if (Active::checkRoutePattern($item->clean_url)) { return true; } - if (! empty($item->children)) { + if (!empty($item->children)) { foreach ($item->children as $child) { $child->clean_url = $child->url; if (strpos($child->url, $separator) !== false) { @@ -275,7 +275,7 @@ function isActiveMenuItem($item, $separator = '?') } } -if (! function_exists('checkDatabaseConnection')) { +if (!function_exists('checkDatabaseConnection')) { /** * @return bool diff --git a/app/Http/Controllers/Api/V1/AuthController.php b/app/Http/Controllers/Api/V1/AuthController.php index dd953a98..ad431484 100644 --- a/app/Http/Controllers/Api/V1/AuthController.php +++ b/app/Http/Controllers/Api/V1/AuthController.php @@ -29,7 +29,7 @@ public function login(Request $request) $credentials = $request->only(['email', 'password']); try { - if (! Auth::attempt($credentials)) { + if (!Auth::attempt($credentials)) { return $this->throwValidation(trans('api.messages.login.failed')); } diff --git a/app/Http/Controllers/Api/V1/ForgotPasswordController.php b/app/Http/Controllers/Api/V1/ForgotPasswordController.php index 8bd3a3b1..ddaefd73 100644 --- a/app/Http/Controllers/Api/V1/ForgotPasswordController.php +++ b/app/Http/Controllers/Api/V1/ForgotPasswordController.php @@ -39,7 +39,7 @@ public function sendResetLinkEmail(Request $request) $user = $this->repository->findByEmail($request->get('email')); - if (! $user) { + if (!$user) { return $this->respondNotFound(trans('api.messages.forgot_password.validation.email_not_found')); } diff --git a/app/Http/Controllers/Api/V1/RegisterController.php b/app/Http/Controllers/Api/V1/RegisterController.php index cc804bd5..77e9dcb3 100644 --- a/app/Http/Controllers/Api/V1/RegisterController.php +++ b/app/Http/Controllers/Api/V1/RegisterController.php @@ -45,7 +45,7 @@ public function register(Request $request) $user = $this->repository->create($request->all()); - if (! Config::get('api.register.release_token')) { + if (!Config::get('api.register.release_token')) { return $this->respondCreated([ 'message' => trans('api.messages.registeration.success'), ]); diff --git a/app/Http/Controllers/Api/V1/UsersController.php b/app/Http/Controllers/Api/V1/UsersController.php index 718d9d0a..2b6c5374 100644 --- a/app/Http/Controllers/Api/V1/UsersController.php +++ b/app/Http/Controllers/Api/V1/UsersController.php @@ -124,7 +124,7 @@ public function deleteAll(Request $request) { $ids = $request->get('ids'); - if (isset($ids) && ! empty($ids)) { + if (isset($ids) && !empty($ids)) { $result = $this->repository->deleteAll($ids); } diff --git a/app/Http/Controllers/Backend/Search/SearchController.php b/app/Http/Controllers/Backend/Search/SearchController.php index 20b71387..358b66bd 100755 --- a/app/Http/Controllers/Backend/Search/SearchController.php +++ b/app/Http/Controllers/Backend/Search/SearchController.php @@ -17,7 +17,7 @@ class SearchController extends Controller */ public function index(Request $request) { - if (! $request->filled('q')) { + if (!$request->filled('q')) { return redirect() ->route('admin.dashboard') ->withFlashDanger(trans('strings.backend.search.empty')); diff --git a/app/Http/Controllers/Frontend/Auth/LoginController.php b/app/Http/Controllers/Frontend/Auth/LoginController.php index 14f49791..e9138986 100755 --- a/app/Http/Controllers/Frontend/Auth/LoginController.php +++ b/app/Http/Controllers/Frontend/Auth/LoginController.php @@ -71,11 +71,11 @@ protected function authenticated(Request $request, $user) /* * Check to see if the users account is confirmed and active */ - if (! $user->isConfirmed()) { + if (!$user->isConfirmed()) { access()->logout(); throw new GeneralException(trans('exceptions.frontend.auth.confirmation.resend', ['user_id' => $user->id]), true); - } elseif (! $user->isActive()) { + } elseif (!$user->isActive()) { access()->logout(); throw new GeneralException(trans('exceptions.frontend.auth.deactivated')); @@ -139,7 +139,7 @@ public function logout(Request $request) public function logoutAs() { //If for some reason route is getting hit without someone already logged in - if (! access()->user()) { + if (!access()->user()) { return redirect()->route('frontend.auth.login'); } diff --git a/app/Http/Controllers/Frontend/Auth/ResetPasswordController.php b/app/Http/Controllers/Frontend/Auth/ResetPasswordController.php index 0d354c9c..91eca980 100755 --- a/app/Http/Controllers/Frontend/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Frontend/Auth/ResetPasswordController.php @@ -50,7 +50,7 @@ public function redirectPath() */ public function showResetForm($token = null) { - if (! $token) { + if (!$token) { return redirect()->route('frontend.auth.password.email'); } diff --git a/app/Http/Controllers/Frontend/Auth/SocialLoginController.php b/app/Http/Controllers/Frontend/Auth/SocialLoginController.php index 47182b8a..bee119a3 100755 --- a/app/Http/Controllers/Frontend/Auth/SocialLoginController.php +++ b/app/Http/Controllers/Frontend/Auth/SocialLoginController.php @@ -51,7 +51,7 @@ public function login(Request $request, $provider) $user = null; // If the provider is not an acceptable third party than kick back - if (! in_array($provider, $this->helper->getAcceptedProviders())) { + if (!in_array($provider, $this->helper->getAcceptedProviders())) { return redirect()->route('frontend.index')->withFlashDanger(trans('auth.socialite.unacceptable', ['provider' => $provider])); } @@ -60,7 +60,7 @@ public function login(Request $request, $provider) * It's redirected to the provider and then back here, where request is populated * So it then continues creating the user */ - if (! $request->all()) { + if (!$request->all()) { return $this->getAuthorizationFirst($provider); } @@ -71,12 +71,12 @@ public function login(Request $request, $provider) return redirect()->route('frontend.index')->withFlashDanger($e->getMessage()); } - if (is_null($user) || ! isset($user)) { + if (is_null($user) || !isset($user)) { return redirect()->route('frontend.index')->withFlashDanger(trans('exceptions.frontend.auth.unknown')); } // Check to see if they are active. - if (! $user->isActive()) { + if (!$user->isActive()) { throw new GeneralException(trans('exceptions.frontend.auth.deactivated')); } diff --git a/app/Http/Middleware/RouteNeedsPermission.php b/app/Http/Middleware/RouteNeedsPermission.php index 648d9dd3..16f6a0db 100755 --- a/app/Http/Middleware/RouteNeedsPermission.php +++ b/app/Http/Middleware/RouteNeedsPermission.php @@ -32,7 +32,7 @@ public function handle($request, Closure $next, $permission, $needsAll = false) $access = access()->allow($permission); } - if (! $access) { + if (!$access) { return redirect() ->route('frontend.index') ->withFlashDanger(trans('auth.general_error')); diff --git a/app/Http/Middleware/RouteNeedsRole.php b/app/Http/Middleware/RouteNeedsRole.php index ec231b59..e7b83f16 100755 --- a/app/Http/Middleware/RouteNeedsRole.php +++ b/app/Http/Middleware/RouteNeedsRole.php @@ -32,7 +32,7 @@ public function handle($request, Closure $next, $role, $needsAll = false) $access = access()->hasRole($role); } - if (! $access) { + if (!$access) { return redirect() ->route('frontend.index') ->withFlashDanger(trans('auth.general_error')); diff --git a/app/Http/Middleware/SessionTimeout.php b/app/Http/Middleware/SessionTimeout.php index 9d92fc9d..8be173d2 100755 --- a/app/Http/Middleware/SessionTimeout.php +++ b/app/Http/Middleware/SessionTimeout.php @@ -43,10 +43,10 @@ public function handle($request, Closure $next) //Cookie Name for when 'remember me' is checked $remember_cookie = \Auth::guard()->getRecallerName(); - if (! Cookie::has($remember_cookie) && config('session.timeout_status')) { + if (!Cookie::has($remember_cookie) && config('session.timeout_status')) { $isLoggedIn = $request->path() != '/logout'; - if (! session('lastActivityTime')) { + if (!session('lastActivityTime')) { $this->session->put('lastActivityTime', time()); } elseif (time() - $this->session->get('lastActivityTime') > $this->timeout) { $this->session->forget('lastActivityTime'); diff --git a/app/Http/Responses/ViewResponse.php b/app/Http/Responses/ViewResponse.php index 53f52fb1..1e31d525 100644 --- a/app/Http/Responses/ViewResponse.php +++ b/app/Http/Responses/ViewResponse.php @@ -35,7 +35,7 @@ public function __construct($view, $with = []) */ public function toResponse($request) { - if (! empty($this->with)) { + if (!empty($this->with)) { return view($this->view)->with($this->with); } diff --git a/app/Http/Utilities/FileUploads.php b/app/Http/Utilities/FileUploads.php index 957eef16..8e422fa6 100755 --- a/app/Http/Utilities/FileUploads.php +++ b/app/Http/Utilities/FileUploads.php @@ -368,7 +368,7 @@ public function moveFile($source, $destination) $destination = $filePath.DIRECTORY_SEPARATOR.$destination; if (File::exists($source)) { $dir = dirname($destination); - if (! is_dir($dir)) { + if (!is_dir($dir)) { mkdir($dir, 0777, true); } @@ -393,7 +393,7 @@ public function copyFile($source, $destination) $destination = $filePath.DIRECTORY_SEPARATOR.$destination; if (File::exists($source)) { $dir = dirname($destination); - if (! is_dir($dir)) { + if (!is_dir($dir)) { mkdir($dir, 0777, true); } diff --git a/app/Http/Utilities/Notification.php b/app/Http/Utilities/Notification.php index 9e33f87c..78cd245e 100755 --- a/app/Http/Utilities/Notification.php +++ b/app/Http/Utilities/Notification.php @@ -130,7 +130,7 @@ public function setOptions(array $options) public function raiseerror($errorCode) { $codeValue = $this->getErrorMessages(); - if (! isset($codeValue[$errorCode])) { + if (!isset($codeValue[$errorCode])) { $errorException = 'Erro code '.$errorCode; } else { $errorException = $codeValue[$errorCode]; diff --git a/app/Http/Utilities/NotificationIos.php b/app/Http/Utilities/NotificationIos.php index 0e96dad2..edef630b 100755 --- a/app/Http/Utilities/NotificationIos.php +++ b/app/Http/Utilities/NotificationIos.php @@ -54,7 +54,7 @@ protected function _send($deviceId, $message, $sendOptions = []) stream_context_set_option($ctx, 'ssl', 'passphrase', $this->_passPhrase); $fp = stream_socket_client(self::$_url, $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx); - if (! $fp) { + if (!$fp) { $this->raiseerror(self::ERROR_CONNECTION_FAILED); } //return 'Connected to APNS' . PHP_EOL; @@ -72,7 +72,7 @@ protected function _send($deviceId, $message, $sendOptions = []) $result = fwrite($fp, $msg, strlen($msg)); } //echo "
-------
"; - if (! $result) { + if (!$result) { return 'Message not delivered'.PHP_EOL; } else { return 'Message successfully delivered'.PHP_EOL; @@ -107,7 +107,7 @@ public function setPemFile($pemFile = 'apns_baseproject_dev.pem') // echo $_SERVER['DOCUMENT_ROOT'].'/app/Http/Controllers/Utilities/'.$pemFile;exit; //echo dirname(__FILE__); exit; // echo file_get_contents(dirname(__FILE__).'/'.$pemFile); exit; - if (! (file_exists($newPemFilePath)) && ! (is_readable($newPemFilePath))) { + if (!(file_exists($newPemFilePath)) && !(is_readable($newPemFilePath))) { $error = $this->raiseerror(self::ERROR_PEM_NOTACCESSIBLE); } $this->_pemFile = $newPemFilePath; diff --git a/app/Http/Utilities/PushNotification.php b/app/Http/Utilities/PushNotification.php index c10e4f45..b0bbbe4b 100755 --- a/app/Http/Utilities/PushNotification.php +++ b/app/Http/Utilities/PushNotification.php @@ -61,7 +61,7 @@ public function _pushNotification($msg, $type, $devicetoken) */ public function _pushToAndroid($registrationIds, $msg) { - if (! is_array($registrationIds)) { + if (!is_array($registrationIds)) { $registrationIds = [$registrationIds]; } $fields = [ @@ -108,7 +108,7 @@ public function _pushtoios($devicetoken, $message) //$fp = stream_socket_client('ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ctx); - if (! $fp) { + if (!$fp) { exit("Failed to connect amarnew: $err $errstr".PHP_EOL); } @@ -122,7 +122,7 @@ public function _pushtoios($devicetoken, $message) $result = fwrite($fp, $msg, strlen($msg)); - if (! $result) { + if (!$result) { return false; } else { return true; diff --git a/app/Models/Access/Role/Traits/RoleAccess.php b/app/Models/Access/Role/Traits/RoleAccess.php index bae9cc53..cbac1bd5 100755 --- a/app/Models/Access/Role/Traits/RoleAccess.php +++ b/app/Models/Access/Role/Traits/RoleAccess.php @@ -16,7 +16,7 @@ trait RoleAccess */ public function savePermissions($inputPermissions) { - if (! empty($inputPermissions)) { + if (!empty($inputPermissions)) { $this->permissions()->sync($inputPermissions); } else { $this->permissions()->detach(); diff --git a/app/Models/Access/User/Traits/Attribute/UserAttribute.php b/app/Models/Access/User/Traits/Attribute/UserAttribute.php index f511e16a..22a49b15 100755 --- a/app/Models/Access/User/Traits/Attribute/UserAttribute.php +++ b/app/Models/Access/User/Traits/Attribute/UserAttribute.php @@ -20,7 +20,7 @@ public function canChangeEmail() */ public function canChangePassword() { - return ! app('session')->has(config('access.socialite_session_name')); + return !app('session')->has(config('access.socialite_session_name')); } /** @@ -62,7 +62,7 @@ public function getPictureAttribute() */ public function getPicture($size = false) { - if (! $size) { + if (!$size) { $size = config('gravatar.default.size'); } @@ -176,7 +176,7 @@ public function getStatusButtonAttribute($class) */ public function getConfirmedButtonAttribute($class) { - if (! $this->isConfirmed() && access()->allow('edit-user')) { + if (!$this->isConfirmed() && access()->allow('edit-user')) { return '
'; } @@ -228,7 +228,7 @@ public function getLoginAsButtonAttribute($class) /* * If the admin is currently NOT spoofing a user */ - if (access()->allow('login-as-user') && (! session()->has('admin_user_id') || ! session()->has('temp_user_id'))) { + if (access()->allow('login-as-user') && (!session()->has('admin_user_id') || !session()->has('temp_user_id'))) { //Won't break, but don't let them "Login As" themselves if ($this->id != access()->id()) { return '