<?php

namespace App\Http\Controllers\Admin\Advisor;

use App\Models\Advisor;
use App\Models\Fail;
use App\Models\Success;
use App\Models\Rating;
use App\Providers\AdvisorProvider;

class AdvisorDeleteController
{
    public function __construct(public AdvisorProvider $advisorProvider)
    {
    }
    public function index($IdAdvisor)
    {
        $advisor = $this->advisorProvider->findAdvisor($IdAdvisor);
        if($advisor== null){
            return $this->advisorProvider->findAdvisorFail();
        }
        Rating::where('IdAdvisor',$IdAdvisor )->delete();
        $advisor->delete();
        return json_encode(new Success(
            true,
            "Deleted",
            (object)[
            ]
            )
        );
    }

}
