-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #189 from loadpartner/garrett/tms-103-shipment-lif…
…ecycle-state-system Garrett/tms 103 shipment lifecycle state system
- Loading branch information
Showing
32 changed files
with
2,058 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace App\Actions\Shipments; | ||
|
||
use App\Models\Shipments\Shipment; | ||
use App\States\Shipments\Canceled; | ||
use Lorisleiva\Actions\ActionRequest; | ||
use Lorisleiva\Actions\Concerns\AsAction; | ||
|
||
class CancelShipment | ||
{ | ||
use AsAction; | ||
|
||
public function handle( | ||
Shipment $shipment, | ||
): Shipment { | ||
|
||
$shipment->state->transitionTo(Canceled::class); | ||
|
||
return $shipment; | ||
} | ||
|
||
public function asController(ActionRequest $request, Shipment $shipment) | ||
{ | ||
$this->handle( | ||
$shipment, | ||
); | ||
|
||
return redirect()->back()->with('success', 'Shipment canceled successfully'); | ||
} | ||
|
||
public function rules(): array | ||
{ | ||
return [ | ||
]; | ||
} | ||
|
||
public function authorize(ActionRequest $request): bool | ||
{ | ||
return $request->user()->can(\App\Enums\Permission::SHIPMENT_EDIT); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace App\Actions\Shipments; | ||
|
||
use App\Enums\TemperatureUnit; | ||
use App\Http\Requests\Shipments\UpdateShipmentGeneralRequest; | ||
use App\Http\Requests\Shipments\UpdateShipmentNumberRequest; | ||
use App\Models\Shipments\Shipment; | ||
use App\States\Shipments\Dispatched; | ||
use Carbon\Carbon; | ||
use Illuminate\Support\Facades\DB; | ||
use Lorisleiva\Actions\ActionRequest; | ||
use Lorisleiva\Actions\Concerns\AsAction; | ||
use Nette\NotImplementedException; | ||
|
||
class DispatchShipment | ||
{ | ||
use AsAction; | ||
|
||
public function handle( | ||
Shipment $shipment, | ||
): Shipment { | ||
|
||
$shipment->state->transitionTo(Dispatched::class); | ||
|
||
return $shipment; | ||
} | ||
|
||
public function asController(ActionRequest $request, Shipment $shipment) | ||
{ | ||
$this->handle( | ||
$shipment, | ||
); | ||
|
||
return redirect()->back()->with('success', 'Shipment dispatched successfully'); | ||
} | ||
|
||
public function rules(): array | ||
{ | ||
return [ | ||
]; | ||
} | ||
|
||
public function authorize(ActionRequest $request): bool | ||
{ | ||
return $request->user()->can(\App\Enums\Permission::SHIPMENT_EDIT); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace App\Events\Shipments; | ||
|
||
use App\Models\Shipments\Shipment; | ||
use Illuminate\Broadcasting\Channel; | ||
use Illuminate\Broadcasting\InteractsWithSockets; | ||
use Illuminate\Broadcasting\PresenceChannel; | ||
use Illuminate\Broadcasting\PrivateChannel; | ||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast; | ||
use Illuminate\Foundation\Events\Dispatchable; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
class ShipmentCarrierUpdated | ||
{ | ||
use Dispatchable, InteractsWithSockets, SerializesModels; | ||
|
||
/** | ||
* Create a new event instance. | ||
*/ | ||
public function __construct( | ||
public Shipment $shipment, | ||
) { | ||
|
||
} | ||
|
||
/** | ||
* Get the channels the event should broadcast on. | ||
* | ||
* @return array<int, \Illuminate\Broadcasting\Channel> | ||
*/ | ||
public function broadcastOn(): array | ||
{ | ||
return [ | ||
|
||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace App\Events\Shipments; | ||
|
||
use App\Models\Shipments\Shipment; | ||
use Illuminate\Broadcasting\Channel; | ||
use Illuminate\Broadcasting\InteractsWithSockets; | ||
use Illuminate\Broadcasting\PresenceChannel; | ||
use Illuminate\Broadcasting\PrivateChannel; | ||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast; | ||
use Illuminate\Foundation\Events\Dispatchable; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
class ShipmentStopsUpdated | ||
{ | ||
use Dispatchable, InteractsWithSockets, SerializesModels; | ||
|
||
/** | ||
* Create a new event instance. | ||
*/ | ||
public function __construct( | ||
public Shipment $shipment, | ||
) { | ||
|
||
} | ||
|
||
/** | ||
* Get the channels the event should broadcast on. | ||
* | ||
* @return array<int, \Illuminate\Broadcasting\Channel> | ||
*/ | ||
public function broadcastOn(): array | ||
{ | ||
return [ | ||
|
||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.