diff --git a/app/Http/Controllers/Admin/PhotoCommentController.php b/app/Http/Controllers/Admin/PhotoCommentController.php index ce41bed..efa1add 100644 --- a/app/Http/Controllers/Admin/PhotoCommentController.php +++ b/app/Http/Controllers/Admin/PhotoCommentController.php @@ -6,14 +6,13 @@ use App\Album; use App\Facade\Theme; use App\Facade\UserConfig; use App\Http\Controllers\Controller; -use App\Mail\PhotoCommentApproved; -use App\Mail\PhotoCommentApprovedUser; -use App\Mail\PhotoCommentRepliedTo; +use App\Notifications\PhotoCommentApproved; +use App\Notifications\PhotoCommentApprovedUser; +use App\Notifications\PhotoCommentRepliedTo; use App\Photo; use App\PhotoComment; use App\User; use Illuminate\Http\Request; -use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\View; class PhotoCommentController extends Controller @@ -344,16 +343,17 @@ class PhotoCommentController extends Controller */ private function notifyAlbumOwnerAndPoster(Album $album, Photo $photo, PhotoComment $comment) { + /** @var User $owner */ $owner = $album->user; - Mail::to($owner)->send(new PhotoCommentApproved($owner, $album, $photo, $comment)); + $owner->notify(new PhotoCommentApproved($album, $photo, $comment)); // Also send a notification to the comment poster $poster = new User(); $poster->name = $comment->authorDisplayName(); $poster->email = $comment->authorEmail(); - Mail::to($poster)->send(new PhotoCommentApprovedUser($poster, $album, $photo, $comment)); + $poster->notify(new PhotoCommentApprovedUser($album, $photo, $comment)); // Send notification to the parent comment owner (if this is a reply) if (!is_null($comment->parent_comment_id)) @@ -369,7 +369,7 @@ class PhotoCommentController extends Controller $parentPoster->name = $parentComment->authorDisplayName(); $parentPoster->email = $parentComment->authorEmail(); - Mail::to($parentPoster)->send(new PhotoCommentRepliedTo($parentPoster, $album, $photo, $comment)); + $parentPoster->notify(new PhotoCommentRepliedTo($album, $photo, $comment)); } } } \ No newline at end of file diff --git a/app/Http/Controllers/Gallery/PhotoCommentController.php b/app/Http/Controllers/Gallery/PhotoCommentController.php index ac165ed..2a46553 100644 --- a/app/Http/Controllers/Gallery/PhotoCommentController.php +++ b/app/Http/Controllers/Gallery/PhotoCommentController.php @@ -8,21 +8,16 @@ use App\Facade\UserConfig; use App\Helpers\DbHelper; use App\Helpers\PermissionsHelper; use App\Http\Controllers\Controller; -use App\Http\Requests\StorePhotoCommentRequest; -use App\Mail\ModeratePhotoComment; -use App\Mail\PhotoCommentApproved; -use App\Mail\PhotoCommentApprovedUser; -use App\Mail\PhotoCommentRepliedTo; -use App\Permission; +use App\Notifications\ModeratePhotoComment; +use App\Notifications\PhotoCommentApproved; +use App\Notifications\PhotoCommentApprovedUser; +use App\Notifications\PhotoCommentRepliedTo; use App\Photo; use App\PhotoComment; use App\User; use App\UserActivity; use Illuminate\Http\Request; use Illuminate\Support\Facades\App; -use Illuminate\Support\Facades\Auth; -use Illuminate\Support\Facades\Gate; -use Illuminate\Support\Facades\Mail; use Illuminate\Validation\ValidationException; class PhotoCommentController extends Controller @@ -315,7 +310,7 @@ class PhotoCommentController extends Controller /** @var User $moderator */ foreach ($moderators as $moderator) { - Mail::to($moderator)->send(new ModeratePhotoComment($moderator, $album, $photo, $comment)); + $moderator->notify(new ModeratePhotoComment($album, $photo, $comment)); } } @@ -327,16 +322,17 @@ class PhotoCommentController extends Controller */ private function notifyAlbumOwnerAndPoster(Album $album, Photo $photo, PhotoComment $comment) { + /** @var User $owner */ $owner = $album->user; - Mail::to($owner)->send(new PhotoCommentApproved($owner, $album, $photo, $comment)); + $owner->notify(new PhotoCommentApproved($album, $photo, $comment)); // Also send a notification to the comment poster $poster = new User(); $poster->name = $comment->authorDisplayName(); $poster->email = $comment->authorEmail(); - Mail::to($poster)->send(new PhotoCommentApprovedUser($poster, $album, $photo, $comment)); + $poster->notify(new PhotoCommentApprovedUser($album, $photo, $comment)); // Send notification to the parent comment owner (if this is a reply) if (!is_null($comment->parent_comment_id)) @@ -352,7 +348,7 @@ class PhotoCommentController extends Controller $parentPoster->name = $parentComment->authorDisplayName(); $parentPoster->email = $parentComment->authorEmail(); - Mail::to($parentPoster)->send(new PhotoCommentRepliedTo($parentPoster, $album, $photo, $comment)); + $parentPoster->notify(new PhotoCommentRepliedTo($album, $photo, $comment)); } } diff --git a/app/Mail/ModeratePhotoComment.php b/app/Mail/ModeratePhotoComment.php index db6db37..7e98c8e 100644 --- a/app/Mail/ModeratePhotoComment.php +++ b/app/Mail/ModeratePhotoComment.php @@ -8,10 +8,9 @@ use App\Photo; use App\PhotoComment; use App\User; use Illuminate\Bus\Queueable; -use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; -class ModeratePhotoComment extends Mailable +class ModeratePhotoComment extends MailableBase { use Queueable, SerializesModels; diff --git a/app/Mail/PhotoCommentApproved.php b/app/Mail/PhotoCommentApproved.php index fb3a326..834a21d 100644 --- a/app/Mail/PhotoCommentApproved.php +++ b/app/Mail/PhotoCommentApproved.php @@ -8,14 +8,13 @@ use App\Photo; use App\PhotoComment; use App\User; use Illuminate\Bus\Queueable; -use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; /** * E-mail notification to the owner of an album that is sent when a new comment has been approved in their album. * @package App\Mail */ -class PhotoCommentApproved extends Mailable +class PhotoCommentApproved extends MailableBase { use Queueable, SerializesModels; diff --git a/app/Mail/PhotoCommentApprovedUser.php b/app/Mail/PhotoCommentApprovedUser.php index c791a6f..7fa2f16 100644 --- a/app/Mail/PhotoCommentApprovedUser.php +++ b/app/Mail/PhotoCommentApprovedUser.php @@ -8,14 +8,13 @@ use App\Photo; use App\PhotoComment; use App\User; use Illuminate\Bus\Queueable; -use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; /** * E-mail notification to the poster of a comment that is sent when it has been approved. * @package App\Mail */ -class PhotoCommentApprovedUser extends Mailable +class PhotoCommentApprovedUser extends MailableBase { use Queueable, SerializesModels; diff --git a/app/Notifications/ModeratePhotoComment.php b/app/Notifications/ModeratePhotoComment.php new file mode 100644 index 0000000..8907ceb --- /dev/null +++ b/app/Notifications/ModeratePhotoComment.php @@ -0,0 +1,48 @@ +album = $album; + $this->photo = $photo; + $this->comment = $comment; + } + + /** + * Get the mail representation of the notification. + * + * @param mixed $notifiable + * @return \Illuminate\Notifications\Messages\MailMessage|MailableBase + */ + public function toMail($notifiable) + { + $mailable = new ModeratePhotoCommentMailable($notifiable, $this->album, $this->photo, $this->comment); + + $this->setPropertiesOnMailable($mailable, $notifiable); + + return $mailable; + } +} diff --git a/app/Notifications/PhotoCommentApproved.php b/app/Notifications/PhotoCommentApproved.php new file mode 100644 index 0000000..841200a --- /dev/null +++ b/app/Notifications/PhotoCommentApproved.php @@ -0,0 +1,48 @@ +album = $album; + $this->photo = $photo; + $this->comment = $comment; + } + + /** + * Get the mail representation of the notification. + * + * @param mixed $notifiable + * @return \Illuminate\Notifications\Messages\MailMessage|MailableBase + */ + public function toMail($notifiable) + { + $mailable = new PhotoCommentApprovedMailable($notifiable, $this->album, $this->photo, $this->comment); + + $this->setPropertiesOnMailable($mailable, $notifiable); + + return $mailable; + } +} diff --git a/app/Notifications/PhotoCommentApprovedUser.php b/app/Notifications/PhotoCommentApprovedUser.php new file mode 100644 index 0000000..b60de7f --- /dev/null +++ b/app/Notifications/PhotoCommentApprovedUser.php @@ -0,0 +1,48 @@ +album = $album; + $this->photo = $photo; + $this->comment = $comment; + } + + /** + * Get the mail representation of the notification. + * + * @param mixed $notifiable + * @return \Illuminate\Notifications\Messages\MailMessage|MailableBase + */ + public function toMail($notifiable) + { + $mailable = new PhotoCommentApprovedUserMailable($notifiable, $this->album, $this->photo, $this->comment); + + $this->setPropertiesOnMailable($mailable, $notifiable); + + return $mailable; + } +} diff --git a/app/Notifications/PhotoCommentRepliedTo.php b/app/Notifications/PhotoCommentRepliedTo.php new file mode 100644 index 0000000..adf2b73 --- /dev/null +++ b/app/Notifications/PhotoCommentRepliedTo.php @@ -0,0 +1,48 @@ +album = $album; + $this->photo = $photo; + $this->comment = $comment; + } + + /** + * Get the mail representation of the notification. + * + * @param mixed $notifiable + * @return \Illuminate\Notifications\Messages\MailMessage|MailableBase + */ + public function toMail($notifiable) + { + $mailable = new PhotoCommentRepliedToMailable($notifiable, $this->album, $this->photo, $this->comment); + + $this->setPropertiesOnMailable($mailable, $notifiable); + + return $mailable; + } +}