<?php

namespace App\Http\Controllers\Lead\API;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Controller;

class LeadController extends Controller
{
    /**
     * Get All Leads
     */
    public function leads(){
        $leads = DB::table('leads')
        ->select(['id', 'first_name as client_name','email as client_email','lead_status_id'])
        ->where('lead_status_id', '!=', 1)
        ->orderBy('id','desc')
        ->get();
        $count = count($leads);
        return response()->json([
            'count'=>$count,
            'message'=>'success',
            'status'=>'200',
            'leads'=> $leads
        ]);
    }

    // Get All Lead Status
    public function statusList(){
        $statusList = DB::table('lead_statuses')->select(['id','name'])->get();
        $count = count($statusList);
        return response()->json([
            'count'=>$count,
            'message'=>'success',
            'status'=>'200',
            'statusList'=> $statusList
        ]);
    }

    // Get All Lead Sources
    public function sourceList(){
        $sourceList = DB::table('lead_sources')->select(['id','name'])->get();
        $count = count($sourceList);
        return response()->json([
            'count'=>$count,
            'message'=>'success',
            'status'=>'200',
            'sourceList'=> $sourceList
        ]);
    }
}
