diff --git a/app/Http/Controllers/PBXController.php b/app/Http/Controllers/PBXController.php index df14424..eac0c0c 100644 --- a/app/Http/Controllers/PBXController.php +++ b/app/Http/Controllers/PBXController.php @@ -14,6 +14,7 @@ use Illuminate\Support\Facades\Session; use Illuminate\Http\Request; use App\Mail\NotifyAdmin; use App\Mail\NotifyUser; +use App\Mail\PinDisabled; use App\Models\ExpiredPin; use App\Models\PBXPin; use GuzzleHttp\RetryMiddleware; @@ -80,6 +81,12 @@ class PBXController extends Controller $pbx->pin = $pinGenerator; $pbx->save(); + + $mailData = $pbx; + + Mail::to('amirah.ali@gov.tt')->send(new NotifyUser($mailData)); + Mail::to('amirah.ali@gov.tt')->send(new NotifyAdmin($mailData)); + return redirect()->route('pbx'); } else { @@ -126,14 +133,10 @@ class PBXController extends Controller $old_pin->updated_by = $curr_user[0]['name']; $old_pin->save(); - $pin = DB::table('pbx_pin')->where('id', $id)->delete(); - $pins = DB::table('pbx_pin')->orderBy("name")->get(); - - $data = [ - 'pins' => $pins, - 'curr_user' => $curr_user[0]['name'] - ]; + + $mailData = $old_pin; + Mail::to('amirah.ali@gov.tt')->send(new PinDisabled($mailData)); return redirect()->route('pbx'); } diff --git a/app/Mail/PinDisabled.php b/app/Mail/PinDisabled.php new file mode 100644 index 0000000..818ab8a --- /dev/null +++ b/app/Mail/PinDisabled.php @@ -0,0 +1,34 @@ +mailData = $mailData; + } + + /** + * Build the message. + * + * @return $this + */ + public function build() + { + return $this->subject('Disabled PBX Pin') + ->view('Mail.disabled-pin'); + } +} diff --git a/resources/views/Mail/admin-mail.blade.php b/resources/views/Mail/admin-mail.blade.php index 32548ce..f7f9440 100644 --- a/resources/views/Mail/admin-mail.blade.php +++ b/resources/views/Mail/admin-mail.blade.php @@ -6,11 +6,11 @@

Good day Admin,


-

This email serves to notify you that a new PBX pin has been assigned. Please see below for the necssary details to be entered into the PBX system:


+

This email serves to notify you that a new PBX pin has been assigned. Please see below for the necessary details to be entered into the PBX system:


-

Owner: {{ $mailData['pin']->owner }}

-

Email: {{ $mailData['email']}}

-

PBX Pin: {{ $mailData['pin']->pin}}


+

Owner: {{ $mailData->name }}

+

Email: {{ $mailData->email}}

+

PBX Pin: {{ $mailData->pin}}


Best Wishes,

MYDNS Teams Directory Services

diff --git a/resources/views/Mail/disabled-pin.blade.php b/resources/views/Mail/disabled-pin.blade.php new file mode 100644 index 0000000..1c59167 --- /dev/null +++ b/resources/views/Mail/disabled-pin.blade.php @@ -0,0 +1,17 @@ + + + + MYDNS Automated Response + + + +

Good day Admin,


+

This email serves to notify you that a PBX pin has been disabled. Please see below for the necessary details to be removed into the PBX system:


+ +

Owner: {{ $mailData->name }}

+

Email: {{ $mailData->email}}

+

PBX Pin: {{ $mailData->pin}}


+

Best Wishes,

+

MYDNS Teams Directory Services

+ + \ No newline at end of file diff --git a/resources/views/Mail/user-mail.blade.php b/resources/views/Mail/user-mail.blade.php index c7841eb..b5b7d8a 100644 --- a/resources/views/Mail/user-mail.blade.php +++ b/resources/views/Mail/user-mail.blade.php @@ -5,11 +5,12 @@ -

Good day {{ $mailData['pin']->owner }},


-

This email serves to notify you that you have been assigned a new PBX pin:


- -

Pin: {{ $mailData['pin']->pin}}


+

Good day Admin,


+

This email serves to notify you that a PBX pin has been disabled. Please see below for the necessary details to be removed into the PBX system:


+

Owner: {{ $mailData['pin']->owner }}

+

Email: {{ $mailData['email']}}

+

PBX Pin: {{ $mailData['pin']->pin}}


Best Wishes,

MYDNS Teams Directory Services