<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;

class CreditreportProvider extends BaseModel
{
    use HasFactory;

    protected $fillable = ['company_type','link'];

    public function getReportProviders()
    {
        return self::pluck('link','company_type');
    }
    public function deleteReportProvider($inputData)
    {
        $data = [];
        $provider = self:: where('company_type',$inputData['delete_source_type'])->first();
        if(!empty($provider))
        {
            $data = $provider->delete();
        }
        return $data;
    }
    public function insertReportProvider($inputData){

         return self::create($inputData);
    }
    public function updateReportProvider($inputData){
        $result = [];
        $provider = self:: where('company_type',$inputData['edit_source_type'])->first();

        if(!empty($provider)){
            $data['company_type'] = $inputData['edit_source_type'];
            $data['link'] = $inputData['edit_link'];
            $result = $provider->update($data);

        }

        return $result;
    }

}
