generated from IBEC-BOX/admin-kit-package-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
94 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
<?php | ||
|
||
// The label can be a translation key | ||
return [ | ||
'email_notification' => [ | ||
'enabled' => env('ADMIN_KIT_FEEDBACKS_EMAIL_NOTIFICATION_ENABLED', false), | ||
'addresses' => env('ADMIN_KIT_FEEDBACKS_EMAIL_NOTIFICATION_ADDRESSES', '[email protected]'), | ||
], | ||
|
||
'fields' => [ | ||
'name' => [ | ||
'rules' => 'required|string|max:255', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<h1>Получена новая заявка</h1> | ||
@foreach($fields as $key => $value) | ||
<p>{{ $key }}: {{ $value }}</p> | ||
@endforeach |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace AdminKit\Feedbacks\Events; | ||
|
||
use AdminKit\Feedbacks\Models\Feedback; | ||
|
||
class FeedbackSaved | ||
{ | ||
public Feedback $feedback; | ||
|
||
public function __construct(Feedback $feedback) | ||
{ | ||
$this->feedback = $feedback; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace AdminKit\Feedbacks\Listeners; | ||
|
||
use AdminKit\Feedbacks\Mail\FeedbackNotificationMail; | ||
use AdminKit\Feedbacks\Events\FeedbackSaved; | ||
use Illuminate\Support\Facades\Mail; | ||
|
||
class NotifyAboutNewFeedback | ||
{ | ||
/** | ||
* Create the event listener. | ||
*/ | ||
public function __construct() | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Handle the event. | ||
*/ | ||
public function handle(FeedbackSaved $event): void | ||
{ | ||
$fields = $event->feedback->fields; | ||
|
||
Mail::queue(new FeedbackNotificationMail($fields)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace AdminKit\Feedbacks\Mail; | ||
|
||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Mail\Mailable; | ||
use Illuminate\Queue\SerializesModels; | ||
|
||
class FeedbackNotificationMail extends Mailable | ||
{ | ||
use Queueable, SerializesModels; | ||
|
||
public function __construct(public array $fields) | ||
{ | ||
} | ||
|
||
public function build() | ||
{ | ||
$emailList = explode(',', trim(config('admin-kit-feedbacks.email_notification.addresses'))); | ||
|
||
return $this | ||
->to($emailList) | ||
->subject('Получена новая заявка с сайта') | ||
->view('admin-kit-feedbacks::mail.feedback-notification', $this->fields); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters