<?php namespace App;

/**
 * Created by PhpStorm.
 * User: sunil khorwal
 * Date: 6/6/16
 * Time: 1:52 PM
 */
class Vivriti
{

    public static $lender_id = 12;


    public static function activatedMerchants(){
        $merchantWhitelist = MerchantWhitelistLender::where('lender_id',self::$lender_id)->whereNull('deleted_at')->get(['merchant_id']);
        $merchantWhitelisted =[];
        foreach($merchantWhitelist as $white){
            $merchantWhitelisted[] = $white->merchant_id;
        }
        // return !_env('APP_CONNECTION') ? [1] : [73, 4830, 8, 6659, 6861, 6602, 6654, 5425, 83, 5408, 5453, 6167, 5098, 4182, 6110, 6583, 6948, 1338, 4693, 1286, 6657, 6451, 6873, 5668, 6440, 5861, 6661, 6816, 1731, 6777, 6034];
        return $merchantWhitelisted;
    }

    public function checkEligibility($id){
        $application = ConsumerApplication::where('id', $id)->first(['id','merchant_id']);
        return in_array($application->merchant_id, self::activatedMerchants());
    }
}
