Skip to main content

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

Read more here

pinkary-project/pinkary.com

1505 stars
2 code files
View pinkary-project/pinkary.com on GitHub

app/Notifications/QuestionAnswered.php

Open in GitHub
use App\Models\Question;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
 
final class QuestionAnswered extends Notification
{
use Queueable;
 
public function __construct(private Question $question) {}
 
public function via(object $notifiable): array
{
return ['database'];
}
 
public function toDatabase(object $notifiable): array
{
return [
'question_id' => $this->question->id,
];
}
}

app/Observers/QuestionObserver.php

Open in GitHub
use App\Models\Question;
use App\Notifications\QuestionCreated;
use App\Notifications\UserMentioned;
 
final readonly class QuestionObserver
{
// ...
 
public function updated(Question $question): void
{
// ...
 
$question->from->notify(new QuestionAnswered($question));
$question->mentions()->each->notify(new UserMentioned($question));
}
 
// ...
}

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.