Skip to content
This repository was archived by the owner on Feb 4, 2024. It is now read-only.

Commit 17236af

Browse files
Merge pull request #2378 from laravel-liberu/analysis-54Dajx
Apply fixes from StyleCI
2 parents 88e7d2f + c3be889 commit 17236af

21 files changed

+117
-123
lines changed

app/Events/ServerCreated.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ public function __construct(
2323
* The user that created the server.
2424
*/
2525
public $message
26-
)
27-
{
26+
) {
2827
}
2928

3029
/**

app/Http/Controllers/Auth/LoginController.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function redirectToProvider($provider)
6060
/**
6161
* Obtain the user information from Provider.
6262
*
63-
* @param $provider
63+
* @param $provider
6464
* @return JsonResponse
6565
*/
6666
public function handleProviderCallback($provider)
@@ -264,7 +264,7 @@ protected function validateLogin(Request $request)
264264
}
265265

266266
/**
267-
* @param $provider
267+
* @param $provider
268268
* @return JsonResponse
269269
*/
270270
protected function validateProvider($provider)
@@ -344,17 +344,16 @@ private function loggableUser(Request $request)
344344
if ($main_company !== null && ! $user->isAdmin()) {
345345
$c_id = $main_company->id;
346346
}
347-
if(! $user->isAdmin()){
348-
349-
$tenants = Tenant::find($main_company->id);
350-
}
351-
if ($user->isAdmin()) {
352-
$tenants = null;
353-
}
347+
if (! $user->isAdmin()) {
348+
$tenants = Tenant::find($main_company->id);
349+
}
350+
if ($user->isAdmin()) {
351+
$tenants = null;
352+
}
354353
if ($main_company === null && ! $user->isAdmin()) {
355354
// if (($main_company == null||$tenants=='') && ! $user->isAdmin()) {
356355
// if ($main_company == null) {
357-
$this->create_company($user);
356+
$this->create_company($user);
358357
} else {
359358
if ($tenants && ! $user->isAdmin()) {
360359
// $c = DB::connection('tenantdb',$tenants->tenancy_db_name)->table('users')->count();

app/Http/Controllers/Auth/RegisterController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ protected function create(Request $request)
140140
}
141141

142142
/** protected function getSubscriptionPlan(Request $request)
143-
{
144-
return (new GetPlans())($request);
145-
}
146-
**/
143+
* {
144+
* return (new GetPlans())($request);
145+
* }.
146+
**/
147147
}

app/Http/Controllers/Dna/Store.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ public function __invoke(Request $request)
2020
$user_id = \Auth::user()->id;
2121
$dna = Dna::where('user_id', '=', $user_id)->count();
2222
if (in_array($role, [1, 2, 9, 10])) {
23-
$allowed = TRUE;
23+
$allowed = true;
2424
}
2525
if (in_array($role, [4, 5, 6]) && $dna < 1) {
26-
$allowed = TRUE;
26+
$allowed = true;
2727
}
2828

2929
if (in_array($role, [7, 8]) && $dna < 5) {
30-
$allowed = TRUE;
30+
$allowed = true;
3131
}
32-
if ($allowed === TRUE) {
32+
if ($allowed === true) {
3333
if ($request->hasFile('file')) {
3434
if ($request->file('file')->isValid()) {
3535
try {

app/Http/Controllers/Gedcom/Export.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44

55
use App\Http\Controllers\Controller;
66
use App\Jobs\ExportGedCom;
7-
use FamilyTree365\LaravelGedcom\Utils\GedcomGenerator;
8-
use Illuminate\Http\Request;
9-
use App\Models\Person;
10-
use Illuminate\Support\Facades\Log;
117
use App\Models\Family;
8+
use App\Models\Person;
129
use App\Tenant\Manager;
10+
use FamilyTree365\LaravelGedcom\Utils\GedcomGenerator;
11+
use Illuminate\Http\Request;
1312
use Illuminate\Support\Facades\File;
13+
use Illuminate\Support\Facades\Log;
14+
1415
class Export extends Controller
1516
{
1617
public function __invoke(Request $request)
@@ -19,15 +20,15 @@ public function __invoke(Request $request)
1920
$file = env('APP_NAME').date('_Ymd_').$ts.'.ged';
2021
$file = str_replace(' ', '', $file);
2122
$file = str_replace("'", '', $file);
22-
$filePath = 'public/' . $file;
23+
$filePath = 'public/'.$file;
2324
$manager = Manager::fromModel($request->user()->company(), $request->user());
2425
ExportGedCom::dispatchSync($filePath, $request->user());
2526

26-
$filePath = $manager->storage()->path($filePath);
27-
Log::info("Read gedfile from ". $manager->storage()->path($filePath));
27+
$filePath = $manager->storage()->path($filePath);
28+
Log::info('Read gedfile from '.$manager->storage()->path($filePath));
2829
// var_dump($filePath);
2930
return json_encode([
30-
// 'file' => $manager->storage()->path($filePath) ,
31+
// 'file' => $manager->storage()->path($filePath) ,
3132
'file' => file_get_contents($filePath, true),
3233
'name' => $file,
3334
], JSON_THROW_ON_ERROR);

app/Http/Controllers/Person/PeopleController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function searchPerson(Request $request)
4343

4444
return response()->json([
4545
'response' => [
46-
'docs' => $people->map(fn($person) => [
46+
'docs' => $people->map(fn ($person) => [
4747
'id' => $person->id,
4848
'name' => $person->name,
4949
'user_name' => $person->systemPerson?->name,

app/Http/Controllers/Stripe/GetCurrentSubscription.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function __invoke(Request $request)
1919
$data['has_payment_method'] = $user->hasDefaultPaymentMethod();
2020
if ($user->subscribed('default')) {
2121
$subscription = $user->subscription();
22-
22+
2323
$data['subscribed'] = $subscription->stripe_status != 'canceled' ? true : false;
2424

2525
$data['plan_id'] = $subscription->stripe_price;
@@ -37,22 +37,20 @@ public function __invoke(Request $request)
3737
try {
3838
$coupon = $stripeSub->discount->coupon;
3939
// check the type of coupon - it can be 'fixed_amount' or 'percent_off'
40-
if($coupon->amount_off) {
40+
if ($coupon->amount_off) {
4141
$discountAmount = $coupon->amount_off;
4242
$finalPrice = $price - $discountAmount;
43-
} else if($coupon->percent_off) {
44-
$discountAmount = ($price * $coupon->percent_off/100);
43+
} elseif ($coupon->percent_off) {
44+
$discountAmount = ($price * $coupon->percent_off / 100);
4545
$finalPrice = $price - $discountAmount;
4646
}
4747
} catch (\Exception $e) {
48-
4948
}
5049

5150
$data['final_price'] = $finalPrice;
5251
$data['discount_amount'] = $discountAmount;
5352
} catch (Exception $e) {
5453
}
55-
5654
} else {
5755
$data['subscribed'] = false;
5856
}

app/Http/Controllers/Stripe/GetPlans.php

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,66 +17,65 @@ class GetPlans extends Controller
1717
public function __invoke(Request $request)
1818
{
1919
// $role = Role::where("name", "free")->first();
20-
Stripe\Stripe::setApiKey(\Config::get("services.stripe.secret"));
20+
Stripe\Stripe::setApiKey(\Config::get('services.stripe.secret'));
2121

2222
$plans = Stripe\Plan::all();
2323

2424
$result = [];
2525
foreach ($plans as $k => $plan) {
26-
if (!$plan->active || $plan->amount == 0) {
26+
if (! $plan->active || $plan->amount == 0) {
2727
continue;
2828
}
2929

3030
/*
3131
* FREE PLAN
3232
*/
3333

34-
/**
35-
if ($k === 0) {
36-
$row1 = [];
37-
$row1["id"] = $role->id;
38-
$row1["amount"] = 0;
39-
$row1["nickname"] = $role->name;
40-
$row1["title"] = $role->display_name;
41-
$row1["subscribed"] = false;
42-
$result[] = $row1;
43-
}
44-
**/
34+
/**
35+
* if ($k === 0) {
36+
* $row1 = [];
37+
* $row1["id"] = $role->id;
38+
* $row1["amount"] = 0;
39+
* $row1["nickname"] = $role->name;
40+
* $row1["title"] = $role->display_name;
41+
* $row1["subscribed"] = false;
42+
* $result[] = $row1;
43+
* }.
44+
**/
4545
if (empty($plan->nickname)) {
4646
continue;
4747
}
4848
$row = [];
4949

50-
$row["id"] = $plan->id;
51-
$row["amount"] = $plan->amount;
52-
$row["title"] = $plan->nickname;
53-
$row["nickname"] = $plan->title;
54-
$row["interval"] = $plan->interval;
55-
$row["trial_end"] = null;
50+
$row['id'] = $plan->id;
51+
$row['amount'] = $plan->amount;
52+
$row['title'] = $plan->nickname;
53+
$row['nickname'] = $plan->title;
54+
$row['interval'] = $plan->interval;
55+
$row['trial_end'] = null;
5656

57-
$row["features"] = [];
58-
$row["features_missing"] = [];
59-
$row["metadata"] = [
60-
"featured" => false,
61-
"description" => "Missing description!!!",
57+
$row['features'] = [];
58+
$row['features_missing'] = [];
59+
$row['metadata'] = [
60+
'featured' => false,
61+
'description' => 'Missing description!!!',
6262
];
6363

6464
foreach ($plan->metadata->toArray() as $key => $value) {
6565
if (preg_match('/^feature-missing[0-9]*$/', $key)) {
66-
$row["features_missing"][] = $value;
66+
$row['features_missing'][] = $value;
6767
}
6868
if (preg_match('/^feature[0-9]*$/', $key)) {
69-
$row["features"][] = $value;
69+
$row['features'][] = $value;
7070
}
71-
if ($key == "featured" && ($value == 1 || $value == "true")) {
72-
$row["metadata"]["featured"] = true;
71+
if ($key == 'featured' && ($value == 1 || $value == 'true')) {
72+
$row['metadata']['featured'] = true;
7373
}
7474
}
75-
$row["subscribed"] = false;
75+
$row['subscribed'] = false;
7676
$result[] = $row;
7777
}
7878

7979
return $result;
8080
}
8181
}
82-

app/Http/Controllers/Stripe/VerifyCoupon.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function __invoke(Request $request)
1919
$user = auth()->user();
2020

2121
try {
22-
$user->createAsStripeCustomer();
22+
$user->createAsStripeCustomer();
2323
} catch(\Exception $e) {
2424
}
2525

@@ -32,14 +32,14 @@ public function __invoke(Request $request)
3232
if (strtolower($coupon->name) == strtolower($couponCode) && $coupon->valid) {
3333
return [
3434
'success' => true,
35-
'coupon' => $coupon
35+
'coupon' => $coupon,
3636
];
3737
}
38-
};
39-
38+
}
4039
} catch (\Stripe\Exception\InvalidRequestException $e) {
4140
return ['success' => false, 'message' => 'There was an error when checking your coupon.'];
4241
}
42+
4343
return ['success' => false, 'message' => 'Coupon code is not valid'];
4444
}
4545
}

app/Http/Controllers/Stripe/Webhook.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<?php
22

33
namespace App\Http\Controllers\Stripe;
4-
use LaravelEnso\Roles\Models\Role;
4+
55
use App\Http\Controllers\Controller;
66
use App\Models\User;
77
use Illuminate\Http\Request;
8-
use Stripe;
98
use Illuminate\Support\Facades\Log;
9+
use LaravelEnso\Roles\Models\Role;
10+
use Stripe;
1011

1112
class Webhook extends Controller
1213
{
@@ -23,42 +24,42 @@ public function __invoke(Request $request)
2324

2425
if ($data) {
2526
switch ($data['type']) {
26-
case "customer.subscription.deleted":
27+
case 'customer.subscription.deleted':
2728
$user = User::where('stripe_id', $data['data']['object']['customer'])->first();
2829
if ($user) {
2930
$user->role_id = 4;
3031
$user->save();
3132
}
3233
break;
33-
34-
case "customer.subscription.created":
35-
case "customer.subscription.updated":
34+
35+
case 'customer.subscription.created':
36+
case 'customer.subscription.updated':
3637
$user = User::where('stripe_id', $data['data']['object']['customer'])->first();
3738
if ($user) {
3839
$plan_nickname = $data['data']['object']['plan']['nickname'];
39-
$roles= Role::where('name', strtolower($plan_nickname))->first();
40+
$roles = Role::where('name', strtolower($plan_nickname))->first();
4041
if ($roles) {
4142
$user->role_id = $roles->id;
4243
$user->save();
4344
}
4445
}
4546
break;
46-
47-
case "invoice.payment_succeeded":
47+
48+
case 'invoice.payment_succeeded':
4849
$user = User::where('stripe_id', $data['data']['object']['customer'])->first();
4950
if ($user) {
5051
$plan_nickname = $data['data']['object']['lines']['data'][0]['plan']['nickname'];
51-
$roles= Role::where('name', strtolower($plan_nickname))->first();
52+
$roles = Role::where('name', strtolower($plan_nickname))->first();
5253
if ($roles) {
5354
$user->role_id = $roles->id;
5455
$user->save();
5556
}
5657
}
5758
break;
58-
case "invoice.payment_failed" :
59+
case 'invoice.payment_failed':
5960
$user = User::where('stripe_id', $data['data']['object']['customer'])->first();
6061
if ($user) {
61-
$roles= Role::where('name', strtolower("free"))->first();
62+
$roles = Role::where('name', strtolower('free'))->first();
6263
if ($roles) {
6364
$user->role_id = $roles->id;
6465
$user->save();

0 commit comments

Comments
 (0)