public function configure(array $modelConfigurations) {
        if (empty($modelConfigurations)) {
            throw new \LogicException('Supply at least one model or model configuration!');
        }

        /* First define the models and their columns. */
        foreach ($modelConfigurations as $className) {

            $modelClass = $className;

            if (is_subclass_of($className, 'Illuminate\Database\Eloquent\Model')) {
                $config = new ModelConfig();
                $config->setModelClass($modelClass);
            }
            else if (is_subclass_of($className, 'Label305\AujaLaravel\Config\ModelConfig')) {
                $config = new $className();
                $modelClass = $config->getModelClass();
            }
            else {
                throw new \InvalidArgumentException(
                    "Model configuration should be class name string of either a ModelConfig or Eloquent subclass."
                );
            }

            $model = new Model($modelClass);
            $this->models[$modelClass] = $model;
            $this->relations[$modelClass] = [];

            $configResolver = new ConfigResolver($config, $model);
            $this->configs[$modelClass] = $configResolver->resolve();
            $this->findColumns($this->models[$modelClass]);
            $this->configs[$modelClass] = $configResolver->resolve(); // TODO: Find a workaround for doing this twice.
        }

        /* Find relations */
        $this->findRelations(array_values($this->models));
    }
public function configure(array $modelConfigurations) {
        if (empty($modelConfigurations)) {
            throw new \LogicException('Supply at least one model or model configuration!');
        }

        /* First define the models and their columns. */
        foreach ($modelConfigurations as $className) {

            $modelClass = $className;

            if (is_subclass_of($className, 'Illuminate\Database\Eloquent\Model')) {
                $config = new ModelConfig();
                $config->setModelClass($modelClass);
            }
            else if (is_subclass_of($className, 'Label305\AujaLaravel\Config\ModelConfig')) {
                $config = new $className();
                $modelClass = $config->getModelClass();
            }
            else {
                throw new \InvalidArgumentException(
                    "Model configuration should be class name string of either a ModelConfig or Eloquent subclass."
                );
            }

            $model = new Model($modelClass);
            $this->models[$modelClass] = $model;
            $this->relations[$modelClass] = [];

            $configResolver = new ConfigResolver($config, $model);
            $this->configs[$modelClass] = $configResolver->resolve();
            $this->findColumns($this->models[$modelClass]);
            $this->configs[$modelClass] = $configResolver->resolve(); // TODO: Find a workaround for doing this twice.
        }

        /* Find relations */
        $this->findRelations(array_values($this->models));
    }
public function configure ( array $ modelConfigurations ) { if ( empty ( $ modelConfigurations ) ) { throw new \ LogicException ( 'Supply at least one model or model configuration!' ) ; } /* First define the models and their columns. */ foreach ( $ modelConfigurations as $ className ) { $ modelClass = $ className ; if ( is_subclass_of ( $ className , 'Illuminate\Database\Eloquent\Model' ) ) { $ config = new ModelConfig ( ) ; $ config -> setModelClass ( $ modelClass ) ; } else if ( is_subclass_of ( $ className , 'Label305\AujaLaravel\Config\ModelConfig' ) ) { $ config = new $ className ( ) ; $ modelClass = $ config -> getModelClass ( ) ; } else { throw new \ InvalidArgumentException ( "Model configuration should be class name string of either a ModelConfig or Eloquent subclass." ) ; } $ model = new Model ( $ modelClass ) ; $ this -> models [ $ modelClass ] = $ model ; $ this -> relations [ $ modelClass ] = [ ] ; $ configResolver = new ConfigResolver ( $ config , $ model ) ; $ this -> configs [ $ modelClass ] = $ configResolver -> resolve ( ) ; $ this -> findColumns ( $ this -> models [ $ modelClass ] ) ; $ this -> configs [ $ modelClass ] = $ configResolver -> resolve ( ) ; // TODO: Find a workaround for doing this twice. } /* Find relations */ $ this -> findRelations ( array_values ( $ this -> models ) ) ; }
Defines Models, Columns and Relations between the Models.
This method should be called before using any other methods.

@param  String[] $modelConfigurations an array of full namespaces of ModelConfig objects of Eloquent objects
Defines Models Columns and Relations between the Models . This method should be called before using any other methods .