<?php

declare(strict_types=1);

namespace App\Services;

use App\Models\User;
use App\Support\ApiResponse;
use Illuminate\Http\Request;

class NotificationService
{
    public function sendByRole(Request $request, $role)
    {
        $users = User::role($role)->get();
        foreach ($users as $user) {
            // $user->notify(new \App\Notifications\NewMessage($request->title, $request->desc));
        }

        return ApiResponse::success(message: count($users) . ' پیام با موفقیت ارسال شد.');
    }

    public function sendById(Request $request)
    {
        $users = User::whereIn('id', json_decode($request->ids, true))->get();
        foreach ($users as $user) {
            // $user->notify(new \App\Notifications\NewMessage($request->title, $request->desc));
        }

        return ApiResponse::success(message: 'با موفقیت ارسال شد.');
    }
}
