src/Builders/ModelBuilder.php
private function buildRelationships()
    {
        $menus         = Menu::all()->keyBy('id');
        $used          = [];
        $relationships = '';
        foreach ($this->fields as $key => $field) {
            if (! in_array($field->title, $used) && $field->type == 'relationship') {
                $menu    = $menus[$field->relationship_id];
                $relLine = '
    public function $RELATIONSHIP$()
    {
        return $this->hasOne(\'App\$RELATIONSHIP_MODEL$\', \'id\', \'$RELATIONSHIP$_id\');
    }' . "\r\n\r\n";
                $relLine = str_replace([
                    '$RELATIONSHIP$',
                    '$RELATIONSHIP_MODEL$'
                ], [
                    strtolower($menu->name),
                    ucfirst(Str::camel($menu->name))
                ], $relLine);
                $relationships .= $relLine;
            }
        }

        return $relationships;
    }
private function buildRelationships()
    {
        $menus         = Menu::all()->keyBy('id');
        $used          = [];
        $relationships = '';
        foreach ($this->fields as $key => $field) {
            if (! in_array($field->title, $used) && $field->type == 'relationship') {
                $menu    = $menus[$field->relationship_id];
                $relLine = '
    public function $RELATIONSHIP$()
    {
        return $this->hasOne(\'App\$RELATIONSHIP_MODEL$\', \'id\', \'$RELATIONSHIP$_id\');
    }' . "\r\n\r\n";
                $relLine = str_replace([
                    '$RELATIONSHIP$',
                    '$RELATIONSHIP_MODEL$'
                ], [
                    strtolower($menu->name),
                    ucfirst(Str::camel($menu->name))
                ], $relLine);
                $relationships .= $relLine;
            }
        }

        return $relationships;
    }
private function buildRelationships ( ) { $ menus = Menu :: all ( ) -> keyBy ( 'id' ) ; $ used = [ ] ; $ relationships = '' ; foreach ( $ this -> fields as $ key => $ field ) { if ( ! in_array ( $ field -> title , $ used ) && $ field -> type == 'relationship' ) { $ menu = $ menus [ $ field -> relationship_id ] ; $ relLine = '
    public function $RELATIONSHIP$()
    {
        return $this->hasOne(\'App\$RELATIONSHIP_MODEL$\', \'id\', \'$RELATIONSHIP$_id\');
    }' . "\r\n\r\n" ; $ relLine = str_replace ( [ '$RELATIONSHIP$' , '$RELATIONSHIP_MODEL$' ] , [ strtolower ( $ menu -> name ) , ucfirst ( Str :: camel ( $ menu -> name ) ) ] , $ relLine ) ; $ relationships .= $ relLine ; } } return $ relationships ; }
Build model relationships
@return string
Build model relationships