diff --git a/app/Http/Middleware/MeasureExecutionTime.php b/app/Http/Middleware/MeasureExecutionTime.php index 2c9c5aaa..9b4b1673 100644 --- a/app/Http/Middleware/MeasureExecutionTime.php +++ b/app/Http/Middleware/MeasureExecutionTime.php @@ -25,8 +25,8 @@ class MeasureExecutionTime implements Middleware // I assume you're using valid json in your responses // Then I manipulate them below $content = json_decode($response->getContent(), true) + [ - 'execution_time' => $executionTime, - ]; + 'execution_time' => $executionTime, + ]; // Change the content of your response $response->setData($content); diff --git a/app/Models/File.php b/app/Models/File.php index 774dfb74..5887d4cb 100644 --- a/app/Models/File.php +++ b/app/Models/File.php @@ -67,7 +67,7 @@ class File extends Model * * @return string */ - public function getFilenameAttribute() :string + public function getFilenameAttribute(): string { if (!$this->pathinfo) { $this->pathinfo = pathinfo($this->path); diff --git a/app/Models/User.php b/app/Models/User.php index d306a3c8..fe10797a 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -146,7 +146,7 @@ class User extends Authenticatable } return new File([ - 'path' => $this->attributes['avatar'], + 'path' => $this->attributes['avatar'], ]); } diff --git a/app/Services/FareService.php b/app/Services/FareService.php index 00bbade7..34f28c54 100644 --- a/app/Services/FareService.php +++ b/app/Services/FareService.php @@ -34,7 +34,14 @@ class FareService extends Service $flight_fares = $this->getForFlight($flight); } + if (empty($subfleet)) { + return $flight_fares; + } + $subfleet_fares = $this->getForSubfleet($subfleet); + if (empty($subfleet_fares) || $subfleet_fares->count() === 0) { + return $flight_fares; + } // Go through all of the fares assigned by the subfleet // See if any of the same fares are assigned to the flight @@ -60,7 +67,7 @@ class FareService extends Service protected function getFares($fare) { if (filled($fare->pivot->price)) { - if (substr_count($fare->pivot->price, '%', -1)) { + if (strpos($fare->pivot->price, '%', -1) !== false) { $fare->price = Math::addPercent($fare->price, $fare->pivot->price); } else { $fare->price = $fare->pivot->price; @@ -68,7 +75,7 @@ class FareService extends Service } if (filled($fare->pivot->cost)) { - if (substr_count($fare->pivot->cost, '%', -1)) { + if (strpos($fare->pivot->cost, '%', -1) !== false) { $fare->cost = Math::addPercent($fare->cost, $fare->pivot->cost); } else { $fare->cost = $fare->pivot->cost; @@ -76,7 +83,7 @@ class FareService extends Service } if (filled($fare->pivot->capacity)) { - if (substr_count($fare->pivot->capacity, '%', -1)) { + if (strpos($fare->pivot->capacity, '%', -1) !== false) { $fare->capacity = Math::addPercent($fare->capacity, $fare->pivot->capacity); } else { $fare->capacity = $fare->pivot->capacity; diff --git a/app/Services/PirepService.php b/app/Services/PirepService.php index 0602087c..7684738b 100644 --- a/app/Services/PirepService.php +++ b/app/Services/PirepService.php @@ -269,10 +269,10 @@ class PirepService extends Service foreach ($field_values as $fv) { PirepFieldValue::updateOrCreate( ['pirep_id' => $pirep_id, - 'name' => $fv['name'], + 'name' => $fv['name'], ], - ['value' => $fv['value'], - 'source' => $fv['source'], + ['value' => $fv['value'], + 'source' => $fv['source'], ] ); } diff --git a/modules/Importer/Services/Importers/RankImport.php b/modules/Importer/Services/Importers/RankImport.php index 5c4efcc4..47e173ac 100644 --- a/modules/Importer/Services/Importers/RankImport.php +++ b/modules/Importer/Services/Importers/RankImport.php @@ -16,9 +16,9 @@ class RankImport extends BaseImporter $count = 0; foreach ($this->db->readRows($this->table, $start) as $row) { $rank = Rank::firstOrCreate(['name' => $row->rank], [ - 'image_url' => $row->rankimage, - 'hours' => $row->minhours, - ]); + 'image_url' => $row->rankimage, + 'hours' => $row->minhours, + ]); $this->idMapper->addMapping('ranks', $row->rankid, $rank->id); $this->idMapper->addMapping('ranks', $row->rank, $rank->id); diff --git a/modules/Importer/Utils/ImporterDB.php b/modules/Importer/Utils/ImporterDB.php index 769d1967..60ce6010 100644 --- a/modules/Importer/Utils/ImporterDB.php +++ b/modules/Importer/Utils/ImporterDB.php @@ -38,7 +38,7 @@ class ImporterDB 'host='.$this->creds['host'], 'port='.$this->creds['port'], 'dbname='.$this->creds['name'], - ]); + ]); Log::info('Using DSN: '.$this->dsn); diff --git a/modules/Updater/Providers/UpdateServiceProvider.php b/modules/Updater/Providers/UpdateServiceProvider.php index cc30a8bb..01306cb0 100644 --- a/modules/Updater/Providers/UpdateServiceProvider.php +++ b/modules/Updater/Providers/UpdateServiceProvider.php @@ -21,19 +21,19 @@ class UpdateServiceProvider extends ServiceProvider protected function registerRoutes() { Route::group([ - 'as' => 'update.', - 'prefix' => 'update', - 'middleware' => ['auth', 'ability:admin,admin-access', 'web'], - 'namespace' => 'Modules\Updater\Http\Controllers', - ], function () { - Route::get('/', 'UpdateController@index')->name('index'); + 'as' => 'update.', + 'prefix' => 'update', + 'middleware' => ['auth', 'ability:admin,admin-access', 'web'], + 'namespace' => 'Modules\Updater\Http\Controllers', + ], function () { + Route::get('/', 'UpdateController@index')->name('index'); - Route::get('/step1', 'UpdateController@step1')->name('step1'); - Route::post('/step1', 'UpdateController@step1')->name('step1'); + Route::get('/step1', 'UpdateController@step1')->name('step1'); + Route::post('/step1', 'UpdateController@step1')->name('step1'); - Route::post('/run-migrations', 'UpdateController@run_migrations')->name('run_migrations'); - Route::get('/complete', 'UpdateController@complete')->name('complete'); - }); + Route::post('/run-migrations', 'UpdateController@run_migrations')->name('run_migrations'); + Route::get('/complete', 'UpdateController@complete')->name('complete'); + }); } /** diff --git a/tests/FinanceTest.php b/tests/FinanceTest.php index 061a7683..ed654c5d 100644 --- a/tests/FinanceTest.php +++ b/tests/FinanceTest.php @@ -177,7 +177,7 @@ class FinanceTest extends TestCase 'capacity' => $percent_200, ]); - $ac_fares = $this->fareSvc->getForFlight($flight); + $ac_fares = $this->fareSvc->getAllFares($flight, null); $this->assertCount(1, $ac_fares); $this->assertEquals($new_price, $ac_fares[0]->price); diff --git a/tests/TestCase.php b/tests/TestCase.php index 5fbaf526..14be075c 100755 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -37,7 +37,7 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase /** * @throws Exception */ - public function setUp() : void + public function setUp(): void { parent::setUp(); @@ -52,7 +52,7 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase Artisan::call('migrate:refresh', ['--env' => 'testing']); } - public function tearDown() : void + public function tearDown(): void { parent::tearDown(); }