1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Spatie\EmailCampaigns\Exceptions; |
4
|
|
|
|
5
|
|
|
use Exception; |
6
|
|
|
use ErrorException; |
7
|
|
|
use Illuminate\Mail\Mailable; |
8
|
|
|
use Spatie\EmailCampaigns\Mails\CampaignMailable; |
9
|
|
|
use Spatie\EmailCampaigns\Mails\UsedInCampaign; |
10
|
|
|
use Spatie\EmailCampaigns\Models\Campaign; |
11
|
|
|
|
12
|
|
|
class CouldNotSendCampaign extends Exception |
13
|
|
|
{ |
14
|
|
|
public static function beingSent(Campaign $campaign): self |
15
|
|
|
{ |
16
|
|
|
return new static("The campaign with id `{$campaign->id}` can't be sent, because it is already being sent."); |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
public static function invalidMailableClass(Campaign $campaign, string $invalidMailableClass) |
20
|
|
|
{ |
21
|
|
|
$shouldExtend = CampaignMailable::class; |
22
|
|
|
|
23
|
|
|
return new static("The campaign with id `{$campaign->id}` can't be sent, because an invalid mailable class `{$invalidMailableClass}` is set. A valid mailable class must extend `{$shouldExtend}`."); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public static function alreadySent(Campaign $campaign): self |
27
|
|
|
{ |
28
|
|
|
return new static("The campaign with id `{$campaign->id}` can't be sent, because it was already sent."); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public static function noListSet(Campaign $campaign) |
32
|
|
|
{ |
33
|
|
|
return new static("The campaign with id `{$campaign->id}` can't be sent, because there is no list set to send it to."); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public static function noSubjectSet(Campaign $campaign) |
37
|
|
|
{ |
38
|
|
|
return new static("The campaign with id `{$campaign->id}` can't be sent, because no subject has been set."); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public static function noContent(Campaign $campaign): self |
42
|
|
|
{ |
43
|
|
|
return new static("The campaign with id `{$campaign->id}` can't be sent because not content has been set."); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public static function invalidContent(Campaign $campaign, ErrorException $errorException): self |
47
|
|
|
{ |
48
|
|
|
return new static("The campaign with id `{$campaign->id}` can't be sent because the content isn't valid. Please check if the html is valid. DOMDocument reported: `{$errorException->getMessage()}`", 0, $errorException); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|