diff --git a/app/Broadcasting/Notification.php b/app/Broadcasting/Notification.php index fd3ae04ba..1caaf04ad 100644 --- a/app/Broadcasting/Notification.php +++ b/app/Broadcasting/Notification.php @@ -7,15 +7,6 @@ class Notification { - /** - * Create a new channel instance. - * - * @return void - */ - public function __construct() - { - } - /** * Authenticate the user's access to the channel. * diff --git a/app/Console/Commands/SyncWithGeneanum.php b/app/Console/Commands/SyncWithGeneanum.php index c48763984..5b1ebc585 100644 --- a/app/Console/Commands/SyncWithGeneanum.php +++ b/app/Console/Commands/SyncWithGeneanum.php @@ -32,8 +32,6 @@ class SyncWithGeneanum extends Command /** * Execute the console command. - * - * @return int */ public function handle(): int { diff --git a/app/Events/MessageSent.php b/app/Events/MessageSent.php index 4510b0c7b..0089dd1df 100644 --- a/app/Events/MessageSent.php +++ b/app/Events/MessageSent.php @@ -32,10 +32,8 @@ public function __construct(Message $message, User $user, public $conversation) /** * Determine if this event should broadcast. - * - * @return bool */ - public function broadcastWhen() + public function broadcastWhen(): bool { // return $this->conversation->status == 1; return true; @@ -65,7 +63,7 @@ public function broadcastOn() return new PrivateChannel('chat'); } - public function broadcastAs() + public function broadcastAs(): string { return 'MessageSent'; } diff --git a/app/Events/ServerCreated.php b/app/Events/ServerCreated.php index 733827d9d..8581d5bde 100644 --- a/app/Events/ServerCreated.php +++ b/app/Events/ServerCreated.php @@ -38,10 +38,8 @@ public function broadcastOn() /** * The event's broadcast name. - * - * @return string */ - public function broadcastAs() + public function broadcastAs(): string { return 'TestEvent'; } diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index e18abac0f..8ec9223ca 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -26,6 +26,10 @@ class LoginController extends Controller { + /** + * @var mixed + */ + public $maxAttempts; use AuthenticatesUsers, Logout, Login { Logout::logout insteadof AuthenticatesUsers; Login::login insteadof AuthenticatesUsers; @@ -196,13 +200,13 @@ public function providerLogin(Request $request, $provider) public function confirmSubscription(Request $request) { - $params = $request->all(); + $request->all(); $user = $this->loggableUser($request); return response()->json($user); } - protected function attemptLogin(Request $request) + protected function attemptLogin(Request $request): bool { $this->user = $this->loggableUser($request); @@ -296,11 +300,6 @@ private function create_company($user) * ]);. */ $company_id = $company->id; - $user_id = $user->id; - $person_name = $user->person->name; - $user_email = $user->email; - - $db = $company_id; // \Log::debug('CreateDBs----------------------'.$company); CreateDBs::dispatch($company); // \Log::debug('Migration----------------------'.$company); @@ -354,33 +353,29 @@ private function loggableUser(Request $request) // if (($main_company == null||$tenants=='') && ! $user->isAdmin()) { // if ($main_company == null) { $this->create_company($user); - } else { - if ($tenants && ! $user->isAdmin()) { - // $c = DB::connection('tenantdb',$tenants->tenancy_db_name)->table('users')->count(); - $company = \App\Models\Company::find($main_company->id); - // \Log::debug('Database----------------------'.$main_company->id); - - tenancy()->initialize($tenants); - $tenants->run(function () use ($company, $user) { - // $company->save(); - $c = User::count(); - if ($c === 0) { - // \Log::debug('Run Migration----------------------'); - return Migration::dispatch($company, $user->name, $user->email, $user->password); - } - // \Log::debug($company->id.-'users----------------------'.$c); - }); - tenancy()->end(); - - return $user; - } + } elseif ($tenants && ! $user->isAdmin()) { + // $c = DB::connection('tenantdb',$tenants->tenancy_db_name)->table('users')->count(); + $company = \App\Models\Company::find($main_company->id); + // \Log::debug('Database----------------------'.$main_company->id); + tenancy()->initialize($tenants); + $tenants->run(function () use ($company, $user) { + // $company->save(); + $c = User::count(); + if ($c === 0) { + // \Log::debug('Run Migration----------------------'); + return Migration::dispatch($company, $user->name, $user->email, $user->password); + } + // \Log::debug($company->id.-'users----------------------'.$c); + }); + tenancy()->end(); + return $user; } } return $user; } - private function loggableSocialUser($user) + private function loggableSocialUser($user): bool { $company = $user->person->company(); $tenant = false; diff --git a/app/Http/Controllers/Auth/VerificationController.php b/app/Http/Controllers/Auth/VerificationController.php index 61c9ae5ea..80d8f1c6f 100644 --- a/app/Http/Controllers/Auth/VerificationController.php +++ b/app/Http/Controllers/Auth/VerificationController.php @@ -28,46 +28,45 @@ public function __construct() */ public function verify_user(Request $request) { + $token = null; + $activation = null; + $user_id = null; + $user = null; $data = $request->all(); $this->validator($data)->validate(); - try { - $token = $request->get('token'); - $activation = Activation::where('token', $token)->first(); - if ($activation === null) { - return response()->json( - [ - 'error' => [ - 'code' => 300, - 'message' => 'Send activation code again.', - ], + $token = $request->get('token'); + $activation = Activation::where('token', $token)->first(); + if ($activation === null) { + return response()->json( + [ + 'error' => [ + 'code' => 300, + 'message' => 'Send activation code again.', ], - Response::HTTP_UNPROCESSABLE_ENTITY - ); - } - $user_id = $activation->user_id; - $user = User::find($user_id); - if ($user === null) { - return response()->json( - [ - 'error' => [ - 'code' => 301, - 'message' => 'There is not such user.', - ], + ], + Response::HTTP_UNPROCESSABLE_ENTITY + ); + } + $user_id = $activation->user_id; + $user = User::find($user_id); + if ($user === null) { + return response()->json( + [ + 'error' => [ + 'code' => 301, + 'message' => 'There is not such user.', ], - Response::HTTP_UNPROCESSABLE_ENTITY - ); - } - $user->is_active = 1; - $user->email_verified_at = date('Y-m-d H:i:s'); - $user->save(); - Activation::where('user_id', $user_id)->delete(); - - return response()->json([ - 'csrfToken' => csrf_token(), - ]); - } catch (\Exception $e) { - throw $e; + ], + Response::HTTP_UNPROCESSABLE_ENTITY + ); } + $user->is_active = 1; + $user->email_verified_at = date('Y-m-d H:i:s'); + $user->save(); + Activation::where('user_id', $user_id)->delete(); + return response()->json([ + 'csrfToken' => csrf_token(), + ]); } protected function validator(array $data) diff --git a/app/Http/Controllers/Dashboard/ChartController.php b/app/Http/Controllers/Dashboard/ChartController.php index 38cff22b0..ceb81ace6 100644 --- a/app/Http/Controllers/Dashboard/ChartController.php +++ b/app/Http/Controllers/Dashboard/ChartController.php @@ -52,10 +52,10 @@ public function pie() $male = \DB::table('people')->where('sex', 'M')->get()->count(); $female = \DB::table('people')->where('sex', 'F')->get()->count(); $unknown = \DB::table('people')->whereNull('sex')->get()->count(); - $sv = \Session::get('db', env('DB_DATABASE')); + \Session::get('db', env('DB_DATABASE')); $user = Auth::user(); - $companies = $user->person->company(); - $current_db = \Session::get('companyId'); + $user->person->company(); + \Session::get('companyId'); // return $current_db; // return $sv; @@ -140,7 +140,7 @@ public function changedb(Request $request) return json_encode([ 'db' => config('database.connections.tenant.database'), 'connection' => $changeConn, - 'changedb' => $prevConn === $changeConn ? true : false, + 'changedb' => $prevConn === $changeConn, 'familiesjoined' => $familiesjoined, 'peoplesattached' => $peoplesattached, ], JSON_THROW_ON_ERROR); @@ -198,7 +198,7 @@ public function changeCompany(Request $request) return json_encode([ 'db' => config('database.connections.tenant.database'), 'connection' => $changeConn, - 'changedb' => $prevConn === $changeConn ? true : false, + 'changedb' => $prevConn === $changeConn, 'familiesjoined' => $familiesjoined, 'peoplesattached' => $peoplesattached, ], JSON_THROW_ON_ERROR); diff --git a/app/Http/Controllers/Families/Index.php b/app/Http/Controllers/Families/Index.php index 5e4d42542..d96af1dcf 100644 --- a/app/Http/Controllers/Families/Index.php +++ b/app/Http/Controllers/Families/Index.php @@ -12,7 +12,7 @@ public function __invoke(Request $request) return $this->getDabolvilleFormat(); } - public function getDabolvilleFormat() + public function getDabolvilleFormat(): string { //1 Progenitor - $husband married $woman $year $location //1.1 Child - $husband married $woman $year $location diff --git a/app/Http/Controllers/Gedcom/Store.php b/app/Http/Controllers/Gedcom/Store.php index 03cbcf934..b16a9a9b9 100644 --- a/app/Http/Controllers/Gedcom/Store.php +++ b/app/Http/Controllers/Gedcom/Store.php @@ -24,7 +24,7 @@ public function __invoke(Request $request): Response ]); $slug = $request->slug; $file = $request->file('file'); - \Log::info(json_encode($request->user()->company())); + \Log::info(json_encode($request->user()->company(), JSON_THROW_ON_ERROR)); $manager = Manager::fromModel($request->user()->company(), $request->user()); $path = $manager->storage()->putFile('imports', $file); diff --git a/app/Http/Controllers/GenealogyCloud/GenealogyCloudController.php b/app/Http/Controllers/GenealogyCloud/GenealogyCloudController.php index ed3313da9..5bdbef90c 100644 --- a/app/Http/Controllers/GenealogyCloud/GenealogyCloudController.php +++ b/app/Http/Controllers/GenealogyCloud/GenealogyCloudController.php @@ -28,8 +28,8 @@ public function searchPerson(Request $request) ], ]); - $statusCode = $response->getStatusCode(); - $content = $response->getBody(); + $response->getStatusCode(); + $response->getBody(); $persons = json_decode($response->getBody(), true, 512, JSON_THROW_ON_ERROR); return response()->json($persons); diff --git a/app/Http/Controllers/Geneanum/GeneanumController.php b/app/Http/Controllers/Geneanum/GeneanumController.php index f97a38110..1b31008f3 100644 --- a/app/Http/Controllers/Geneanum/GeneanumController.php +++ b/app/Http/Controllers/Geneanum/GeneanumController.php @@ -9,7 +9,6 @@ class GeneanumController extends Controller { public function burials(Request $request) { - $authCode = $request->authcode; $client = new \GuzzleHttp\Client(); $URI = 'https://static.geneanum.com/libs/grid/malte_sepulture.php'; @@ -24,8 +23,8 @@ public function burials(Request $request) ], ]); - $statusCode = $response->getStatusCode(); - $content = $response->getBody(); + $response->getStatusCode(); + $response->getBody(); $persons = json_decode($response->getBody(), true, 512, JSON_THROW_ON_ERROR); return response()->json($persons); @@ -33,7 +32,6 @@ public function burials(Request $request) public function baptism(Request $request) { - $authCode = $request->authcode; $client = new \GuzzleHttp\Client(); $URI = 'https://static.geneanum.com/libs/grid/malte_bapteme.php'; @@ -47,8 +45,8 @@ public function baptism(Request $request) ], ]); - $statusCode = $response->getStatusCode(); - $content = $response->getBody(); + $response->getStatusCode(); + $response->getBody(); $persons = json_decode($response->getBody(), true, 512, JSON_THROW_ON_ERROR); return response()->json($persons); @@ -56,7 +54,6 @@ public function baptism(Request $request) public function mariage(Request $request) { - $authCode = $request->authcode; $client = new \GuzzleHttp\Client(); $URI = 'https://static.geneanum.com/libs/grid/malte_mariage.php'; @@ -73,8 +70,8 @@ public function mariage(Request $request) ], ]); - $statusCode = $response->getStatusCode(); - $content = $response->getBody(); + $response->getStatusCode(); + $response->getBody(); $persons = json_decode($response->getBody(), true, 512, JSON_THROW_ON_ERROR); return response()->json($persons); diff --git a/app/Http/Controllers/GrampsXml/Export.php b/app/Http/Controllers/GrampsXml/Export.php index 46b3ab3e7..511ab05f0 100644 --- a/app/Http/Controllers/GrampsXml/Export.php +++ b/app/Http/Controllers/GrampsXml/Export.php @@ -27,16 +27,16 @@ public function export(Request $request) foreach ($children as $child) { $per = $this->getPersonDetail($child); - array_push($childrenArr, $per); + $childrenArr[] = $per; } - array_push($data, [ + $data[] = [ 'id' => $familyId, 'description' => $description, 'husband' => $husband, 'wife' => $wife, 'child' => $childrenArr, - ]); + ]; } return XML::export(['family' => $data])->rootTag('database') diff --git a/app/Http/Controllers/GrampsXml/Import.php b/app/Http/Controllers/GrampsXml/Import.php index c04944d3e..09ff99faa 100644 --- a/app/Http/Controllers/GrampsXml/Import.php +++ b/app/Http/Controllers/GrampsXml/Import.php @@ -65,7 +65,7 @@ public function import(Request $request) // remove temp file after importing Storage::delete('files/temp/'.$fileName); - if (count($errors) > 0) { + if ($errors !== []) { return ['errors' => $errors]; } @@ -78,7 +78,7 @@ protected function fileToJson($request) { $fileName = 'temp'.uniqid().'.xml'; - $file = $request->file('file')->storeAs('/files/temp', $fileName); + $request->file('file')->storeAs('/files/temp', $fileName); $xmlDataString = file_get_contents(storage_path('app/files/temp/'.$fileName)); $xmlObject = simplexml_load_string($xmlDataString); diff --git a/app/Http/Controllers/NationalArch/NationalArchController.php b/app/Http/Controllers/NationalArch/NationalArchController.php index f75b76de6..12a7302ff 100644 --- a/app/Http/Controllers/NationalArch/NationalArchController.php +++ b/app/Http/Controllers/NationalArch/NationalArchController.php @@ -27,8 +27,8 @@ public function searchPerson(Request $request) ], ]); - $statusCode = $response->getStatusCode(); - $content = $response->getBody(); + $response->getStatusCode(); + $response->getBody(); $persons = json_decode($response->getBody(), true, 512, JSON_THROW_ON_ERROR); return response()->json($persons); diff --git a/app/Http/Controllers/Openarch/OpenArchController.php b/app/Http/Controllers/Openarch/OpenArchController.php index 591445cf3..b7f5ae729 100644 --- a/app/Http/Controllers/Openarch/OpenArchController.php +++ b/app/Http/Controllers/Openarch/OpenArchController.php @@ -16,7 +16,6 @@ public function __construct() public function searchPerson(Request $request) { - $authCode = $request->authcode; $client = new \GuzzleHttp\Client(); $response = $client->request('POST', $this->openArchRecordsApi.'/search.json', ['query' => [ @@ -26,8 +25,8 @@ public function searchPerson(Request $request) ], ]); - $statusCode = $response->getStatusCode(); - $content = $response->getBody(); + $response->getStatusCode(); + $response->getBody(); $persons = json_decode($response->getBody(), true, 512, JSON_THROW_ON_ERROR); return response()->json($persons); diff --git a/app/Http/Controllers/Personalias/Index.php b/app/Http/Controllers/Personalias/Index.php index 2f52f1414..714f08f96 100644 --- a/app/Http/Controllers/Personalias/Index.php +++ b/app/Http/Controllers/Personalias/Index.php @@ -20,7 +20,6 @@ public function getPerson() $tenant = Auth::user()->company(); Tenant::set($tenant); $company = Tenant::get(); - $db = Connections::Tenant.$company->id; return DB::connection(Connections::Tenant)->table('people')->get(); } diff --git a/app/Http/Controllers/Records/RecordsAPIController.php b/app/Http/Controllers/Records/RecordsAPIController.php index a09017d4c..e6c220153 100644 --- a/app/Http/Controllers/Records/RecordsAPIController.php +++ b/app/Http/Controllers/Records/RecordsAPIController.php @@ -35,7 +35,7 @@ public function getAuthCode(Request $request) return redirect($redirectTo); } - public function getAuthCodeCallBack(Request $request) + public function getAuthCodeCallBack(Request $request): string { return 'Auth code recieved :: '.$request->authcode; } @@ -76,7 +76,7 @@ public function searchPerson(Request $request) $ancestors = json_decode($response->getBody(), true, 512, JSON_THROW_ON_ERROR); $person['ancestors'] = $ancestors; - array_push($newPersons, $person); + $newPersons[] = $person; } return response()->json($newPersons); diff --git a/app/Http/Controllers/Stripe/GetCurrentSubscription.php b/app/Http/Controllers/Stripe/GetCurrentSubscription.php index 6074a6bac..6c5d3c350 100644 --- a/app/Http/Controllers/Stripe/GetCurrentSubscription.php +++ b/app/Http/Controllers/Stripe/GetCurrentSubscription.php @@ -20,7 +20,7 @@ public function __invoke(Request $request) if ($user->subscribed('default')) { $subscription = $user->subscription(); - $data['subscribed'] = $subscription->stripe_status != 'canceled' ? true : false; + $data['subscribed'] = $subscription->stripe_status != 'canceled'; $data['plan_id'] = $subscription->stripe_price; $data['trial_end'] = null; @@ -44,12 +44,12 @@ public function __invoke(Request $request) $discountAmount = ($price * $coupon->percent_off / 100); $finalPrice = $price - $discountAmount; } - } catch (\Exception $e) { + } catch (\Exception) { } $data['final_price'] = $finalPrice; $data['discount_amount'] = $discountAmount; - } catch (Exception $e) { + } catch (Exception) { } } else { $data['subscribed'] = false; diff --git a/app/Http/Controllers/Stripe/GetPlans.php b/app/Http/Controllers/Stripe/GetPlans.php index 0accdf77a..82a860194 100644 --- a/app/Http/Controllers/Stripe/GetPlans.php +++ b/app/Http/Controllers/Stripe/GetPlans.php @@ -22,7 +22,7 @@ public function __invoke(Request $request) $plans = Stripe\Plan::all(); $result = []; - foreach ($plans as $k => $plan) { + foreach ($plans as $plan) { if (! $plan->active || $plan->amount == 0) { continue; } @@ -62,10 +62,10 @@ public function __invoke(Request $request) ]; foreach ($plan->metadata->toArray() as $key => $value) { - if (preg_match('/^feature-missing[0-9]*$/', $key)) { + if (preg_match('/^feature-missing\d*$/', (string) $key)) { $row['features_missing'][] = $value; } - if (preg_match('/^feature[0-9]*$/', $key)) { + if (preg_match('/^feature\d*$/', (string) $key)) { $row['features'][] = $value; } if ($key == 'featured' && ($value == 1 || $value == 'true')) { diff --git a/app/Http/Controllers/Stripe/Subscribe.php b/app/Http/Controllers/Stripe/Subscribe.php index 5a9ace660..a323df7aa 100644 --- a/app/Http/Controllers/Stripe/Subscribe.php +++ b/app/Http/Controllers/Stripe/Subscribe.php @@ -27,31 +27,25 @@ public function __invoke(Request $request) if ($request->has('payment_method')) { $paymentMethod = $request->payment_method; - $subscription = $user->newSubscription('default', $plan_id) ->trialDays(14); - if ($couponId = $request->input('coupon_id')) { $subscription->withCoupon($couponId); } - $subscription->create($paymentMethod); - $user->notify(new SubscribeSuccessfully($plan_id)); - } else { - if ($user->subscribed('default')) { - $subscription = $user->subscription(); - if ($subscription->stripe_status == 'canceled') { - $user->newSubscription('default', $plan_id) - ->trialDays(14) - ->create(); - $user->notify(new SubscribeSuccessfully($plan_id)); - } else { - $user->subscription('default')->swap($plan_id); - } + } elseif ($user->subscribed('default')) { + $subscription = $user->subscription(); + if ($subscription->stripe_status == 'canceled') { + $user->newSubscription('default', $plan_id) + ->trialDays(14) + ->create(); + $user->notify(new SubscribeSuccessfully($plan_id)); } else { $user->subscription('default')->swap($plan_id); } + } else { + $user->subscription('default')->swap($plan_id); } return ['success' => true]; diff --git a/app/Http/Controllers/Stripe/VerifyCoupon.php b/app/Http/Controllers/Stripe/VerifyCoupon.php index e0717d421..c63fa9005 100644 --- a/app/Http/Controllers/Stripe/VerifyCoupon.php +++ b/app/Http/Controllers/Stripe/VerifyCoupon.php @@ -11,7 +11,6 @@ class VerifyCoupon extends Controller /** * Handle the incoming request. * - * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function __invoke(Request $request) @@ -29,14 +28,14 @@ public function __invoke(Request $request) try { foreach (\Stripe\Coupon::all()->data as $coupon) { - if (strtolower($coupon->name) == strtolower($couponCode) && $coupon->valid) { + if (strtolower((string) $coupon->name) === strtolower((string) $couponCode) && $coupon->valid) { return [ 'success' => true, 'coupon' => $coupon, ]; } } - } catch (\Stripe\Exception\InvalidRequestException $e) { + } catch (\Stripe\Exception\InvalidRequestException) { return ['success' => false, 'message' => 'There was an error when checking your coupon.']; } diff --git a/app/Http/Controllers/Stripe/Webhook.php b/app/Http/Controllers/Stripe/Webhook.php index 808ad4312..36730ca6d 100644 --- a/app/Http/Controllers/Stripe/Webhook.php +++ b/app/Http/Controllers/Stripe/Webhook.php @@ -19,7 +19,7 @@ class Webhook extends Controller public function __invoke(Request $request) { Stripe\Stripe::setApiKey(\Config::get('services.stripe.secret')); - $plans = Stripe\Plan::all(); + Stripe\Plan::all(); $data = request()->all(); if ($data) { @@ -37,7 +37,7 @@ public function __invoke(Request $request) $user = User::where('stripe_id', $data['data']['object']['customer'])->first(); if ($user) { $plan_nickname = $data['data']['object']['plan']['nickname']; - $roles = Role::where('name', strtolower($plan_nickname))->first(); + $roles = Role::where('name', strtolower((string) $plan_nickname))->first(); if ($roles) { $user->role_id = $roles->id; $user->save(); @@ -49,7 +49,7 @@ public function __invoke(Request $request) $user = User::where('stripe_id', $data['data']['object']['customer'])->first(); if ($user) { $plan_nickname = $data['data']['object']['lines']['data'][0]['plan']['nickname']; - $roles = Role::where('name', strtolower($plan_nickname))->first(); + $roles = Role::where('name', strtolower((string) $plan_nickname))->first(); if ($roles) { $user->role_id = $roles->id; $user->save(); diff --git a/app/Http/Controllers/Trees/Ancestors.php b/app/Http/Controllers/Trees/Ancestors.php index bc8793bbe..f7d0f1d3c 100644 --- a/app/Http/Controllers/Trees/Ancestors.php +++ b/app/Http/Controllers/Trees/Ancestors.php @@ -56,7 +56,7 @@ private function getGraphData($start_id, $nest = 1) } $families = Family::where('husband_id', $start_id)->orwhere('wife_id', $start_id)->get(); - if (! (is_countable($families) ? count($families) : 0)) { + if ((is_countable($families) ? count($families) : 0) === 0) { $person->setAttribute('own_unions', []); $person['generation'] = $nest; $this->persons[$start_id] = $person; diff --git a/app/Http/Controllers/Trees/Show.php b/app/Http/Controllers/Trees/Show.php index e196a3546..a28a4c71f 100644 --- a/app/Http/Controllers/Trees/Show.php +++ b/app/Http/Controllers/Trees/Show.php @@ -49,7 +49,7 @@ private function getGraphData($start_id, $nest = 1) } $families = Family::where('husband_id', $start_id)->orwhere('wife_id', $start_id)->get(); - if (! (is_countable($families) ? count($families) : 0)) { + if ((is_countable($families) ? count($families) : 0) === 0) { $person = Person::find($start_id); // do not process for null diff --git a/app/Http/Controllers/WikiTree/WikitreeController.php b/app/Http/Controllers/WikiTree/WikitreeController.php index a09017d4c..e6c220153 100644 --- a/app/Http/Controllers/WikiTree/WikitreeController.php +++ b/app/Http/Controllers/WikiTree/WikitreeController.php @@ -35,7 +35,7 @@ public function getAuthCode(Request $request) return redirect($redirectTo); } - public function getAuthCodeCallBack(Request $request) + public function getAuthCodeCallBack(Request $request): string { return 'Auth code recieved :: '.$request->authcode; } @@ -76,7 +76,7 @@ public function searchPerson(Request $request) $ancestors = json_decode($response->getBody(), true, 512, JSON_THROW_ON_ERROR); $person['ancestors'] = $ancestors; - array_push($newPersons, $person); + $newPersons[] = $person; } return response()->json($newPersons); diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 278e5a78c..27ad4a2d4 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -37,7 +37,7 @@ class Kernel extends HttpKernel ], ]; - protected $routeMiddleware = [ + protected $middlewareAliases = [ 'auth' => \App\Http\Middleware\Authenticate::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, diff --git a/app/Http/Middleware/Multitenant.php b/app/Http/Middleware/Multitenant.php index 4552dcc56..512111cbe 100644 --- a/app/Http/Middleware/Multitenant.php +++ b/app/Http/Middleware/Multitenant.php @@ -20,8 +20,7 @@ public function handle($request, Closure $next) // Log::debug(); $user = \Auth::user(); -// Log::debug($user->role_id.'-roleId'); - $conn = \Session::get('conn'); +\Session::get('conn'); //$value = \Session::get('db'); if ($user->isAdmin()) { $key = 'database.connections.mysql.database'; @@ -42,9 +41,8 @@ public function handle($request, Closure $next) // Log::debug('Avatar-'.$user->avatar); // Log::debug($company); session()->put('db', $value); - $x = config([$key => $value]); - //if ($conn === 'tenant') { - $databaseName = \DB::connection('tenantdb')->getDatabaseName(); + config([$key => $value]); + \DB::connection('tenantdb')->getDatabaseName(); // Log::debug('DB-'.$databaseName); //Family::setConnection(); @@ -58,10 +56,4 @@ public function handle($request, Closure $next) }*/ return $next($request); } - - private function ownerRequestsTenant($request) - { - return $request->user()->isSupervisor(); - // && $request->has('_tenantId'); - } } diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index a73dacef4..2a2ed8b36 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -11,7 +11,7 @@ class RedirectIfAuthenticated { public function handle(Request $request, Closure $next, ...$guards) { - $guards = empty($guards) ? [null] : $guards; + $guards = $guards === [] ? [null] : $guards; foreach ($guards as $guard) { if (Auth::guard($guard)->check()) { diff --git a/app/Http/Requests/ValidateAddrRequest.php b/app/Http/Requests/ValidateAddrRequest.php index 1ba1ca350..7d9ffba99 100644 --- a/app/Http/Requests/ValidateAddrRequest.php +++ b/app/Http/Requests/ValidateAddrRequest.php @@ -6,14 +6,14 @@ class ValidateAddrRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } public function rules() { - $addresses = $this->route('addresses'); + $this->route('addresses'); return [ diff --git a/app/Http/Requests/ValidateAuthorRequest.php b/app/Http/Requests/ValidateAuthorRequest.php index b59be2d6b..4ddce293a 100644 --- a/app/Http/Requests/ValidateAuthorRequest.php +++ b/app/Http/Requests/ValidateAuthorRequest.php @@ -6,14 +6,14 @@ class ValidateAuthorRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } public function rules() { - $author = $this->route('author'); + $this->route('author'); return [ 'description' => 'required|max:50', diff --git a/app/Http/Requests/ValidateCategoryRequest.php b/app/Http/Requests/ValidateCategoryRequest.php index 880b86020..c2d0e70ea 100644 --- a/app/Http/Requests/ValidateCategoryRequest.php +++ b/app/Http/Requests/ValidateCategoryRequest.php @@ -6,7 +6,7 @@ class ValidateCategoryRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } diff --git a/app/Http/Requests/ValidateChanRequest.php b/app/Http/Requests/ValidateChanRequest.php index 94deed677..c31c1d253 100644 --- a/app/Http/Requests/ValidateChanRequest.php +++ b/app/Http/Requests/ValidateChanRequest.php @@ -6,14 +6,14 @@ class ValidateChanRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } public function rules() { - $chan = $this->route('chan'); + $this->route('chan'); return [ diff --git a/app/Http/Requests/ValidateCitationRequest.php b/app/Http/Requests/ValidateCitationRequest.php index 0d3f1b0e5..32dbb3552 100644 --- a/app/Http/Requests/ValidateCitationRequest.php +++ b/app/Http/Requests/ValidateCitationRequest.php @@ -6,14 +6,14 @@ class ValidateCitationRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } public function rules() { - $citation = $this->route('citation'); + $this->route('citation'); return [ 'description' => 'required|max:50', diff --git a/app/Http/Requests/ValidateFamilyEventRequest.php b/app/Http/Requests/ValidateFamilyEventRequest.php index 6f3cb48aa..fb551f045 100644 --- a/app/Http/Requests/ValidateFamilyEventRequest.php +++ b/app/Http/Requests/ValidateFamilyEventRequest.php @@ -6,14 +6,14 @@ class ValidateFamilyEventRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } public function rules() { - $familyevent = $this->route('familyevent'); + $this->route('familyevent'); return [ 'family_id' => '', diff --git a/app/Http/Requests/ValidateFamilyRequest.php b/app/Http/Requests/ValidateFamilyRequest.php index b18d16de4..2c5ed2514 100644 --- a/app/Http/Requests/ValidateFamilyRequest.php +++ b/app/Http/Requests/ValidateFamilyRequest.php @@ -6,14 +6,14 @@ class ValidateFamilyRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } public function rules() { - $family = $this->route('family'); + $this->route('family'); return [ 'is_active' => 'boolean', diff --git a/app/Http/Requests/ValidateFamilySlgsRequest.php b/app/Http/Requests/ValidateFamilySlgsRequest.php index 37b87310f..6cc073759 100644 --- a/app/Http/Requests/ValidateFamilySlgsRequest.php +++ b/app/Http/Requests/ValidateFamilySlgsRequest.php @@ -6,14 +6,14 @@ class ValidateFamilySlgsRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } public function rules() { - $familyslgs = $this->route('familyslgs'); + $this->route('familyslgs'); return [ diff --git a/app/Http/Requests/ValidateMediaObjectRequest.php b/app/Http/Requests/ValidateMediaObjectRequest.php index 76bf7b4bd..26872d4ba 100644 --- a/app/Http/Requests/ValidateMediaObjectRequest.php +++ b/app/Http/Requests/ValidateMediaObjectRequest.php @@ -6,14 +6,14 @@ class ValidateMediaObjectRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } public function rules() { - $mediaobjects = $this->route('mediaobjects'); + $this->route('mediaobjects'); return [ 'gid' => 'required|max:50', diff --git a/app/Http/Requests/ValidateNoteRequest.php b/app/Http/Requests/ValidateNoteRequest.php index 0d1d4baaf..a95ddf04e 100644 --- a/app/Http/Requests/ValidateNoteRequest.php +++ b/app/Http/Requests/ValidateNoteRequest.php @@ -6,14 +6,14 @@ class ValidateNoteRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } public function rules() { - $note = $this->route('note'); + $this->route('note'); return [ 'name' => 'required|max:50', diff --git a/app/Http/Requests/ValidatePersonAliaRequest.php b/app/Http/Requests/ValidatePersonAliaRequest.php index 25e8cb134..d004d7e2c 100644 --- a/app/Http/Requests/ValidatePersonAliaRequest.php +++ b/app/Http/Requests/ValidatePersonAliaRequest.php @@ -6,14 +6,14 @@ class ValidatePersonAliaRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } public function rules() { - $personalias = $this->route('personalias'); + $this->route('personalias'); return [ diff --git a/app/Http/Requests/ValidatePersonAnciRequest.php b/app/Http/Requests/ValidatePersonAnciRequest.php index 5eb994fc0..b312e8ced 100644 --- a/app/Http/Requests/ValidatePersonAnciRequest.php +++ b/app/Http/Requests/ValidatePersonAnciRequest.php @@ -6,14 +6,14 @@ class ValidatePersonAnciRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } public function rules() { - $personanci = $this->route('personanci'); + $this->route('personanci'); return [ diff --git a/app/Http/Requests/ValidatePersonAssoRequest.php b/app/Http/Requests/ValidatePersonAssoRequest.php index f5d6c66f3..5efb5c987 100644 --- a/app/Http/Requests/ValidatePersonAssoRequest.php +++ b/app/Http/Requests/ValidatePersonAssoRequest.php @@ -6,14 +6,14 @@ class ValidatePersonAssoRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } public function rules() { - $personassociation = $this->route('personassociation'); + $this->route('personassociation'); return [ diff --git a/app/Http/Requests/ValidatePersonEventRequest.php b/app/Http/Requests/ValidatePersonEventRequest.php index c092d89d0..29989dc36 100644 --- a/app/Http/Requests/ValidatePersonEventRequest.php +++ b/app/Http/Requests/ValidatePersonEventRequest.php @@ -6,14 +6,14 @@ class ValidatePersonEventRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } public function rules() { - $personevent = $this->route('personevent'); + $this->route('personevent'); return [ diff --git a/app/Http/Requests/ValidatePersonLdsRequest.php b/app/Http/Requests/ValidatePersonLdsRequest.php index 7466472d5..fc5f753b7 100644 --- a/app/Http/Requests/ValidatePersonLdsRequest.php +++ b/app/Http/Requests/ValidatePersonLdsRequest.php @@ -6,14 +6,14 @@ class ValidatePersonLdsRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } public function rules() { - $personlds = $this->route('personlds'); + $this->route('personlds'); return [ diff --git a/app/Http/Requests/ValidatePersonRequest.php b/app/Http/Requests/ValidatePersonRequest.php index 9644701f2..f770c04c4 100644 --- a/app/Http/Requests/ValidatePersonRequest.php +++ b/app/Http/Requests/ValidatePersonRequest.php @@ -8,8 +8,6 @@ class ValidatePersonRequest extends EnsoPerson { - private readonly Collection $companies; - public function authorize() { return $this->emailUnchagedForUser(); diff --git a/app/Http/Requests/ValidatePersonSubmRequest.php b/app/Http/Requests/ValidatePersonSubmRequest.php index 57da2acfc..441c26f13 100644 --- a/app/Http/Requests/ValidatePersonSubmRequest.php +++ b/app/Http/Requests/ValidatePersonSubmRequest.php @@ -6,14 +6,14 @@ class ValidatePersonSubmRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } public function rules() { - $personsubm = $this->route('personsubm'); + $this->route('personsubm'); return [ diff --git a/app/Http/Requests/ValidatePlaceRequest.php b/app/Http/Requests/ValidatePlaceRequest.php index 7c2930244..5a547d3eb 100644 --- a/app/Http/Requests/ValidatePlaceRequest.php +++ b/app/Http/Requests/ValidatePlaceRequest.php @@ -8,10 +8,8 @@ class ValidatePlaceRequest extends FormRequest { /** * Determine if the user is authorized to make this request. - * - * @return bool */ - public function authorize() + public function authorize(): bool { return true; } diff --git a/app/Http/Requests/ValidatePostRequest.php b/app/Http/Requests/ValidatePostRequest.php index 2ac98de94..7292bd23e 100644 --- a/app/Http/Requests/ValidatePostRequest.php +++ b/app/Http/Requests/ValidatePostRequest.php @@ -6,7 +6,7 @@ class ValidatePostRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } diff --git a/app/Http/Requests/ValidatePublicationRequest.php b/app/Http/Requests/ValidatePublicationRequest.php index 29e4e5e6f..958ba936d 100644 --- a/app/Http/Requests/ValidatePublicationRequest.php +++ b/app/Http/Requests/ValidatePublicationRequest.php @@ -6,14 +6,14 @@ class ValidatePublicationRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } public function rules() { - $publication = $this->route('publication'); + $this->route('publication'); return [ 'description' => 'required|max:50', diff --git a/app/Http/Requests/ValidateRefnRequest.php b/app/Http/Requests/ValidateRefnRequest.php index b4812b5d9..3af77abf1 100644 --- a/app/Http/Requests/ValidateRefnRequest.php +++ b/app/Http/Requests/ValidateRefnRequest.php @@ -6,14 +6,14 @@ class ValidateRefnRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } public function rules() { - $refn = $this->route('refn'); + $this->route('refn'); return [ diff --git a/app/Http/Requests/ValidateRepositoryRequest.php b/app/Http/Requests/ValidateRepositoryRequest.php index cee4f8f9f..33ca34fcd 100644 --- a/app/Http/Requests/ValidateRepositoryRequest.php +++ b/app/Http/Requests/ValidateRepositoryRequest.php @@ -6,14 +6,14 @@ class ValidateRepositoryRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } public function rules() { - $repository = $this->route('repository'); + $this->route('repository'); return [ 'description' => 'required|max:50', diff --git a/app/Http/Requests/ValidateSourceDataEvenRequest.php b/app/Http/Requests/ValidateSourceDataEvenRequest.php index ba1cb1369..a37fada8c 100644 --- a/app/Http/Requests/ValidateSourceDataEvenRequest.php +++ b/app/Http/Requests/ValidateSourceDataEvenRequest.php @@ -6,14 +6,14 @@ class ValidateSourceDataEvenRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } public function rules() { - $sourcedataeven = $this->route('sourcedataeven'); + $this->route('sourcedataeven'); return [ diff --git a/app/Http/Requests/ValidateSourceDataRequest.php b/app/Http/Requests/ValidateSourceDataRequest.php index ba322cfaf..da16cadf0 100644 --- a/app/Http/Requests/ValidateSourceDataRequest.php +++ b/app/Http/Requests/ValidateSourceDataRequest.php @@ -6,14 +6,14 @@ class ValidateSourceDataRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } public function rules() { - $sourcedata = $this->route('sourcedata'); + $this->route('sourcedata'); return [ diff --git a/app/Http/Requests/ValidateSourceRefEvenRequest.php b/app/Http/Requests/ValidateSourceRefEvenRequest.php index 03824d7f2..8447a3ed9 100644 --- a/app/Http/Requests/ValidateSourceRefEvenRequest.php +++ b/app/Http/Requests/ValidateSourceRefEvenRequest.php @@ -6,14 +6,14 @@ class ValidateSourceRefEvenRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } public function rules() { - $sourcerefeven = $this->route('sourcerefeven'); + $this->route('sourcerefeven'); return [ diff --git a/app/Http/Requests/ValidateSourceRequest.php b/app/Http/Requests/ValidateSourceRequest.php index 4aa6deff2..2f456880b 100644 --- a/app/Http/Requests/ValidateSourceRequest.php +++ b/app/Http/Requests/ValidateSourceRequest.php @@ -6,14 +6,14 @@ class ValidateSourceRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } public function rules() { - $source = $this->route('source'); + $this->route('source'); return [ 'description' => 'required|max:50', diff --git a/app/Http/Requests/ValidateSubmRequest.php b/app/Http/Requests/ValidateSubmRequest.php index bb22a67e5..3ab430460 100644 --- a/app/Http/Requests/ValidateSubmRequest.php +++ b/app/Http/Requests/ValidateSubmRequest.php @@ -6,14 +6,14 @@ class ValidateSubmRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } public function rules() { - $subm = $this->route('subm'); + $this->route('subm'); return [ diff --git a/app/Http/Requests/ValidateSubnRequest.php b/app/Http/Requests/ValidateSubnRequest.php index aaf7a1ed0..51b4bb334 100644 --- a/app/Http/Requests/ValidateSubnRequest.php +++ b/app/Http/Requests/ValidateSubnRequest.php @@ -6,14 +6,14 @@ class ValidateSubnRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } public function rules() { - $subn = $this->route('subn'); + $this->route('subn'); return [ diff --git a/app/Http/Requests/ValidateTopicRequest.php b/app/Http/Requests/ValidateTopicRequest.php index 57427daf8..1bb46acf2 100644 --- a/app/Http/Requests/ValidateTopicRequest.php +++ b/app/Http/Requests/ValidateTopicRequest.php @@ -6,7 +6,7 @@ class ValidateTopicRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } diff --git a/app/Http/Requests/ValidateTypeRequest.php b/app/Http/Requests/ValidateTypeRequest.php index 04a9be747..de31087a3 100644 --- a/app/Http/Requests/ValidateTypeRequest.php +++ b/app/Http/Requests/ValidateTypeRequest.php @@ -6,14 +6,14 @@ class ValidateTypeRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } public function rules() { - $type = $this->route('type'); + $this->route('type'); return [ 'description' => 'required|max:50', diff --git a/app/Http/Requests/ValidateUserRequest.php b/app/Http/Requests/ValidateUserRequest.php index 379e71e83..4d4cd3628 100644 --- a/app/Http/Requests/ValidateUserRequest.php +++ b/app/Http/Requests/ValidateUserRequest.php @@ -9,7 +9,7 @@ class ValidateUserRequest extends FormRequest { - public function authorize() + public function authorize(): bool { return true; } diff --git a/app/Jobs/DnaMatching.php b/app/Jobs/DnaMatching.php index 005f1b9d7..ea001082f 100644 --- a/app/Jobs/DnaMatching.php +++ b/app/Jobs/DnaMatching.php @@ -39,11 +39,8 @@ public function handle() $dnas = Dna::where('variable_name', '!=', $this->var_name)->get(); $mpath = app_path(); - $output = null; - $retval = null; - foreach ($dnas as $dna) { - Log::info(json_encode($dna)); + Log::info(json_encode($dna, JSON_THROW_ON_ERROR)); Log::info(storage_path('/app/public/dna/output/shared_dna_'.$this->var_name.'_'.$dna->variable_name.'_'.$this->file_name.'_'.$dna->file_name)); // system('/usr/bin/python3 /home/genealogia/public_html/dna.py ' . $this->var_name . ' ' . $dna->variable_name . ' ' . '/home/genealogia/public_html/storage/app/dna/'. $this->file_name . ' ' . '/home/genealogia/public_html/storage/app/dna/'. $dna->file_name); // chdir('/home/familytree365/domains/api.familytree365.com/genealogy/app'); @@ -51,7 +48,7 @@ public function handle() // exec('python dna.py '.$this->var_name.' '.$dna->variable_name.' '.$this->file_name.' '.$dna->file_name, $dna_output); $result = exec('python3 dna.py '.$this->var_name.' '.$dna->variable_name.' '.$this->file_name.' '.$dna->file_name); // $resultData = json_decode($result, true, 512, JSON_THROW_ON_ERROR); - $resultData = json_decode($result, true); + $resultData = json_decode($result, true, 512, JSON_THROW_ON_ERROR); // chmod(storage_path('/app/public/dna/output/shared_dna_'.$this->var_name.'_'.$dna->variable_name.'_'.$this->file_name.'_'.$dna->file_name), 0777); $dm = new DM(); diff --git a/app/Jobs/ExportGedCom.php b/app/Jobs/ExportGedCom.php index 5c9de4d84..ddddbc148 100644 --- a/app/Jobs/ExportGedCom.php +++ b/app/Jobs/ExportGedCom.php @@ -48,11 +48,7 @@ public function handle() if ($family == null) { $person = Person::where('child_in_family_id', $this->user->id)->first(); - if ($person != null) { - $f_id = $person->child_in_family_id; - } else { - $f_id = 0; - } + $f_id = $person != null ? $person->child_in_family_id : 0; } else { $f_id = $family->id; } diff --git a/app/Jobs/Geneanum/Sync.php b/app/Jobs/Geneanum/Sync.php index e05d2dfa5..b41666ea7 100644 --- a/app/Jobs/Geneanum/Sync.php +++ b/app/Jobs/Geneanum/Sync.php @@ -39,7 +39,6 @@ public function __construct(int $page = 1, int $retry = 0) /** * Execute the job. * - * @return void * * @throws \Exception */ diff --git a/app/Jobs/Tenant/CreateDB.php b/app/Jobs/Tenant/CreateDB.php index d7374863a..1180243ef 100644 --- a/app/Jobs/Tenant/CreateDB.php +++ b/app/Jobs/Tenant/CreateDB.php @@ -32,7 +32,7 @@ public function __construct(private readonly Company $tenant) */ public function handle() { - $tenant = Tenants::create([ + Tenants::create([ 'id' => $this->tenant->id, ]); diff --git a/app/Jobs/Tenant/CreateDBs.php b/app/Jobs/Tenant/CreateDBs.php index 56ef8191a..617c8eec2 100644 --- a/app/Jobs/Tenant/CreateDBs.php +++ b/app/Jobs/Tenant/CreateDBs.php @@ -30,7 +30,7 @@ public function __construct(private readonly Company $tenant) */ public function handle() { - $tenant = Tenants::create([ + Tenants::create([ 'id' => $this->tenant->id, ]); } diff --git a/app/Jobs/Tenant/Migration.php b/app/Jobs/Tenant/Migration.php index 8bc83e280..c0cbb0db1 100644 --- a/app/Jobs/Tenant/Migration.php +++ b/app/Jobs/Tenant/Migration.php @@ -46,8 +46,6 @@ public function handle() 'name' => $na, ])); - - $user_group = 1; $user_group = $tenants->run(fn () => UserGroup::create([ 'name' => 'Administrators', 'description' => 'Administrator users group', diff --git a/app/Jobs/Tenant/MigrationFresh.php b/app/Jobs/Tenant/MigrationFresh.php index e6aa280cf..317897ea7 100644 --- a/app/Jobs/Tenant/MigrationFresh.php +++ b/app/Jobs/Tenant/MigrationFresh.php @@ -35,7 +35,6 @@ public function handle() { Tenant::set($this->tenant); $company = Tenant::get(); - $db = Connections::Tenant.$company->id; Artisan::call('migrate:fresh', [ '--database' => $company, diff --git a/app/Logic/Activation/ActivationRepository.php b/app/Logic/Activation/ActivationRepository.php index 9f4d52f96..678bd1c98 100644 --- a/app/Logic/Activation/ActivationRepository.php +++ b/app/Logic/Activation/ActivationRepository.php @@ -19,7 +19,7 @@ class ActivationRepository */ public function createTokenAndSendEmail(User $user) { - $activations = Activation::where('user_id', $user->id) + Activation::where('user_id', $user->id) ->where('created_at', '>=', Carbon::now()->subHours(config('settings.timePeriod'))) ->count(); diff --git a/app/Models/Person.php b/app/Models/Person.php index 13dcd3117..a7607b18c 100644 --- a/app/Models/Person.php +++ b/app/Models/Person.php @@ -84,12 +84,12 @@ public function wife_in_family() return $this->hasMany(Family::class, 'wife_id'); } - public function fullname() + public function fullname(): string { return $this->givn.' '.$this->surn; } - public function getSex() + public function getSex(): string { if ($this->sex === 'F') { return 'Female'; @@ -174,10 +174,8 @@ public function setUpdatedBy() } file_put_contents(storage_path('app/public/file.txt'), $this->connection); - if ($this->connection !== 'tenant') { - if (Auth::check()) { - $this->updated_by = Auth::id(); - } + if ($this->connection !== 'tenant' && Auth::check()) { + $this->updated_by = Auth::id(); } } } diff --git a/app/Models/SystemPerson.php b/app/Models/SystemPerson.php index e95d8fcdf..e51428177 100644 --- a/app/Models/SystemPerson.php +++ b/app/Models/SystemPerson.php @@ -6,7 +6,7 @@ class SystemPerson extends Person { protected $table = 'people'; - public function getConnectionName() + public function getConnectionName(): string { return 'mysql'; } diff --git a/app/Models/User.php b/app/Models/User.php index f373dafe3..37a2e691a 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -36,7 +36,7 @@ public function getNameAttribute() return $this->person?->name; } - public function hasSocialLinked($service) + public function hasSocialLinked($service): bool { return (bool) $this->social->where('service', $service)->count(); } diff --git a/app/Notifications/SubscribeSuccessfully.php b/app/Notifications/SubscribeSuccessfully.php index eeea67599..6a3327425 100755 --- a/app/Notifications/SubscribeSuccessfully.php +++ b/app/Notifications/SubscribeSuccessfully.php @@ -20,11 +20,7 @@ class SubscribeSuccessfully extends Notification public function __construct($plan_id) { $stripe = new \Stripe\StripeClient(\Config::get('services.stripe.secret')); - if (is_array($plan_id)) { - $this->plan = $stripe->plans->retrieve($plan_id['planId']); - } else { - $this->plan = $stripe->plans->retrieve($plan_id); - } + $this->plan = is_array($plan_id) ? $stripe->plans->retrieve($plan_id['planId']) : $stripe->plans->retrieve($plan_id); } /** diff --git a/app/Service/Tenant.php b/app/Service/Tenant.php index 773a525f7..bb6c45278 100644 --- a/app/Service/Tenant.php +++ b/app/Service/Tenant.php @@ -32,7 +32,7 @@ public static function tenantDatabase() return config('database.connections.'.Connections::Tenant.'.database'); } - private static function tenantId() + private static function tenantId(): int { return (int) Str::replaceFirst(Connections::Tenant, '', self::tenantDatabase()); } diff --git a/app/Tenant/Manager.php b/app/Tenant/Manager.php index 00e70059b..65c9ff633 100644 --- a/app/Tenant/Manager.php +++ b/app/Tenant/Manager.php @@ -94,9 +94,9 @@ public function databaseExists(): bool $this->config->set('database.default', 'tenant'); } - return count($this->database->select(<<database->select(<< 0; + SQL) !== []; } catch (\PDOException) { return false; } diff --git a/app/Traits/ActivationTrait.php b/app/Traits/ActivationTrait.php index 0452e94e6..e57b0ba78 100644 --- a/app/Traits/ActivationTrait.php +++ b/app/Traits/ActivationTrait.php @@ -31,11 +31,6 @@ public function initiateEmailActivationApi(User $user) protected function validateEmail(User $user) { $validator = Validator::make(['email' => $user->email], ['email' => 'required|email']); - - if ($validator->fails()) { - return false; - } - - return true; + return !$validator->fails(); } } diff --git a/app/Traits/TenantConnectionResolver.php b/app/Traits/TenantConnectionResolver.php index f561a4e4d..9398579ad 100644 --- a/app/Traits/TenantConnectionResolver.php +++ b/app/Traits/TenantConnectionResolver.php @@ -9,16 +9,14 @@ trait TenantConnectionResolver { public function getConnectionName() { - if (! App::runningUnitTests()) { - if (Auth::check()) { - $user = \Auth::user(); - $role_id = $user->role_id; - if ($user->isAdmin()) { - return env('DB_DATABASE', 'genealogy'); //'enso'); - } - if (session()->get('db')) { - return 'tenantdb'; - } + if (! App::runningUnitTests() && Auth::check()) { + $user = \Auth::user(); + $role_id = $user->role_id; + if ($user->isAdmin()) { + return env('DB_DATABASE', 'genealogy'); //'enso'); + } + if (session()->get('db')) { + return 'tenantdb'; } } diff --git a/composer.json b/composer.json index 779f41c5d..8de05aaf7 100644 --- a/composer.json +++ b/composer.json @@ -45,6 +45,7 @@ "barryvdh/laravel-debugbar": "^3.5", "barryvdh/laravel-ide-helper": "^2.10", "brianium/paratest": "^7.1", + "driftingly/rector-laravel": "*", "fakerphp/faker": "^1.15", "filp/whoops": "^2.1", "laravel-liberu/cli": "^5.0", @@ -54,7 +55,7 @@ "nunomaduro/collision": "^7.1", "nunomaduro/phpinsights": "^2.0", "phpunit/phpunit": "^10.1", - "rector/rector": "^0.17.0", + "rector/rector": "*", "spatie/laravel-ignition": "^2.1" }, "config": { diff --git a/composer.lock b/composer.lock index 68b101c47..3643310f6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3813fb1798e9f03d460340a95a6c3d6c", + "content-hash": "1fb15205e05f620c1befc01ab539e841", "packages": [ { "name": "anlutro/curl", @@ -14859,6 +14859,40 @@ }, "time": "2023-02-02T22:02:53+00:00" }, + { + "name": "driftingly/rector-laravel", + "version": "0.25.0", + "source": { + "type": "git", + "url": "https://github.com/driftingly/rector-laravel.git", + "reference": "c568226985f9f388f1deabd77eea89d440372edd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/driftingly/rector-laravel/zipball/c568226985f9f388f1deabd77eea89d440372edd", + "reference": "c568226985f9f388f1deabd77eea89d440372edd", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "rector-extension", + "autoload": { + "psr-4": { + "RectorLaravel\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Rector upgrades rules for Laravel Framework", + "support": { + "issues": "https://github.com/driftingly/rector-laravel/issues", + "source": "https://github.com/driftingly/rector-laravel/tree/0.25.0" + }, + "time": "2023-09-18T20:17:51+00:00" + }, { "name": "fakerphp/faker", "version": "v1.23.0", @@ -16758,16 +16792,16 @@ }, { "name": "rector/rector", - "version": "0.17.4", + "version": "0.17.6", "source": { "type": "git", "url": "https://github.com/rectorphp/rector.git", - "reference": "14829888274eebddc67a0d7248c3dd2965704fbc" + "reference": "ec40080b9bdaf39eb0c0a9276cd7b4a778c03f21" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/rectorphp/rector/zipball/14829888274eebddc67a0d7248c3dd2965704fbc", - "reference": "14829888274eebddc67a0d7248c3dd2965704fbc", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/ec40080b9bdaf39eb0c0a9276cd7b4a778c03f21", + "reference": "ec40080b9bdaf39eb0c0a9276cd7b4a778c03f21", "shasum": "" }, "require": { @@ -16807,7 +16841,7 @@ ], "support": { "issues": "https://github.com/rectorphp/rector/issues", - "source": "https://github.com/rectorphp/rector/tree/0.17.4" + "source": "https://github.com/rectorphp/rector/tree/0.17.6" }, "funding": [ { @@ -16815,7 +16849,7 @@ "type": "github" } ], - "time": "2023-07-11T16:00:46+00:00" + "time": "2023-07-14T09:54:15+00:00" }, { "name": "sebastian/cli-parser", @@ -18541,5 +18575,5 @@ "php": ">=8.2.0" }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/config/enso/exports.php b/config/enso/exports.php index a3a825554..efd41a5ef 100644 --- a/config/enso/exports.php +++ b/config/enso/exports.php @@ -10,7 +10,7 @@ | */ - 'rowLimit' => (int) env('EXPORT_ROW_LIMIT', 1000000), + 'rowLimit' => (int) env('EXPORT_ROW_LIMIT', 1_000_000), /* |-------------------------------------------------------------------------- diff --git a/config/enso/tables.php b/config/enso/tables.php index e787de833..d0b756278 100644 --- a/config/enso/tables.php +++ b/config/enso/tables.php @@ -202,7 +202,7 @@ 'export' => [ 'folder' => 'exports', 'timeout' => 60 * 60, - 'sheetLimit' => 1000000, + 'sheetLimit' => 1_000_000, 'notifications' => ['mail', 'broadcast', 'database'], ], @@ -238,7 +238,7 @@ | greatly improved. The info can still be called on demand. */ - 'fullInfoRecordLimit' => 1000000, + 'fullInfoRecordLimit' => 1_000_000, /* |-------------------------------------------------------------------------- diff --git a/config/sanctum.php b/config/sanctum.php index 529cfdc99..b739976d5 100644 --- a/config/sanctum.php +++ b/config/sanctum.php @@ -15,7 +15,7 @@ | */ - 'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf( + 'stateful' => explode(',', (string) env('SANCTUM_STATEFUL_DOMAINS', sprintf( '%s%s', 'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1', Sanctum::currentApplicationUrlWithPort() diff --git a/rector.php b/rector.php new file mode 100644 index 000000000..47419c06e --- /dev/null +++ b/rector.php @@ -0,0 +1,30 @@ +paths([ + __DIR__ . '/app', + __DIR__ . '/bootstrap', + __DIR__ . '/config', + __DIR__ . '/lang', + __DIR__ . '/public', + __DIR__ . '/resources', + __DIR__ . '/routes', + __DIR__ . '/tests', + ]); + + // register a single rule + $rectorConfig->sets([ +SetList::DEAD_CODE, + SetList::CODE_QUALITY, +LaravelSetList::LARAVEL_100, + LevelSetList::UP_TO_PHP_82 + ]); +}; diff --git a/routes/api.php b/routes/api.php index 4b1d7546b..29e781e70 100644 --- a/routes/api.php +++ b/routes/api.php @@ -473,25 +473,25 @@ // use App\Http\Controllers\Families\ExportGramps as FamiliesExportGramps; -Route::get('gramps-export', [ExportGramps::class, 'export']); -Route::post('gramps-import', [ImportGramps::class, 'import']); +Route::get('gramps-export', fn(\Illuminate\Http\Request $request) => (new \App\Http\Controllers\GrampsXml\Export())->export($request)); +Route::post('gramps-import', fn(\Illuminate\Http\Request $request) => (new \App\Http\Controllers\GrampsXml\Import())->import($request)); Route::namespace('Auth') ->middleware('api') ->group(function () { Route::middleware('guest')->group(function () { - Route::get('login/{provider}', [LoginController::class, 'redirectToProvider'])->name('login.provider'); - Route::get('login/{provider}/callback', [LoginController::class, 'handleProviderCallback'])->name('login.provider.callback'); + Route::get('login/{provider}', fn($provider) => (new \App\Http\Controllers\Auth\LoginController())->redirectToProvider($provider))->name('login.provider'); + Route::get('login/{provider}/callback', fn($provider): \App\Http\Controllers\Auth\JsonResponse => (new \App\Http\Controllers\Auth\LoginController())->handleProviderCallback($provider))->name('login.provider.callback'); - Route::post('login', [LoginController::class, 'login'])->name('login'); + Route::post('login', fn(\Illuminate\Http\Request $request) => (new \App\Http\Controllers\Auth\LoginController())->login($request))->name('login'); }); Route::middleware('auth')->group(function () { - Route::post('logout', [LoginController::class, 'logout'])->name('logout'); + Route::post('logout', fn(\Illuminate\Http\Request $request) => (new \App\Http\Controllers\Auth\LoginController())->logout($request))->name('logout'); }); - Route::post('confirm_checkout', [LoginController::class, 'confirmSubscription']); + Route::post('confirm_checkout', fn(\Illuminate\Http\Request $request) => (new \App\Http\Controllers\Auth\LoginController())->confirmSubscription($request)); - Route::post('register', [RegisterController::class, 'create']); + Route::post('register', fn(\Illuminate\Http\Request $request) => (new \App\Http\Controllers\Auth\RegisterController())->create($request)); Route::get('get-subscription-plan', [RegisterController::class, 'getSubscriptionPlan']); Route::post('verify', [RegisterController::class, 'verify_user']); }); @@ -507,25 +507,25 @@ ->namespace('') ->prefix('dashboard')->as('dashboard.') ->group(function () { - Route::get('line', [ChartController::class, 'line']) + Route::get('line', fn() => (new \App\Http\Controllers\Dashboard\ChartController())->line()) ->name('line'); - Route::get('bar', [ChartController::class, 'bar']) + Route::get('bar', fn() => (new \App\Http\Controllers\Dashboard\ChartController())->bar()) ->name('bar'); - Route::get('pie', [ChartController::class, 'pie']) + Route::get('pie', fn() => (new \App\Http\Controllers\Dashboard\ChartController())->pie()) ->name('pie'); - Route::get('doughnut', [ChartController::class, 'doughnut']) + Route::get('doughnut', fn() => (new \App\Http\Controllers\Dashboard\ChartController())->doughnut()) ->name('doughnut'); - Route::get('radar', [ChartController::class, 'radar']) + Route::get('radar', fn() => (new \App\Http\Controllers\Dashboard\ChartController())->radar()) ->name('radar'); - Route::get('polar', [ChartController::class, 'polar']) + Route::get('polar', fn() => (new \App\Http\Controllers\Dashboard\ChartController())->polar()) ->name('polar'); - Route::get('bubble', [ChartController::class, 'bubble']) + Route::get('bubble', fn() => (new \App\Http\Controllers\Dashboard\ChartController())->bubble()) ->name('bubble'); - Route::post('changedb', [ChartController::class, 'changedb']) + Route::post('changedb', fn(\Illuminate\Http\Request $request) => (new \App\Http\Controllers\Dashboard\ChartController())->changedb($request)) ->name('changedb'); - Route::post('getdb', [ChartController::class, 'getDB']) + Route::post('getdb', fn() => (new \App\Http\Controllers\Dashboard\ChartController())->getDB()) ->name('getdb'); - Route::get('trial', [ChartController::class, 'trial']) + Route::get('trial', fn() => (new \App\Http\Controllers\Dashboard\ChartController())->trial()) ->name('trial'); // Route::post('changeCompany', [ChartController::class, 'changeCompany']) // ->name('changeCompany'); @@ -851,40 +851,40 @@ Route::get('records-api/search-person', [RecordsAPIController::class, 'searchPerson'])->name('records-api.search-person'); // Wikitree -Route::get('wikitree/get-authcode', [WikitreeController::class, 'getAuthCode'])->name('wikitree.get-authcode'); -Route::get('wikitree/clientLoginResponse', [WikitreeController::class, 'getAuthCodeCallBack'])->name('wikitree.clientLoginResponse'); -Route::get('wikitree/search-person', [WikitreeController::class, 'searchPerson'])->name('wikitree.search-person'); +Route::get('wikitree/get-authcode', fn(\Illuminate\Http\Request $request) => (new \App\Http\Controllers\WikiTree\WikitreeController())->getAuthCode($request))->name('wikitree.get-authcode'); +Route::get('wikitree/clientLoginResponse', fn(\Illuminate\Http\Request $request): string => (new \App\Http\Controllers\WikiTree\WikitreeController())->getAuthCodeCallBack($request))->name('wikitree.clientLoginResponse'); +Route::get('wikitree/search-person', fn(\Illuminate\Http\Request $request) => (new \App\Http\Controllers\WikiTree\WikitreeController())->searchPerson($request))->name('wikitree.search-person'); // OpenArch Route::prefix('open-arch')->group(function () { - Route::get('search-person', [OpenArchController::class, 'searchPerson'])->name('search-person'); + Route::get('search-person', fn(\Illuminate\Http\Request $request) => (new \App\Http\Controllers\Openarch\OpenArchController())->searchPerson($request))->name('search-person'); }); // Member Tree Route::prefix('member-tree')->group(function () { - Route::get('search-person', [PeopleController::class, 'searchPerson'])->name('search-person'); + Route::get('search-person', fn(\Illuminate\Http\Request $request) => (new \App\Http\Controllers\Person\PeopleController())->searchPerson($request))->name('search-person'); }); // OpenArch Route::prefix('family-search')->group(function () { - Route::get('search', [FamilySearchController::class, 'searchPerson'])->name('search-person'); + Route::get('search', fn(\Illuminate\Http\Request $request) => (new \App\Http\Controllers\FamilySearch\FamilySearchController())->searchPerson($request))->name('search-person'); }); // UK national Arc Route::prefix('uk-national-arch')->group(function () { - Route::get('search-person', [NationalArchController::class, 'searchPerson'])->name('search-person'); + Route::get('search-person', fn(\Illuminate\Http\Request $request) => (new \App\Http\Controllers\NationalArch\NationalArchController())->searchPerson($request))->name('search-person'); }); // Genealogy Cloud Route::prefix('genealogy-cloud')->group(function () { - Route::get('search-person', [GenealogyCloudController::class, 'searchPerson'])->name('search-person'); + Route::get('search-person', fn(\Illuminate\Http\Request $request) => (new \App\Http\Controllers\GenealogyCloud\GenealogyCloudController())->searchPerson($request))->name('search-person'); }); // Geneanum Route::prefix('geneanum')->group(function () { - Route::get('search-person/{nation}/burials', [GeneanumController::class, 'burials']); - Route::get('search-person/{nation}/mariage', [GeneanumController::class, 'mariage']); - Route::get('search-person/{nation}/baptism', [GeneanumController::class, 'baptism']); + Route::get('search-person/{nation}/burials', fn(\Illuminate\Http\Request $request) => (new \App\Http\Controllers\Geneanum\GeneanumController())->burials($request)); + Route::get('search-person/{nation}/mariage', fn(\Illuminate\Http\Request $request) => (new \App\Http\Controllers\Geneanum\GeneanumController())->mariage($request)); + Route::get('search-person/{nation}/baptism', fn(\Illuminate\Http\Request $request) => (new \App\Http\Controllers\Geneanum\GeneanumController())->baptism($request)); }); Route::middleware(['api', 'auth', 'core', 'multitenant']) @@ -1489,7 +1489,7 @@ Route::get('current-subscription', StripeGetCurrentSubscription::class); Route::get('intent', StripeGetIntent::class); Route::get('plans', StripeGetPlans::class); - Route::post('update-default-payment-method', [StripePaymentMethod::class, 'updateDefaultPaymentMethod']); + Route::post('update-default-payment-method', fn(\Illuminate\Http\Request $request) => (new \App\Http\Controllers\Stripe\PaymentMethod())->updateDefaultPaymentMethod($request)); Route::post('subscribe', StripeSubscribe::class); Route::post('verify-coupon', StripeVerifyCoupon::class); Route::post('unsubscribe', StripeUnsubscribe::class); @@ -1520,20 +1520,20 @@ ->prefix('subscription') ->as('subscription.') ->group(function () { - Route::get('plans', [PlanController::class, 'getPlans']); + Route::get('plans', fn(\Illuminate\Http\Request $request): \Illuminate\Http\Response => (new \App\Http\Controllers\Subscription\PlanController())->getPlans($request)); }); Route::middleware(['auth', 'api']) ->group(function () { - Route::get('get_companies', [CompanyIndex::class, 'getCompany']); - Route::get('get_person', [PersonaliasIndex::class, 'getPerson']); - Route::get('trees/options', [TreesManage::class, 'getOptions']); + Route::get('get_companies', fn() => (new \App\Http\Controllers\Companies\Index())->getCompany()); + Route::get('get_person', fn() => (new \App\Http\Controllers\Personalias\Index())->getPerson()); + Route::get('trees/options', fn(\Illuminate\Http\Request $request) => (new \App\Http\Controllers\Trees\Manage())->getOptions($request)); }); Route::middleware(['auth', 'api', 'multitenant']) ->group(function () { Route::get('persons', GetPersons::class); - Route::get('getPersons', [GetPersons::class, 'getPersons']); + Route::get('getPersons', fn() => (new \App\Http\Controllers\Person\GetPersons())->getPersons()); }); Route::namespace('') @@ -1541,9 +1541,9 @@ Route::prefix('social/chats') ->as('social.chats.') ->group(function () { - Route::get('/', [ChatsController::class, 'fetchConnects']); - Route::post('/', [ChatsController::class, 'store']); - Route::post('/{id}', [ChatsController::class, 'sendMessage']); + Route::get('/', fn(): \App\Http\Controllers\Private\Connects => (new \App\Http\Controllers\Private\ChatsController())->fetchConnects()); + Route::post('/', fn(\Illuminate\Http\Request $request): \Illuminate\Http\Response => (new \App\Http\Controllers\Private\ChatsController())->store($request)); + Route::post('/{id}', fn(\Illuminate\Http\Request $request, $id): \App\Http\Controllers\Private\Response => (new \App\Http\Controllers\Private\ChatsController())->sendMessage($request, $id)); Route::get('/options', PeopleSystemOptions::class)->name('options'); }); }); diff --git a/routes/channels.php b/routes/channels.php index 98abb15e1..0ce82375e 100644 --- a/routes/channels.php +++ b/routes/channels.php @@ -4,6 +4,4 @@ use Illuminate\Support\Facades\Broadcast; // Broadcast::channel('user.{user}', Notification::class); -Broadcast::channel('chat', function () { - return 'user'; -}); +Broadcast::channel('chat', fn(): string => 'user'); diff --git a/routes/tenant.php b/routes/tenant.php index 52e232c5a..14087a8f9 100644 --- a/routes/tenant.php +++ b/routes/tenant.php @@ -21,7 +21,5 @@ 'web', PreventAccessFromCentralDomains::class, ])->group(function () { - Route::get('/', function () { - return 'This is your multi-tenant application. The id of the current tenant is '.tenant('id'); - }); + Route::get('/', fn(): string => 'This is your multi-tenant application. The id of the current tenant is '.tenant('id')); }); diff --git a/tests/Feature/LoginTest.php b/tests/Feature/LoginTest.php index cbec41f95..3968abcc2 100644 --- a/tests/Feature/LoginTest.php +++ b/tests/Feature/LoginTest.php @@ -19,8 +19,8 @@ class LoginTest extends TestCase private const WrongPassword = 'wrong_password'; private const SpaUrl = 'spa.test'; - private $permissionGroup = 'administration.users'; - private $testModel; + private string $permissionGroup = 'administration.users'; + private \App\Models\User $testModel; private $spaGuard; protected function setUp(): void