<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use EF;

class GenericType extends Model
{
    public function getGenericTypeByName($name)
    {
    	return GenericType::where('name',$name)->first();
    }

    public function getGenericTypeById($id)
    {
    	return GenericType::where('id',$id)->first();
    }

    public function getGenericListById($name = [])
    {
    	return GenericType::whereIn('name',$name)->pluck('id');
    }

    public function getAllGenericList()
    {
        $generic_index = EF::getGenericTableIndex();

        $generic_id = [$generic_index['Installment'],$generic_index['Commission'],$generic_index['Booking'],$generic_index['HR Adjustment'],$generic_index['Inventory Payable']]; 
        
        return GenericType::whereIn('id',$generic_id)->get();

    }
}
