<?php

namespace Modules\Notification\Controllers\Admin;

/** Ajax Request */

use Illuminate\View\View;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Modules\Notification\Services\ManagementNotificationService;

class AlertController extends Controller
{

    /** Redirect to this path after each operation success*/
    private $redirectSuccessPath= '/admin/alerts';
    /** View folder */
    private $viewDirectory= 'admin.alerts.';
    //
    private ManagementNotificationService $managementNotificationService;

    public function __construct(ManagementNotificationService $managementNotificationService )
    {
        $this->managementNotificationService = $managementNotificationService;
    }

    /**
     * Display a listing of the notifications.
     *
     * @param Request $request
     * @return View
     */
    public function index(Request $request) :View
    {
        $title= __('alerts.head');
        return view($this->viewDirectory.'index', get_defined_vars());
    }

    /**
     * return data of the notifications.
     *
     * @param Request $request
     * @return View
     */
    public function grid(Request $request) //:View
    {
        $request->merge(['paginate'=> true]);
        $alerts= $this->managementNotificationService->get($request);

        return view($this->viewDirectory.'grid',compact('alerts'));
    }


}
