public function from($input, $key, $rule, $lang)
    {
        $lang = $this->custom('from', $lang);
        $db = new Database();
        $cap = $db->getCapsule();

        $exp = explode(':', $rule);
        $table = $cap->table($exp[1]);

        if ($table->where($exp[2], '=', $input[$key])->count() == 0) {
            $tn = $exp[1];

            return preg_replace_callback('/(:field)(.*)(\:from)/i',
            function ($m) use ($input, $key, $tn) {
                return $input[$key].$m[2].$tn;
            }, $lang);
        }
    }
public function from($input, $key, $rule, $lang)
    {
        $lang = $this->custom('from', $lang);
        $db = new Database();
        $cap = $db->getCapsule();

        $exp = explode(':', $rule);
        $table = $cap->table($exp[1]);

        if ($table->where($exp[2], '=', $input[$key])->count() == 0) {
            $tn = $exp[1];

            return preg_replace_callback('/(:field)(.*)(\:from)/i',
            function ($m) use ($input, $key, $tn) {
                return $input[$key].$m[2].$tn;
            }, $lang);
        }
    }
public function from ( $ input , $ key , $ rule , $ lang ) { $ lang = $ this -> custom ( 'from' , $ lang ) ; $ db = new Database ( ) ; $ cap = $ db -> getCapsule ( ) ; $ exp = explode ( ':' , $ rule ) ; $ table = $ cap -> table ( $ exp [ 1 ] ) ; if ( $ table -> where ( $ exp [ 2 ] , '=' , $ input [ $ key ] ) -> count ( ) == 0 ) { $ tn = $ exp [ 1 ] ; return preg_replace_callback ( '/(:field)(.*)(\:from)/i' , function ( $ m ) use ( $ input , $ key , $ tn ) { return $ input [ $ key ] . $ m [ 2 ] . $ tn ; } , $ lang ) ; } }
Checks if a given field exists in given database table.

@param $input - Language string
@param string $key  - Validation Key
@param array  $rule - The entire rule (Needed for multi-parsing)
@param string $lang - Language string

@return mixed
Checks if a given field exists in given database table .