Skip to content

Commit

Permalink
Merge branch 'master' of github.com:dcblogdev/laravel-sent-emails
Browse files Browse the repository at this point in the history
  • Loading branch information
dcblogdev committed Jun 27, 2022
2 parents dd3d590 + 0fab638 commit f606650
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
8 changes: 6 additions & 2 deletions config/sentemails.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@
// emails per page
'perPage' => 10,

'noEmailsMessage' => 'No emails found.'
];
'noEmailsMessage' => 'No emails found.',

// body emails are stored as compressed strings to save db disk
/* Do not change after first mail is stored */
'compressBody' => false,
];
13 changes: 13 additions & 0 deletions src/Models/SentEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,17 @@
class SentEmail extends Model
{
protected $guarded = [];

public function getBodyAttribute($compressed) {
return config('sentemails.compressBody')
? gzinflate(base64_decode($compressed))
: $compressed;
}

public function setBodyAttribute($raw) {
$body = config('sentemails.compressBody')
? base64_encode(gzdeflate($raw, 9))
: $raw;
$this->attributes['body'] = $body;
}
}

0 comments on commit f606650

Please sign in to comment.