<?php

namespace App\Http\Controllers\ProvinceDashboard\PeopleMessages;

use App\Enums\PeopleMessageActions;
use App\Http\Controllers\Controller;
use app\Http\Traits\ApiResponse;
use App\Models\PeopleMessage;
use App\Services\Dashboard\Province\PeopleMessages\DataTableService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class OperatorController extends Controller
{
    use ApiResponse;
    /**
     * Display a listing of the resource.
     */
    public function index(Request $request, DataTableService $dataTableService): JsonResponse
    {
        return response()->json($dataTableService->index($request));
    }

    public function excel()
    {

    }

    public function handle(Request $request, PeopleMessage $peopleMessage): JsonResponse
    {
        $peopleMessage->update([
            'listen_at' => now(),
            'is_listen' => true,
            'action_id' => $request->action_id,
            'action_name' => PeopleMessageActions::name($request->action_id),
            'description' => $request->description,
            'savaneh_id' => $request->savaneh_id,
        ]);
        return $this->successResponse();
    }

    /**
     * Display the specified resource.
     */
    public function show(PeopleMessage $peopleMessage): JsonResponse
    {
        return $this->successResponse($peopleMessage);
    }
}
