Neustrukturierung Customer / Lead / Booking Phase 2
This commit is contained in:
parent
313f0dbf4e
commit
6df9c401af
69 changed files with 3809 additions and 374 deletions
36
app/Exceptions/Offer/InvalidOfferStatusException.php
Normal file
36
app/Exceptions/Offer/InvalidOfferStatusException.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace App\Exceptions\Offer;
|
||||
|
||||
use App\Models\Offer;
|
||||
use DomainException;
|
||||
|
||||
/**
|
||||
* Geworfen, wenn eine Aktion den Offer in einem Status verlangt, in dem er
|
||||
* gerade nicht ist (z. B. accept auf einem Draft, convertToBooking auf nicht-accepted).
|
||||
*/
|
||||
class InvalidOfferStatusException extends DomainException
|
||||
{
|
||||
public readonly int $offerId;
|
||||
public readonly string $currentStatus;
|
||||
/** @var string[] */
|
||||
public readonly array $expectedStatuses;
|
||||
|
||||
/**
|
||||
* @param string[] $expected
|
||||
*/
|
||||
public function __construct(Offer $offer, array $expected, string $action)
|
||||
{
|
||||
$this->offerId = $offer->id;
|
||||
$this->currentStatus = $offer->status;
|
||||
$this->expectedStatuses = $expected;
|
||||
|
||||
parent::__construct(sprintf(
|
||||
'Offer #%d hat status=%s, Aktion „%s" erfordert status ∈ {%s}.',
|
||||
$offer->id,
|
||||
$offer->status,
|
||||
$action,
|
||||
implode(', ', $expected)
|
||||
));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue