Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

ploi-deploy/roadmap

527 stars
2 code files
View ploi-deploy/roadmap on GitHub

app/Notifications/Item/ItemUpdatedNotification.php

Open in GitHub
use App\Models\Item;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
 
class ItemUpdatedNotification extends Notification implements ShouldQueue
{
use Queueable;
 
public function __construct(public Item $item)
{
}
 
public function via($notifiable)
{
return ['mail'];
}
 
public function toMail($notifiable)
{
return (new MailMessage)
->subject('Item ' . $this->item->title . ' has new updates')
->markdown('emails.item.updated', [
'user' => $notifiable,
'item' => $this->item,
'activities' => $this->item->activities()->latest()->limit(2)->get()
]);
}
}

app/Observers/ItemObserver.php

Open in GitHub
use App\Models\Item;
use App\Models\User;
use App\Notifications\Item\ItemUpdatedNotification;
 
class ItemObserver
{
//
public function updating(Item $item)
{
//
if ($isDirty) {
$users = $item->subscribedVotes()->with('user')->get()->pluck('user');
 
$users->each(function (User $user) use ($item) {
$user->notify(new ItemUpdatedNotification($item));
});
}
}
//
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.