Skip to content

Commit

Permalink
Merge pull request #155 from loadpartner/garrett/tms-82-move-carriers…
Browse files Browse the repository at this point in the history
…-to-carrier-folder

fix for phpstan check not working with tty + carrier folder
  • Loading branch information
adrenallen authored Feb 21, 2025
2 parents 2d5eaff + 51432f3 commit 28804fd
Show file tree
Hide file tree
Showing 27 changed files with 55 additions and 46 deletions.
22 changes: 11 additions & 11 deletions _ide_helper_actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @method static dispatchSync(string $name)
* @method static dispatchNow(string $name)
* @method static dispatchAfterResponse(string $name)
* @method static \App\Models\Carrier run(string $name)
* @method static \App\Models\Carriers\Carrier run(string $name)
*/
class CreateCarrier
{
Expand All @@ -25,7 +25,7 @@ class CreateCarrier
* @method static dispatchSync(\App\Models\Carriers\CarrierSaferReport $carrierSaferReport)
* @method static dispatchNow(\App\Models\Carriers\CarrierSaferReport $carrierSaferReport)
* @method static dispatchAfterResponse(\App\Models\Carriers\CarrierSaferReport $carrierSaferReport)
* @method static \App\Models\Carrier run(\App\Models\Carriers\CarrierSaferReport $carrierSaferReport)
* @method static \App\Models\Carriers\Carrier run(\App\Models\Carriers\CarrierSaferReport $carrierSaferReport)
*/
class CreateCarrierFromSaferReport
{
Expand Down Expand Up @@ -59,15 +59,15 @@ class FmcsaNameLookup
{
}
/**
* @method static \Lorisleiva\Actions\Decorators\JobDecorator|\Lorisleiva\Actions\Decorators\UniqueJobDecorator makeJob(\App\Models\Carrier $carrier, ?string $name = null, ?string $mc_number = null, ?string $dot_number = null, ?int $physical_location_id = null, ?string $contact_email = null, ?string $contact_phone = null)
* @method static \Lorisleiva\Actions\Decorators\UniqueJobDecorator makeUniqueJob(\App\Models\Carrier $carrier, ?string $name = null, ?string $mc_number = null, ?string $dot_number = null, ?int $physical_location_id = null, ?string $contact_email = null, ?string $contact_phone = null)
* @method static \Illuminate\Foundation\Bus\PendingDispatch dispatch(\App\Models\Carrier $carrier, ?string $name = null, ?string $mc_number = null, ?string $dot_number = null, ?int $physical_location_id = null, ?string $contact_email = null, ?string $contact_phone = null)
* @method static \Illuminate\Foundation\Bus\PendingDispatch|\Illuminate\Support\Fluent dispatchIf(bool $boolean, \App\Models\Carrier $carrier, ?string $name = null, ?string $mc_number = null, ?string $dot_number = null, ?int $physical_location_id = null, ?string $contact_email = null, ?string $contact_phone = null)
* @method static \Illuminate\Foundation\Bus\PendingDispatch|\Illuminate\Support\Fluent dispatchUnless(bool $boolean, \App\Models\Carrier $carrier, ?string $name = null, ?string $mc_number = null, ?string $dot_number = null, ?int $physical_location_id = null, ?string $contact_email = null, ?string $contact_phone = null)
* @method static dispatchSync(\App\Models\Carrier $carrier, ?string $name = null, ?string $mc_number = null, ?string $dot_number = null, ?int $physical_location_id = null, ?string $contact_email = null, ?string $contact_phone = null)
* @method static dispatchNow(\App\Models\Carrier $carrier, ?string $name = null, ?string $mc_number = null, ?string $dot_number = null, ?int $physical_location_id = null, ?string $contact_email = null, ?string $contact_phone = null)
* @method static dispatchAfterResponse(\App\Models\Carrier $carrier, ?string $name = null, ?string $mc_number = null, ?string $dot_number = null, ?int $physical_location_id = null, ?string $contact_email = null, ?string $contact_phone = null)
* @method static \App\Models\Carrier run(\App\Models\Carrier $carrier, ?string $name = null, ?string $mc_number = null, ?string $dot_number = null, ?int $physical_location_id = null, ?string $contact_email = null, ?string $contact_phone = null)
* @method static \Lorisleiva\Actions\Decorators\JobDecorator|\Lorisleiva\Actions\Decorators\UniqueJobDecorator makeJob(\App\Models\Carriers\Carrier $carrier, ?string $name = null, ?string $mc_number = null, ?string $dot_number = null, ?int $physical_location_id = null, ?string $contact_email = null, ?string $contact_phone = null)
* @method static \Lorisleiva\Actions\Decorators\UniqueJobDecorator makeUniqueJob(\App\Models\Carriers\Carrier $carrier, ?string $name = null, ?string $mc_number = null, ?string $dot_number = null, ?int $physical_location_id = null, ?string $contact_email = null, ?string $contact_phone = null)
* @method static \Illuminate\Foundation\Bus\PendingDispatch dispatch(\App\Models\Carriers\Carrier $carrier, ?string $name = null, ?string $mc_number = null, ?string $dot_number = null, ?int $physical_location_id = null, ?string $contact_email = null, ?string $contact_phone = null)
* @method static \Illuminate\Foundation\Bus\PendingDispatch|\Illuminate\Support\Fluent dispatchIf(bool $boolean, \App\Models\Carriers\Carrier $carrier, ?string $name = null, ?string $mc_number = null, ?string $dot_number = null, ?int $physical_location_id = null, ?string $contact_email = null, ?string $contact_phone = null)
* @method static \Illuminate\Foundation\Bus\PendingDispatch|\Illuminate\Support\Fluent dispatchUnless(bool $boolean, \App\Models\Carriers\Carrier $carrier, ?string $name = null, ?string $mc_number = null, ?string $dot_number = null, ?int $physical_location_id = null, ?string $contact_email = null, ?string $contact_phone = null)
* @method static dispatchSync(\App\Models\Carriers\Carrier $carrier, ?string $name = null, ?string $mc_number = null, ?string $dot_number = null, ?int $physical_location_id = null, ?string $contact_email = null, ?string $contact_phone = null)
* @method static dispatchNow(\App\Models\Carriers\Carrier $carrier, ?string $name = null, ?string $mc_number = null, ?string $dot_number = null, ?int $physical_location_id = null, ?string $contact_email = null, ?string $contact_phone = null)
* @method static dispatchAfterResponse(\App\Models\Carriers\Carrier $carrier, ?string $name = null, ?string $mc_number = null, ?string $dot_number = null, ?int $physical_location_id = null, ?string $contact_email = null, ?string $contact_phone = null)
* @method static \App\Models\Carriers\Carrier run(\App\Models\Carriers\Carrier $carrier, ?string $name = null, ?string $mc_number = null, ?string $dot_number = null, ?int $physical_location_id = null, ?string $contact_email = null, ?string $contact_phone = null)
*/
class UpdateCarrierGeneral
{
Expand Down
4 changes: 2 additions & 2 deletions app/Actions/Carriers/CreateCarrier.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace App\Actions\Carriers;

use App\Http\Resources\CarrierResource;
use App\Models\Carrier;
use App\Http\Resources\Carriers\CarrierResource;
use App\Models\Carriers\Carrier;
use Lorisleiva\Actions\ActionRequest;
use Lorisleiva\Actions\Concerns\AsAction;

Expand Down
4 changes: 2 additions & 2 deletions app/Actions/Carriers/CreateCarrierFromSaferReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace App\Actions\Carriers;

use App\Http\Resources\CarrierResource;
use App\Models\Carrier;
use App\Http\Resources\Carriers\CarrierResource;
use App\Models\Carriers\Carrier;
use App\Models\Carriers\CarrierSaferReport;
use App\Models\Location;
use Lorisleiva\Actions\ActionRequest;
Expand Down
4 changes: 2 additions & 2 deletions app/Actions/Carriers/FmcsaDOTLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace App\Actions\Carriers;

use App\Http\Resources\CarrierResource;
use App\Http\Resources\Carriers\CarrierResource;
use App\Http\Resources\Carriers\CarrierSaferReportResource;
use App\Integrations\FmcsaService;
use App\Models\Carrier;
use App\Models\Carriers\Carrier;
use App\Models\Carriers\CarrierSaferReport;
use Lorisleiva\Actions\ActionRequest;
use Lorisleiva\Actions\Concerns\AsAction;
Expand Down
4 changes: 2 additions & 2 deletions app/Actions/Carriers/FmcsaNameLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace App\Actions\Carriers;

use App\Http\Resources\CarrierResource;
use App\Http\Resources\Carriers\CarrierResource;
use App\Http\Resources\Carriers\CarrierSaferReportResource;
use App\Integrations\FmcsaService;
use App\Models\Carrier;
use App\Models\Carriers\Carrier;
use App\Models\Carriers\CarrierSaferReport;
use Illuminate\Support\Collection;
use Lorisleiva\Actions\ActionRequest;
Expand Down
4 changes: 2 additions & 2 deletions app/Actions/Carriers/UpdateCarrierGeneral.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace App\Actions\Carriers;

use App\Http\Resources\CarrierResource;
use App\Models\Carrier;
use App\Http\Resources\Carriers\CarrierResource;
use App\Models\Carriers\Carrier;
use App\Rules\ValidPhoneNumber;
use Lorisleiva\Actions\ActionRequest;
use Lorisleiva\Actions\Concerns\AsAction;
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/DemoEnvironmentSetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Console\Commands;

use App\Models\Carrier;
use App\Models\Carriers\Carrier;
use App\Models\Facility;
use App\Models\Location;
use App\Models\Customers\Customer;
Expand Down
10 changes: 8 additions & 2 deletions app/Console/Commands/PreCommitChecks.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ public function handle()
return in_array(false, $this->checks) ? 1 : 0;
}

protected function runProcess(array $command, string $check, callable $successCallback, array $env = []): void
protected function runProcess(array $command, string $check, callable $successCallback, array $env = [], bool $tty = true): void
{
try {
$process = new Process($command);
$process->setTty($tty);

if ($env) {
$process->setEnv($env);
Expand All @@ -79,6 +80,12 @@ protected function runProcess(array $command, string $check, callable $successCa

$this->checks[$check] = $successCallback($output, $process);
} catch (\Exception $e) {
if (str_contains($e->getMessage(), 'TTY') && $tty === true) {
logger()->info("TTY error, running without TTY");
$this->runProcess($command, $check, $successCallback, $env, false);
return;
}

$this->error("Failed to run $check: " . $e->getMessage());
}
}
Expand All @@ -87,7 +94,6 @@ protected function runProcess(array $command, string $check, callable $successCa
protected function getSuccessCallback(string $check): callable
{
return match($check) {
'phpstan' => fn($output, $process) => str_contains($output, '[OK] No errors'),
default => fn($output, $process) => $process->isSuccessful()
};
}
Expand Down
2 changes: 1 addition & 1 deletion app/Enums/Contactable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
declare(strict_types=1);
namespace App\Enums;

use App\Models\Carrier;
use App\Models\Carriers\Carrier;
use App\Models\Customers\Customer;
use App\Models\Shipments\Shipment;

Expand Down
2 changes: 1 addition & 1 deletion app/Enums/Notable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
declare(strict_types=1);
namespace App\Enums;

use App\Models\Carrier;
use App\Models\Carriers\Carrier;
use App\Models\Customers\Customer;
use App\Models\Shipments\Shipment;

Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/CarrierController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace App\Http\Controllers;

use App\Http\Resources\CarrierResource;
use App\Models\Carrier;
use App\Http\Resources\Carriers\CarrierResource;
use App\Models\Carriers\Carrier;
use Illuminate\Http\Request;
use Inertia\Inertia;

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Shipments/ShipmentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use App\Http\Resources\ShipmentStopResource;
use App\Http\Resources\TrailerSizeResource;
use App\Http\Resources\TrailerTypeResource;
use App\Models\Carrier;
use App\Models\Carriers\Carrier;
use App\Models\Facility;
use App\Models\Shipments\TrailerSize;
use App\Models\Shipments\TrailerType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php

namespace App\Http\Resources;
namespace App\Http\Resources\Carriers;

use App\Http\Resources\LocationResource;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

/**
* @mixin \App\Models\Carrier
* @mixin \App\Models\Carriers\Carrier
*/
class CarrierResource extends JsonResource
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Resources/Carriers/CarrierSaferReportResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Http\Resources\Carriers;

use App\Http\Resources\CarrierResource;
use App\Http\Resources\Carriers\CarrierResource;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

Expand Down
1 change: 1 addition & 0 deletions app/Http/Resources/ShipmentResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Resources;

use App\Http\Resources\Carriers\CarrierResource;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

Expand Down
5 changes: 3 additions & 2 deletions app/Models/Carrier.php → app/Models/Carriers/Carrier.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

namespace App\Models;
namespace App\Models\Carriers;

use App\Http\Resources\CarrierResource;
use App\Http\Resources\Carriers\CarrierResource;
use App\Models\Location;
use App\Traits\HasOrganization;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Carriers/CarrierSaferReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Models\Carriers;

use App\Models\Carrier;
use App\Models\Carriers\Carrier;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Collection;
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Shipments/Shipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Models\Shipments;

use App\Http\Resources\ShipmentResource;
use App\Models\Carrier;
use App\Models\Carriers\Carrier;
use App\Models\Customers\Customer;
use Illuminate\Database\Eloquent\Model;
use App\Traits\HasOrganization;
Expand Down
2 changes: 1 addition & 1 deletion app/Policies/CarrierPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Policies;

use App\Models\Carrier;
use App\Models\Carriers\Carrier;
use App\Models\User;
use Illuminate\Auth\Access\Response;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Database\Factories;
namespace Database\Factories\Carriers;

use App\Models\Location;
use App\Models\Organizations\Organization;
Expand All @@ -9,7 +9,7 @@
use Illuminate\Support\Str;

/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Carrier>
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Carriers\Carrier>
*/
class CarrierFactory extends Factory
{
Expand Down
2 changes: 1 addition & 1 deletion database/factories/Shipments/ShipmentFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use App\Models\Location;
use App\Models\Organizations\Organization;
use App\Models\Carrier;
use App\Models\Carriers\Carrier;
use App\Models\Shipments\Shipment;
use App\Models\Shipments\TrailerType;
use Illuminate\Database\Eloquent\Factories\Factory;
Expand Down
2 changes: 1 addition & 1 deletion database/factories/Shipments/ShipmentStopFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use App\Enums\StopType;
use App\Models\Location;
use App\Models\Organizations\Organization;
use App\Models\Carrier;
use App\Models\Carriers\Carrier;
use App\Models\Shipments\Shipment;
use App\Models\Shipments\TrailerType;
use Illuminate\Database\Eloquent\Factories\Factory;
Expand Down
2 changes: 1 addition & 1 deletion database/seeders/DemoEnvironmentSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Database\Seeders;

use App\Models\Carrier;
use App\Models\Carriers\Carrier;
use App\Models\Facility;
use App\Models\Location;
use App\Models\Shipments\Shipment;
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/Carriers/CarrierSecurityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use App\Models\Location;
use App\Models\Organizations\Organization;
use App\Models\User;
use App\Models\Carrier;
use App\Models\Carriers\Carrier;
use Illuminate\Support\Facades\Context;
use Inertia\Testing\AssertableInertia;

Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/Shipments/ShipmentSecurityTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use App\Actions\Shipments\CreateShipment;
use App\Models\Carrier;
use App\Models\Carriers\Carrier;
use App\Models\Facility;
use App\Models\Customers\Customer;
use App\Models\Organizations\Organization;
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Actions/Carriers/CarrierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use App\Actions\Carriers\CreateCarrier;
use App\Actions\Carriers\UpdateCarrierGeneral;
use App\Models\Carrier;
use App\Models\Carriers\Carrier;
use App\Models\Location;
use Illuminate\Support\Facades\DB;

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Actions/Shipments/ShipmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use App\Actions\Shipments\UpdateShipmentGeneral;
use App\Actions\Shipments\UpdateShipmentCustomers;
use App\Actions\Shipments\UpdateShipmentCarrierDetails;
use App\Models\Carrier;
use App\Models\Carriers\Carrier;
use App\Models\Facility;
use App\Models\Customers\Customer;
use App\Models\Shipments\Shipment;
Expand Down

0 comments on commit 28804fd

Please sign in to comment.