src/Helper.php
public static function getIdFor($object, $type)
    {
        if (is_null($object)) {
            return null;
        } elseif (is_object($object)) {
            return $object->getKey();
        } elseif (is_array($object)) {
            return $object['id'];
        } elseif (is_numeric($object)) {
            return $object;
        } elseif (is_string($object)) {
            return call_user_func_array([
                Config::get("laratrust.models.{$type}"), 'where'
            ], ['name', $object])->firstOrFail()->getKey();
        }

        throw new InvalidArgumentException(
            'getIdFor function only accepts an integer, a Model object or an array with an "id" key'
        );
    }
public static function getIdFor($object, $type)
    {
        if (is_null($object)) {
            return null;
        } elseif (is_object($object)) {
            return $object->getKey();
        } elseif (is_array($object)) {
            return $object['id'];
        } elseif (is_numeric($object)) {
            return $object;
        } elseif (is_string($object)) {
            return call_user_func_array([
                Config::get("laratrust.models.{$type}"), 'where'
            ], ['name', $object])->firstOrFail()->getKey();
        }

        throw new InvalidArgumentException(
            'getIdFor function only accepts an integer, a Model object or an array with an "id" key'
        );
    }
public static function getIdFor ( $ object , $ type ) { if ( is_null ( $ object ) ) { return null ; } elseif ( is_object ( $ object ) ) { return $ object -> getKey ( ) ; } elseif ( is_array ( $ object ) ) { return $ object [ 'id' ] ; } elseif ( is_numeric ( $ object ) ) { return $ object ; } elseif ( is_string ( $ object ) ) { return call_user_func_array ( [ Config :: get ( "laratrust.models.{$type}" ) , 'where' ] , [ 'name' , $ object ] ) -> firstOrFail ( ) -> getKey ( ) ; } throw new InvalidArgumentException ( 'getIdFor function only accepts an integer, a Model object or an array with an "id" key' ) ; }
Gets the it from an array, object or integer.

@param  mixed  $object
@param  string  $type
@return int
Gets the it from an array object or integer .