<?php

namespace App\Http\Controllers;

use App\Repositories\NotificationRepository;
use Illuminate\Http\Request;

class NotificationController extends Controller {

    public function sendNotification(Request $request) {
        try {
            $params = [
                "title" => $request->title,
                "user_id" => $request->has('user_id') ? $request->user_id : null
            ];
            $data = NotificationRepository::sendNotification($params);
        }
        catch(\Exception $e) { return response()->json(["error" => $e->getMessage()], 400); };

        return response()->json(["enviado" => $params]);
    }
}
