| 1 | <?php |
||
| 2 | |||
| 3 | namespace ag84ark\AwsSesBounceComplaintHandler\Models; |
||
| 4 | |||
| 5 | use Illuminate\Database\Eloquent\Builder; |
||
| 6 | use Illuminate\Database\Eloquent\Model; |
||
| 7 | |||
| 8 | /** |
||
| 9 | * ag84ark\AwsSesBounceComplaintHandler\Models\WrongEmail. |
||
| 10 | * |
||
| 11 | * @property int $id |
||
| 12 | * @property string $email |
||
| 13 | * @property string $problem_type |
||
| 14 | * @property string $problem_subtype |
||
| 15 | * @property int $repeated_attempts |
||
| 16 | * @property int $ignore |
||
| 17 | * @property \Illuminate\Support\Carbon|null $created_at |
||
| 18 | * @property \Illuminate\Support\Carbon|null $updated_at |
||
| 19 | * |
||
| 20 | * @method static \Illuminate\Database\Eloquent\Builder|\ag84ark\AwsSesBounceComplaintHandler\Models\WrongEmail active() |
||
| 21 | * @method static \Illuminate\Database\Eloquent\Builder|\ag84ark\AwsSesBounceComplaintHandler\Models\WrongEmail bounced() |
||
| 22 | * @method static \Illuminate\Database\Eloquent\Builder|\ag84ark\AwsSesBounceComplaintHandler\Models\WrongEmail complained() |
||
| 23 | * @method static \Illuminate\Database\Eloquent\Builder|\ag84ark\AwsSesBounceComplaintHandler\Models\WrongEmail newModelQuery() |
||
| 24 | * @method static \Illuminate\Database\Eloquent\Builder|\ag84ark\AwsSesBounceComplaintHandler\Models\WrongEmail newQuery() |
||
| 25 | * @method static \Illuminate\Database\Eloquent\Builder|\ag84ark\AwsSesBounceComplaintHandler\Models\WrongEmail query() |
||
| 26 | * @method static \Illuminate\Database\Eloquent\Builder|\ag84ark\AwsSesBounceComplaintHandler\Models\WrongEmail whereCreatedAt($value) |
||
| 27 | * @method static \Illuminate\Database\Eloquent\Builder|\ag84ark\AwsSesBounceComplaintHandler\Models\WrongEmail whereEmail($value) |
||
| 28 | * @method static \Illuminate\Database\Eloquent\Builder|\ag84ark\AwsSesBounceComplaintHandler\Models\WrongEmail whereId($value) |
||
| 29 | * @method static \Illuminate\Database\Eloquent\Builder|\ag84ark\AwsSesBounceComplaintHandler\Models\WrongEmail whereIgnore($value) |
||
| 30 | * @method static \Illuminate\Database\Eloquent\Builder|\ag84ark\AwsSesBounceComplaintHandler\Models\WrongEmail whereProblemSubtype($value) |
||
| 31 | * @method static \Illuminate\Database\Eloquent\Builder|\ag84ark\AwsSesBounceComplaintHandler\Models\WrongEmail whereProblemType($value) |
||
| 32 | * @method static \Illuminate\Database\Eloquent\Builder|\ag84ark\AwsSesBounceComplaintHandler\Models\WrongEmail whereRepeatedAttempts($value) |
||
| 33 | * @method static \Illuminate\Database\Eloquent\Builder|\ag84ark\AwsSesBounceComplaintHandler\Models\WrongEmail whereUpdatedAt($value) |
||
| 34 | * @mixin \Eloquent |
||
| 35 | */ |
||
| 36 | class WrongEmail extends Model |
||
| 37 | { |
||
| 38 | protected $table = 'wrong_emails'; |
||
| 39 | |||
| 40 | protected $fillable = ['email', 'problem_type', 'problem_subtype', 'repeated_attempts']; |
||
| 41 | |||
| 42 | 1 | public function unsubscribed(): bool |
|
| 43 | { |
||
| 44 | 1 | return 'Complaint' === $this->problem_type; |
|
| 45 | } |
||
| 46 | |||
| 47 | 1 | public function dontSend(): bool |
|
| 48 | { |
||
| 49 | 1 | return ('Bounce' === $this->problem_type && 'Permanent' === $this->problem_subtype) || 'Complaint' === $this->problem_type; |
|
| 50 | } |
||
| 51 | |||
| 52 | 2 | public function canBouncedSend(): bool |
|
| 53 | { |
||
| 54 | 2 | return 'Bounce' === $this->problem_type |
|
| 55 | 2 | && 'Permanent' !== $this->problem_subtype |
|
| 56 | 2 | && $this->updated_at->diffInMinutes(config('aws-ses-bounce-complaint-handler.block_bounced_transient_for_minutes')); |
|
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Scope a query to only include popular users. |
||
| 61 | * |
||
| 62 | * @param Builder $query |
||
| 63 | */ |
||
| 64 | 3 | public function scopeBounced($query): Builder |
|
| 65 | { |
||
| 66 | 3 | return $query->where('problem_type', '=', 'Bounce'); |
|
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * Scope a query to only include popular users. |
||
| 71 | * |
||
| 72 | * @param Builder $query |
||
| 73 | */ |
||
| 74 | 1 | public function scopeComplained($query): Builder |
|
| 75 | { |
||
| 76 | 1 | return $query->where('problem_type', '=', 'Complaint'); |
|
| 77 | } |
||
| 78 | |||
| 79 | 3 | public function scopeActive(Builder $query): Builder |
|
| 80 | { |
||
| 81 | 3 | return $query->where('ignore', '=', false); |
|
| 82 | } |
||
| 83 | } |
||
| 84 |