<?php

namespace App\Classes\Modules\Milestones\ControllersLogic;


use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Milestones\Services\ListsMilestoneProgress;
use App\Http\Resources\MilestoneProgressResource;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class ListMilestoneProgressLogic extends AbstractControllerLogic
{

    /**
     * @return array
     */
    protected function notification():array {
        return [
            'title' => 'Retrieved Milestone Progress',
            'message' => 'You have successfully retrieved a list of Milestone Progress'
        ];
    }


    /** @var ListsMilestoneProgress */
    private $listsMilestoneProgress;

    /**
     * ListMilestoneProgressLogic constructor.
     * @param ListsMilestoneProgress $listsMilestoneProgress
     */
    public function __construct(ListsMilestoneProgress $listsMilestoneProgress)
    {
        $this->listsMilestoneProgress = $listsMilestoneProgress;
    }

    /**
     * @param Request $request
     * @return JsonResponse
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function logic(Request $request) : JsonResponse
    {
        $query = $this->listsMilestoneProgress->execute($this->listsMilestoneProgress->deserializeFilters($request->input('filters')));

        return $this->collectionResponse(MilestoneProgressResource::collection($query));
    }

}
