protected function saveModelForTable()
    {
        $table = $this;
        $dates = [];
        $fields = $table->getFields();
        // TODO Work with the namespace again. The FQN does not work since switching to the generator.s
        $modelContent = (new ModelContent($table->getModelName()))->setTable($table->getName());

        if (array_key_exists($field = 'deleted_at', $fields)) {
            unset($fields[$field]);

            $dates[] = $field;
            $modelContent->setTraits(['\Illuminate\Database\Eloquent\SoftDeletes']);
        } // if

        if (array_key_exists($field = 'created_at', $fields)) {
            unset($fields[$field]);

            $dates[] = $field;
        } // if

        if (array_key_exists($field = 'updated_at', $fields)) {
            unset($fields[$field]);

            $dates[] = $field;
        } // if

        if ($dates) {
            $modelContent->setDates($dates);
        } // if

        unset($fields['id']);
        $modelContent->setFillable(array_diff(array_keys($fields), $table->getBlacklist()));
        $modelContent->setCasts($table->getCastedFields());

        if ($genericCalls = $table->getGenericCalls()) {
            foreach ($genericCalls as $call) {
                if ($call instanceof ForeignKey) {
                    $modelContent->addForeignKey($call);
                } // if
            } // foreach
        } // if

        if ($sources = $table->getRelationSources()) {
            foreach ($sources as $call) {
                if ($call instanceof ForeignKey) {
                    $modelContent->addForeignKey($call);
                } // if
            } // foreach
        } // if

        $modelContent->save();

        return $this;
    }
protected function saveModelForTable()
    {
        $table = $this;
        $dates = [];
        $fields = $table->getFields();
        // TODO Work with the namespace again. The FQN does not work since switching to the generator.s
        $modelContent = (new ModelContent($table->getModelName()))->setTable($table->getName());

        if (array_key_exists($field = 'deleted_at', $fields)) {
            unset($fields[$field]);

            $dates[] = $field;
            $modelContent->setTraits(['\Illuminate\Database\Eloquent\SoftDeletes']);
        } // if

        if (array_key_exists($field = 'created_at', $fields)) {
            unset($fields[$field]);

            $dates[] = $field;
        } // if

        if (array_key_exists($field = 'updated_at', $fields)) {
            unset($fields[$field]);

            $dates[] = $field;
        } // if

        if ($dates) {
            $modelContent->setDates($dates);
        } // if

        unset($fields['id']);
        $modelContent->setFillable(array_diff(array_keys($fields), $table->getBlacklist()));
        $modelContent->setCasts($table->getCastedFields());

        if ($genericCalls = $table->getGenericCalls()) {
            foreach ($genericCalls as $call) {
                if ($call instanceof ForeignKey) {
                    $modelContent->addForeignKey($call);
                } // if
            } // foreach
        } // if

        if ($sources = $table->getRelationSources()) {
            foreach ($sources as $call) {
                if ($call instanceof ForeignKey) {
                    $modelContent->addForeignKey($call);
                } // if
            } // foreach
        } // if

        $modelContent->save();

        return $this;
    }
protected function saveModelForTable ( ) { $ table = $ this ; $ dates = [ ] ; $ fields = $ table -> getFields ( ) ; // TODO Work with the namespace again. The FQN does not work since switching to the generator.s $ modelContent = ( new ModelContent ( $ table -> getModelName ( ) ) ) -> setTable ( $ table -> getName ( ) ) ; if ( array_key_exists ( $ field = 'deleted_at' , $ fields ) ) { unset ( $ fields [ $ field ] ) ; $ dates [ ] = $ field ; $ modelContent -> setTraits ( [ '\Illuminate\Database\Eloquent\SoftDeletes' ] ) ; } // if if ( array_key_exists ( $ field = 'created_at' , $ fields ) ) { unset ( $ fields [ $ field ] ) ; $ dates [ ] = $ field ; } // if if ( array_key_exists ( $ field = 'updated_at' , $ fields ) ) { unset ( $ fields [ $ field ] ) ; $ dates [ ] = $ field ; } // if if ( $ dates ) { $ modelContent -> setDates ( $ dates ) ; } // if unset ( $ fields [ 'id' ] ) ; $ modelContent -> setFillable ( array_diff ( array_keys ( $ fields ) , $ table -> getBlacklist ( ) ) ) ; $ modelContent -> setCasts ( $ table -> getCastedFields ( ) ) ; if ( $ genericCalls = $ table -> getGenericCalls ( ) ) { foreach ( $ genericCalls as $ call ) { if ( $ call instanceof ForeignKey ) { $ modelContent -> addForeignKey ( $ call ) ; } // if } // foreach } // if if ( $ sources = $ table -> getRelationSources ( ) ) { foreach ( $ sources as $ call ) { if ( $ call instanceof ForeignKey ) { $ modelContent -> addForeignKey ( $ call ) ; } // if } // foreach } // if $ modelContent -> save ( ) ; return $ this ; }
Saves the model content for a table.
@return MakeMWBModel
Saves the model content for a table .