Skip to content

Commit

Permalink
Route users show and created new user joined notification
Browse files Browse the repository at this point in the history
  • Loading branch information
Raccoon254 committed Jun 13, 2024
1 parent 1eed764 commit 694e82b
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
61 changes: 61 additions & 0 deletions app/Notifications/NewUserJoined.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

namespace App\Notifications;

use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class NewUserJoined extends Notification
{
use Queueable;
protected User $user;

/**
* Create a new notification instance.
*/
public function __construct(User $user)
{
$this->user = $user;
}

/**
* Get the notification's delivery channels.
*
* @return array<int, string>
*/
public function via(object $notifiable): array
{
return ['mail'];
}

/**
* Get the mail representation of the notification.
*/
public function toMail(object $notifiable): MailMessage
{
return (new MailMessage)
->line('A new user has joined the website.')
->line('Name: ' . $this->user->name)
->line('Email: ' . $this->user->email)
->line('Phone: ' . $this->user->phone)
->line('Location: ' . $this->user->location)
->action('View User', url(route('users.show', $this->user)))
->line('Thank you for using our application!');
}

/**
* Get the array representation of the notification.
*
* @return array<string, mixed>
*/
public function toArray(object $notifiable): array
{
return [
'name' => $this->user->name,
'email' => $this->user->email,
];
}
}
1 change: 1 addition & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

Route::get('/payments', VerifyPayments::class)->name('payments.index');
Route::get('/users', ManageUsers::class)->name('users.index');
Route::get('/users/{user}', [ManageUsers::class, 'show'])->name('users.show');

Route::get('/orders/create/new/', AutoOrderCreate::class)->name('orders.create.new');
Route::get('/payments/{paymentId}', VerifyOrderPayment::class)->name('payments.show');
Expand Down

0 comments on commit 694e82b

Please sign in to comment.