src/commands/CrudController.php
public function actionModel($model = null)
    {
        if (!$model) {
            $model = $this->prompt('Namespaced path to the ngrest model (e.g. "app\models\Users"):');
        }
        $object = Yii::createObject(['class' => $model]);
        
        if (!$object instanceof NgRestModelInterface) {
            throw new Exception("Model must be instance of NgRestModelInterface.");
        }
        
        $reflector = new \ReflectionClass($model);
        $fileName = $reflector->getFileName();
        $path = dirname($fileName);
        $apiEndpoint = $object->ngrestApiEndpoint();
        $i18n = !empty($object->i18n);
        $data = [
            'path' =>  $path,
            'fileName' => basename($fileName),
            'content' => $this->generateModelContent(
                $reflector->getNamespaceName(),
                $reflector->getShortName(),
                $apiEndpoint,
                Yii::$app->db->getTableSchema($object->tableName(), true),
                $i18n
             ),
        ];
        
        $this->generateFile($data);
    }
public function actionModel($model = null)
    {
        if (!$model) {
            $model = $this->prompt('Namespaced path to the ngrest model (e.g. "app\models\Users"):');
        }
        $object = Yii::createObject(['class' => $model]);
        
        if (!$object instanceof NgRestModelInterface) {
            throw new Exception("Model must be instance of NgRestModelInterface.");
        }
        
        $reflector = new \ReflectionClass($model);
        $fileName = $reflector->getFileName();
        $path = dirname($fileName);
        $apiEndpoint = $object->ngrestApiEndpoint();
        $i18n = !empty($object->i18n);
        $data = [
            'path' =>  $path,
            'fileName' => basename($fileName),
            'content' => $this->generateModelContent(
                $reflector->getNamespaceName(),
                $reflector->getShortName(),
                $apiEndpoint,
                Yii::$app->db->getTableSchema($object->tableName(), true),
                $i18n
             ),
        ];
        
        $this->generateFile($data);
    }
public function actionModel ( $ model = null ) { if ( ! $ model ) { $ model = $ this -> prompt ( 'Namespaced path to the ngrest model (e.g. "app\models\Users"):' ) ; } $ object = Yii :: createObject ( [ 'class' => $ model ] ) ; if ( ! $ object instanceof NgRestModelInterface ) { throw new Exception ( "Model must be instance of NgRestModelInterface." ) ; } $ reflector = new \ ReflectionClass ( $ model ) ; $ fileName = $ reflector -> getFileName ( ) ; $ path = dirname ( $ fileName ) ; $ apiEndpoint = $ object -> ngrestApiEndpoint ( ) ; $ i18n = ! empty ( $ object -> i18n ) ; $ data = [ 'path' => $ path , 'fileName' => basename ( $ fileName ) , 'content' => $ this -> generateModelContent ( $ reflector -> getNamespaceName ( ) , $ reflector -> getShortName ( ) , $ apiEndpoint , Yii :: $ app -> db -> getTableSchema ( $ object -> tableName ( ) , true ) , $ i18n ) , ] ; $ this -> generateFile ( $ data ) ; }
Generate only the ngrest model

@param string $model Provide
@throws Exception
Generate only the ngrest model