Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
jericdei committed Sep 11, 2024
1 parent ecbfeb8 commit b51dcd4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
20 changes: 10 additions & 10 deletions src/Commands/ConvertToDatabaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

namespace Jericdei\PsgcDatabase\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\File;
use Jericdei\PsgcDatabase\Models\Barangay;
use Jericdei\PsgcDatabase\Models\City;
use Jericdei\PsgcDatabase\Models\Municipality;
use Jericdei\PsgcDatabase\Models\Province;
use Jericdei\PsgcDatabase\Models\Region;
use Jericdei\PsgcDatabase\Models\SubMunicipality;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\File;
use Spatie\SimpleExcel\SimpleExcelReader;

use function Laravel\Prompts\confirm;
Expand Down Expand Up @@ -40,7 +40,7 @@ public function handle()
if (Region::count() !== 0) {
$confirm = confirm('PSGC database is not empty. Do you want to remove all data?');

if (!$confirm) {
if (! $confirm) {
$this->error('Action cancelled.');

return;
Expand All @@ -56,18 +56,18 @@ public function handle()
$this->info('All data has been removed.');
}

$file = storage_path("app/public/psgc/latest.xlsx");
$file = storage_path('app/public/psgc/latest.xlsx');

if (!File::exists($file)) {
if (! File::exists($file)) {
$this->info('Downloading latest PSGC file...');
$this->call('psgc:dl-latest');
}

$this->info('Reading PSGC Excel file...');

$worksheet = Cache::rememberForever(
"psgc-latest",
fn() => SimpleExcelReader::create($file)->fromSheetName('PSGC')->getRows()->toArray()
'psgc-latest',
fn () => SimpleExcelReader::create($file)->fromSheetName('PSGC')->getRows()->toArray()
);

array_shift($worksheet);
Expand Down Expand Up @@ -102,7 +102,7 @@ public function handle()
'old_name' => $row['Old names'] ? trim($row['Old names']) : null,
];

DB::transaction(fn() => match ($type) {
DB::transaction(fn () => match ($type) {
'reg' => Region::create($data),
'prov' => Province::create($data),
'mun' => Municipality::create($data),
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/DownloadPsgcLatestDataCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function handle(): int

$excel = Http::connectTimeout(999999)
->withOptions([
'progress' => fn() => $spinner->advance()
'progress' => fn () => $spinner->advance(),
])
->get($link->attr('href'))
->body();
Expand All @@ -41,7 +41,7 @@ public function handle(): int

$this->info('Storing the file...');

Storage::disk('public')->put("psgc/latest.xlsx", $excel);
Storage::disk('public')->put('psgc/latest.xlsx', $excel);

$this->info('PSGC file has been downloaded successfully!');

Expand Down
1 change: 0 additions & 1 deletion src/PsgcDatabaseServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Jericdei\PsgcDatabase\Commands\DownloadPsgcLatestDataCommand;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;
use Jericdei\PsgcDatabase\Commands\PsgcDatabaseCommand;

class PsgcDatabaseServiceProvider extends PackageServiceProvider
{
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Jericdei\PsgcDatabase\Tests;

use Illuminate\Database\Eloquent\Factories\Factory;
use Orchestra\Testbench\TestCase as Orchestra;
use Jericdei\PsgcDatabase\PsgcDatabaseServiceProvider;
use Orchestra\Testbench\TestCase as Orchestra;

class TestCase extends Orchestra
{
Expand Down

0 comments on commit b51dcd4

Please sign in to comment.