Edit File: FriendRequestObserver.php
<?php namespace App\Observers; use App\Models\FriendRequest; use App\Notifications\FriendRequestNotification; class FriendRequestObserver { public function created(FriendRequest $friendRequest) { $this->sendNotification( $friendRequest, 'طلب صداقه جديد', 'New friend request', 'لديك طلب صداقه جديد من ' . $friendRequest->sender->full_name, 'You have a new friend request from ' . $friendRequest->sender->full_name, 'new_friend_request', ); } public function updated(FriendRequest $friendRequest) { if ($friendRequest->wasChanged('is_accepted')) { $title_ar = 'طلب صداقه مقبول'; $title_en = 'Friend request accepted'; $body_ar = 'لقد تم قبول طلب صداقتك من قبل ' . $friendRequest->sender->full_name; $body_en = 'Your friend request with ' . $friendRequest->sender->full_name . ' has been accepted'; $type = 'accepted_friend_request'; $this->sendNotification($friendRequest, $title_ar, $title_en, $body_ar, $body_en, $type); } } protected function sendNotification(FriendRequest $friendRequest, $title_ar, $title_en, $body_ar, $body_en, $type) { $friendRequest->receiver->notify(new FriendRequestNotification($friendRequest, $title_ar, $title_en, $body_ar, $body_en, $type)); } }
Back to File Manager