<?php
namespace App\Services\Notification;

use App\Models\Notification;
use App\Models\NotificationDescription;

class NotificationService
{
    public function sendNotification($status,$user_id,$title_ar,$title_en,$desc_ar,$desc_en,$id=null,$date=null,$end_date=null)
    {
        Self::sendNotificationDB($status,$user_id,$title_ar,$title_en,$desc_ar,$desc_en,$id);
        return true;
    }

    public function sendNotificationDB($status,$user_id,$title_ar,$title_en,$desc_ar,$desc_en,$id=null)
    {
        $notification =  Notification::create([
            'target_id'=>$id,
            'status'=>$status,
            'user_id'=>$user_id,
        ]);

        $data=[
            'notification_id'=> $notification->id,
            'language_id'=> '1',
            'name'=> $title_ar,
            'description'=> $desc_ar

        ];
        NotificationDescription::create($data);

        $data=[
            'notification_id'=> $notification->id,
            'language_id'=> '2',
            'name'=> $title_en,
            'description'=> $desc_en

        ];
        NotificationDescription::create($data);

        return true;
    }
}