<?php

namespace App\Http\Controllers\Api\V1\Project;

use App\Api\Http\Requests\Project\PreferredProjectRequest;
use App\Api\Http\Resources\PreferredProject\PreferredProjectCollection;
use app\Api\Http\Resources\PreferredProject\PreferredProjectViewResource;
use App\Api\Http\Resources\ProjectView\ProjectViewResource;
use App\Http\Controllers\Controller;
use App\PreferredProject;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;

class PreferredProjectController extends Controller
{
    public function preferredProject(PreferredProjectRequest $request): JsonResponse
    {
        $project_type = $request->project_type;
        $preferredProjects = PreferredProject::where('project_type', $project_type)
            ->where('visibility', 'others')
            ->where('status', 1)

            ->get();
        return $this->success(
            'Preferred Projects!',
            new PreferredProjectCollection($preferredProjects)
        );
    }
    public function ExecutivePreferredProject(PreferredProjectRequest $request): JsonResponse
    {
        $project_type = $request->project_type;
        $preferredProjects = PreferredProject::where('project_type', $project_type)
            ->where('visibility', 'others')
            ->where('status', 1)
            ->where('user_side', 1)
            ->get();
        return $this->success(
            'Preferred Projects!',
            new PreferredProjectCollection($preferredProjects)
        );
    }
    // public function getProjects()
    // {
    //     $preferredProjects = PreferredProject::select('id', 'project_type', 'project_name', 'status')->where('status', 1)->get();
    //     return response()->json([
    //         'status' => true,
    //         'projects_discussed' => $preferredProjects,
    //     ]);
    // }

    public function viewProjects(Request $request)
    {
        $project_services = PreferredProject::where('project_type', $request->project_service_type_id)->get();
        return response()->json([
            'status' => true,
            'project_services' => $project_services,
        ]);
    }
}
