Skip to content

Commit

Permalink
Upgrade to Laravel 5.7
Browse files Browse the repository at this point in the history
  • Loading branch information
rjackson committed May 28, 2024
1 parent 4f2b8c7 commit 6182115
Show file tree
Hide file tree
Showing 49 changed files with 1,105 additions and 482 deletions.
1 change: 0 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ trim_trailing_whitespace = true
trim_trailing_whitespace = false

[*.yml]
indent_style = space
indent_size = 2
13 changes: 6 additions & 7 deletions app/Console/Commands/BillMembers.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?php namespace BB\Console\Commands;

use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Illuminate\Support\FacadesLog;
use BB\Helpers\TelegramHelper;

class BillMembers extends Command
Expand Down Expand Up @@ -50,7 +49,7 @@ public function handle()
try{
//Update the payments status from pending to due
$message = "Start billing...";
\Log::info($message);
Log::info($message);
$this->telegramHelper->notify(
TelegramHelper::JOB,
$message
Expand All @@ -59,7 +58,7 @@ public function handle()
$this->info('Moving sub charges to due');
$this->subscriptionChargeService->makeChargesDue();
$message = "Moved sub charges to due";
\Log::info($message);
Log::info($message);
$this->telegramHelper->notify(
TelegramHelper::JOB,
$message
Expand All @@ -70,7 +69,7 @@ public function handle()
$this->info('Billing members');
$this->subscriptionChargeService->billMembers();
$message = "Billed members - job ran.";
\Log::info($message);
Log::info($message);
$this->telegramHelper->notify(
TelegramHelper::JOB,
$message
Expand All @@ -80,13 +79,13 @@ public function handle()

}catch(\Exception $e){
$message = "billMembers encountered an exception";
\Log::info($message);
Log::info($message);
$this->telegramHelper->notify(
TelegramHelper::ERROR,
$message
);

\Log::error($e);
Log::error($e);
}
}
}
7 changes: 4 additions & 3 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use BB\Helpers\TelegramHelper;
use Illuminate\Support\Facades\Log;

class Kernel extends ConsoleKernel
{
Expand Down Expand Up @@ -37,7 +38,7 @@ protected function schedule(Schedule $schedule)
->dailyAt('06:00')
->then(function () use ($telegram) {
$message = "✔️ Checked Memberships";
\Log::info($message);
Log::info($message);
$telegram->notify(
TelegramHelper::JOB,
$message
Expand All @@ -49,7 +50,7 @@ protected function schedule(Schedule $schedule)
->dailyAt('01:00')
->then(function () use ($telegram) {
$message = "✔️ Created today's subscription charges";
\Log::info($message);
Log::info($message);
$telegram->notify(
TelegramHelper::JOB,
$message
Expand All @@ -61,7 +62,7 @@ protected function schedule(Schedule $schedule)
->dailyAt('01:30')
->then(function () use ($telegram) {
$message = "✅ Billed members.";
\Log::info($message);
Log::info($message);
$telegram->notify(
TelegramHelper::JOB,
$message
Expand Down
14 changes: 5 additions & 9 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
namespace BB\Exceptions;

use BB\Helpers\TelegramErrorHelper;
use BB\Helpers\TelegramHelper;
use BB\Notifications\ErrorNotification;
use Exception;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use GuzzleHttp\Client as HttpClient;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Validation\ValidationException as IlluminateValidationException;
use Illuminate\Support\Facades\Log;

class Handler extends ExceptionHandler
{
Expand Down Expand Up @@ -88,13 +84,13 @@ protected function telegramException(Exception $e)

protected function notifyTelegram($level = 'error', $title = 'Exception', $suppress = false, Exception $e)
{
\Log::error($e);
Log::error($e);
try {
$helper = new TelegramErrorHelper();
$helper->notify(new ErrorNotification($level, $title, $suppress, $e));
} catch (Exception $telegramE) {
// Make sure Telegram exceptions don't stop regular exceptions being logged
\Log::error($telegramE);
Log::error($telegramE);
}
}

Expand Down Expand Up @@ -125,7 +121,7 @@ public function render($request, Exception $e)

if ($e instanceof NotImplementedException) {
\FlashNotification::error("NotImplementedException: " . $e->getMessage());
\Log::warning($e);
Log::warning($e);
return redirect()->back()->withInput();
}

Expand All @@ -134,7 +130,7 @@ public function render($request, Exception $e)
return \Response::json(['error' => $e->getMessage()], 403);
}
$userString = \Auth::guest() ? "A guest" : \Auth::user()->name;
\Log::warning($userString . " tried to access something they weren't supposed to.");
Log::warning($userString . " tried to access something they weren't supposed to.");

return \Response::view('errors.403', [], 403);
}
Expand Down
5 changes: 3 additions & 2 deletions app/Handlers/PaymentEventHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use BB\Repo\PaymentRepository;
use BB\Repo\SubscriptionChargeRepository;
use BB\Repo\UserRepository;
use Illuminate\Support\Facades\Log;

class PaymentEventHandler
{
Expand Down Expand Up @@ -125,7 +126,7 @@ public function onCancel($paymentId, $userId, $reason, $ref, $status)
{
if ($reason == 'subscription') {
if (empty($ref)) {
\Log::warning('Subscription payment failure, no sub charge id. Payment ID: ' . $paymentId);
Log::warning('Subscription payment failure, no sub charge id. Payment ID: ' . $paymentId);
return;
}
$this->subscriptionChargeRepository->paymentFailed($ref);
Expand Down Expand Up @@ -163,7 +164,7 @@ private function updateSubPayment($paymentId, $userId, $status)
$subCharge = $this->subscriptionChargeRepository->findCharge($userId);

if ( ! $subCharge) {
\Log::warning('Subscription payment without a sub charge. Payment ID:' . $paymentId);
Log::warning('Subscription payment without a sub charge. Payment ID:' . $paymentId);
return;
}

Expand Down
1 change: 0 additions & 1 deletion app/Handlers/SubChargeEventHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public function onPaymentFailure($chargeId, $userId, Carbon $paymentDate, $amoun
$user->extendMembership(null, $paidUntil);
} else {
$user->extendMembership(null, Carbon::now());
//\Log::info('Payment cancelled, expiry date rollback failed as there is no previous payment. User ID:' . $userId);
}
}

Expand Down
8 changes: 5 additions & 3 deletions app/Helpers/GoCardlessHelper.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php namespace BB\Helpers;

use Illuminate\Support\Facades\Log;

class GoCardlessHelper
{

Expand Down Expand Up @@ -103,7 +105,7 @@ public function newBill($mandateId, $amount, $name = null, $description = null)
]
]);
} catch (\Exception $e) {
\Log::error($e);
Log::error($e);

// Log these to Sentry too, to increase visibility of them.
if (app()->bound('sentry')) {
Expand All @@ -126,9 +128,9 @@ public function cancelPreAuth($preauthId)
return true;
}

\Log::error('Canceling pre auth failed: ' . json_encode($mandate));
Log::error('Canceling pre auth failed: ' . json_encode($mandate));
} catch (\Exception $e) {
\Log::error($e);
Log::error($e);
}
return false;
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/ACSController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use BB\Repo\EquipmentLogRepository;
use BB\Validators\ACSValidator;
use Exception;
use Illuminate\Support\Facades\Log;

class ACSController extends Controller
{
Expand Down Expand Up @@ -76,7 +77,7 @@ public function store()

break;
default:
\Log::debug(json_encode($data));
Log::debug(json_encode($data));
}

}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/ACSSparkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use BB\Repo\ACSNodeRepository;
use BB\Repo\PaymentRepository;
use BB\Services\KeyFobAccess;
use Illuminate\Support\Facades\Log;

class ACSSparkController extends Controller
{
Expand Down Expand Up @@ -35,7 +36,7 @@ public function handle()
try {
$keyFob = $this->keyFobAccess->lookupKeyFob($data['tag']);
} catch (\Exception $e) {
\Log::debug(json_encode($data));
Log::debug(json_encode($data));
return \Response::make('Not found', 404);
}
$user = $keyFob->user()->first();
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/AccessControlController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use BB\Entities\Activity;
use BB\Entities\KeyFob;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Response;

class AccessControlController extends Controller
Expand Down Expand Up @@ -42,7 +43,7 @@ public function mainDoor()

} catch (\BB\Exceptions\ValidationException $e) {

\Log::debug("Entry message received - failed: " . $receivedData);
Log::debug("Entry message received - failed: " . $receivedData);

//The data was invalid or the user doesnt have access
$response = \Response::make(json_encode(['valid' => '0', 'msg' => $e->getMessage()]) . PHP_EOL, 200);
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/AccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use BB\Helpers\MembershipPayments;
use BB\Mailer\UserMailer;
use BB\Validators\InductionValidator;
use Illuminate\Support\Facades\Log;

class AccountController extends Controller
{
Expand Down Expand Up @@ -230,7 +231,7 @@ public function store()

$this->profileRepo->update($user->id, ['new_profile_photo'=>1, 'profile_photo_private'=>$input['profile_photo_private']]);
} catch (\Exception $e) {
\Log::error($e);
Log::error($e);
}
}

Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/DeviceAccessControlController.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php namespace BB\Http\Controllers;

use BB\Repo\ActivityRepository;
use Illuminate\Support\Facades\Log;

class DeviceAccessControlController extends Controller
{
Expand Down Expand Up @@ -47,7 +48,7 @@ public function device()
$this->deviceSession->decodeDeviceCommand($receivedData);
$this->deviceSession->validateData();
} catch (\BB\Exceptions\ValidationException $e) {
\Log::debug($e->getMessage());
Log::debug($e->getMessage());
return \Response::make(json_encode(['valid'=>'0']), 200);
}

Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/EquipmentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use BB\Validators\EquipmentValidator;
use Illuminate\Support\Facades\Storage;
use Input;
use Log;

class EquipmentController extends Controller
{
Expand Down Expand Up @@ -315,7 +316,7 @@ public function addPhoto(Equipment $equipment)
$equipment->addPhoto($newFilename);

} catch(\Exception $e) {
\Log::error($e);
Log::error($e);
throw new ImageFailedException($e->getMessage());
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/ExpensesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use BB\Events\NewExpenseSubmitted;
use BB\Exceptions\ImageFailedException;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Response;
use Illuminate\Support\Facades\Storage;
use Input;
Expand Down Expand Up @@ -95,7 +96,7 @@ public function store()
$data['file'] = $newFilename;

} catch(\Exception $e) {
\Log::error($e);
Log::error($e);
throw new ImageFailedException($e->getMessage());
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/GoCardlessPaymentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Exception;
use GoCardlessPro\Core\Exception\InvalidStateException;
use GoCardlessPro\Core\Exception\ValidationFailedException;
use Illuminate\Support\Facades\Log;

class GoCardlessPaymentController extends Controller
{
Expand Down Expand Up @@ -113,7 +114,7 @@ private function handleBill($amount, $reason, $user, $ref, $returnPath)
return \Redirect::to($returnPath);
} catch (Exception $e) {
// Genuine app exception... needs investigation
\Log::info($e);
Log::info($e);

$status = 'error';
$this->paymentRepository->recordPayment($reason, $user->id, 'gocardless-variable', null, $amount, $status, 0, $ref);
Expand Down
Loading

0 comments on commit 6182115

Please sign in to comment.