src/Builders/ControllerBuilder.php
public function indexBuilder()
    {
        if ($this->relationships == 0) {
            return '$' . strtolower($this->modelName) . ' = ' . $this->modelName . '::all();';
        } else {
            $relationship = '$' . strtolower($this->modelName) . ' = ' . $this->modelName . '::$WITH$get();';
            foreach ($this->fields as $field) {
                if ($field->type == 'relationship') {
                    $relationship = str_replace([
                        '$WITH$'
                    ], [
                        'with("' . $field->relationship_name . '")->$WITH$'
                    ], $relationship);
                }
            }
            $relationship = str_replace('$WITH$', '', $relationship);

            return $relationship;
        }
    }
public function indexBuilder()
    {
        if ($this->relationships == 0) {
            return '$' . strtolower($this->modelName) . ' = ' . $this->modelName . '::all();';
        } else {
            $relationship = '$' . strtolower($this->modelName) . ' = ' . $this->modelName . '::$WITH$get();';
            foreach ($this->fields as $field) {
                if ($field->type == 'relationship') {
                    $relationship = str_replace([
                        '$WITH$'
                    ], [
                        'with("' . $field->relationship_name . '")->$WITH$'
                    ], $relationship);
                }
            }
            $relationship = str_replace('$WITH$', '', $relationship);

            return $relationship;
        }
    }
public function indexBuilder ( ) { if ( $ this -> relationships == 0 ) { return '$' . strtolower ( $ this -> modelName ) . ' = ' . $ this -> modelName . '::all();' ; } else { $ relationship = '$' . strtolower ( $ this -> modelName ) . ' = ' . $ this -> modelName . '::$WITH$get();' ; foreach ( $ this -> fields as $ field ) { if ( $ field -> type == 'relationship' ) { $ relationship = str_replace ( [ '$WITH$' ] , [ 'with("' . $ field -> relationship_name . '")->$WITH$' ] , $ relationship ) ; } } $ relationship = str_replace ( '$WITH$' , '' , $ relationship ) ; return $ relationship ; } }
Build our index template
@return mixed|string
Build our index template