protected function compileExists($key, $masque)
    {
        if (!preg_match("/^exists:(.+)$/", $masque, $match)) {
            return;
        }

        $catch = end($match);
        $parts = explode(',', $catch);

        if (count($parts) == 1) {
            $exists = Database::table($parts[0])
                ->where($key, $this->inputs[$key])->exists();
        } else {
            $exists = Database::table($parts[0])
                ->where($parts[1], $this->inputs[$key])->exists();
        }

        if (!$exists) {
            $this->last_message = $this->lexique('exists', $key);
            
            $this->fails = true;
            
            $this->errors[$key][] = [
                "masque" => $masque,
                "message" => $this->last_message
            ];
        }
    }
protected function compileExists($key, $masque)
    {
        if (!preg_match("/^exists:(.+)$/", $masque, $match)) {
            return;
        }

        $catch = end($match);
        $parts = explode(',', $catch);

        if (count($parts) == 1) {
            $exists = Database::table($parts[0])
                ->where($key, $this->inputs[$key])->exists();
        } else {
            $exists = Database::table($parts[0])
                ->where($parts[1], $this->inputs[$key])->exists();
        }

        if (!$exists) {
            $this->last_message = $this->lexique('exists', $key);
            
            $this->fails = true;
            
            $this->errors[$key][] = [
                "masque" => $masque,
                "message" => $this->last_message
            ];
        }
    }
protected function compileExists ( $ key , $ masque ) { if ( ! preg_match ( "/^exists:(.+)$/" , $ masque , $ match ) ) { return ; } $ catch = end ( $ match ) ; $ parts = explode ( ',' , $ catch ) ; if ( count ( $ parts ) == 1 ) { $ exists = Database :: table ( $ parts [ 0 ] ) -> where ( $ key , $ this -> inputs [ $ key ] ) -> exists ( ) ; } else { $ exists = Database :: table ( $ parts [ 0 ] ) -> where ( $ parts [ 1 ] , $ this -> inputs [ $ key ] ) -> exists ( ) ; } if ( ! $ exists ) { $ this -> last_message = $ this -> lexique ( 'exists' , $ key ) ; $ this -> fails = true ; $ this -> errors [ $ key ] [ ] = [ "masque" => $ masque , "message" => $ this -> last_message ] ; } }
Compile Exists Rule

[exists:table,column] Check that the contents of a table field exist

@param string $key
@param string $masque

@return void
Compile Exists Rule