public function createModel()
    {
        $file = '<?php'.$this->namespace.LF.LF;

        $file .= '/**'.LF;
        $file .= ' * Eloquent class to describe the '.$this->table.' table'.LF;
        $file .= ' *'.LF;
        $file .= ' * automatically generated by ModelGenerator.php'.LF;
        $file .= ' */'.LF;

        // a new class that extends the provided baseModel
        $file .= 'class '.$this->class.' extends '.$this->baseModel.LF;
        $file .= '{'.LF;

        // the name of the mysql table
        $file .= TAB.'protected $table = '.StringUtils::singleQuote($this->table).';'.LF.LF;

        // primary key defaults to "id"
        if ($this->primaryKey !== 'id') {
            $file .= TAB.'public $primaryKey = '.StringUtils::singleQuote($this->primaryKey).';'.LF.LF;
        }

        // timestamps defaults to true
        if (!$this->timestamps) {
            $file .= TAB.'public $timestamps = '.var_export($this->timestamps, true).';'.LF.LF;
        }

        // incrementing defaults to true
        if (!$this->incrementing) {
            $file .= TAB.'public $incrementing = '.var_export($this->incrementing, true).';'.LF.LF;
        }

        // all date fields
        if (!empty($this->dates)) {
            $file .= TAB.'public function getDates()'.LF;
            $file .= TAB.'{'.LF;
            $file .= TAB.TAB.'return array('.StringUtils::implodeAndQuote(', ', $this->dates).');'.LF;
            $file .= TAB.'}'.LF.LF;
        }

        // most fields are considered as fillable
        $wrap = TAB.'protected $fillable = array('.StringUtils::implodeAndQuote(', ', $this->fillable).');'.LF.LF;
        $file .= wordwrap($wrap, ModelGenerator::$lineWrap, LF.TAB.TAB);

        // except for the hidden ones
        if (!empty($this->hidden)) {
            $file .= TAB.'protected $hidden = array('.StringUtils::implodeAndQuote(', ', $this->hidden).');'.LF.LF;
        }

        // add all relations
        $file .= rtrim($this->relations).LF; // remove one LF from end

        // close the class
        $file .= '}'.LF;

        $this->fileContents = $file;
    }
public function createModel()
    {
        $file = '<?php'.$this->namespace.LF.LF;

        $file .= '/**'.LF;
        $file .= ' * Eloquent class to describe the '.$this->table.' table'.LF;
        $file .= ' *'.LF;
        $file .= ' * automatically generated by ModelGenerator.php'.LF;
        $file .= ' */'.LF;

        // a new class that extends the provided baseModel
        $file .= 'class '.$this->class.' extends '.$this->baseModel.LF;
        $file .= '{'.LF;

        // the name of the mysql table
        $file .= TAB.'protected $table = '.StringUtils::singleQuote($this->table).';'.LF.LF;

        // primary key defaults to "id"
        if ($this->primaryKey !== 'id') {
            $file .= TAB.'public $primaryKey = '.StringUtils::singleQuote($this->primaryKey).';'.LF.LF;
        }

        // timestamps defaults to true
        if (!$this->timestamps) {
            $file .= TAB.'public $timestamps = '.var_export($this->timestamps, true).';'.LF.LF;
        }

        // incrementing defaults to true
        if (!$this->incrementing) {
            $file .= TAB.'public $incrementing = '.var_export($this->incrementing, true).';'.LF.LF;
        }

        // all date fields
        if (!empty($this->dates)) {
            $file .= TAB.'public function getDates()'.LF;
            $file .= TAB.'{'.LF;
            $file .= TAB.TAB.'return array('.StringUtils::implodeAndQuote(', ', $this->dates).');'.LF;
            $file .= TAB.'}'.LF.LF;
        }

        // most fields are considered as fillable
        $wrap = TAB.'protected $fillable = array('.StringUtils::implodeAndQuote(', ', $this->fillable).');'.LF.LF;
        $file .= wordwrap($wrap, ModelGenerator::$lineWrap, LF.TAB.TAB);

        // except for the hidden ones
        if (!empty($this->hidden)) {
            $file .= TAB.'protected $hidden = array('.StringUtils::implodeAndQuote(', ', $this->hidden).');'.LF.LF;
        }

        // add all relations
        $file .= rtrim($this->relations).LF; // remove one LF from end

        // close the class
        $file .= '}'.LF;

        $this->fileContents = $file;
    }
public function createModel ( ) { $ file = '<?php' . $ this -> namespace . LF . LF ; $ file .= '/**' . LF ; $ file .= ' * Eloquent class to describe the ' . $ this -> table . ' table' . LF ; $ file .= ' *' . LF ; $ file .= ' * automatically generated by ModelGenerator.php' . LF ; $ file .= ' */' . LF ; // a new class that extends the provided baseModel $ file .= 'class ' . $ this -> class . ' extends ' . $ this -> baseModel . LF ; $ file .= '{' . LF ; // the name of the mysql table $ file .= TAB . 'protected $table = ' . StringUtils :: singleQuote ( $ this -> table ) . ';' . LF . LF ; // primary key defaults to "id" if ( $ this -> primaryKey !== 'id' ) { $ file .= TAB . 'public $primaryKey = ' . StringUtils :: singleQuote ( $ this -> primaryKey ) . ';' . LF . LF ; } // timestamps defaults to true if ( ! $ this -> timestamps ) { $ file .= TAB . 'public $timestamps = ' . var_export ( $ this -> timestamps , true ) . ';' . LF . LF ; } // incrementing defaults to true if ( ! $ this -> incrementing ) { $ file .= TAB . 'public $incrementing = ' . var_export ( $ this -> incrementing , true ) . ';' . LF . LF ; } // all date fields if ( ! empty ( $ this -> dates ) ) { $ file .= TAB . 'public function getDates()' . LF ; $ file .= TAB . '{' . LF ; $ file .= TAB . TAB . 'return array(' . StringUtils :: implodeAndQuote ( ', ' , $ this -> dates ) . ');' . LF ; $ file .= TAB . '}' . LF . LF ; } // most fields are considered as fillable $ wrap = TAB . 'protected $fillable = array(' . StringUtils :: implodeAndQuote ( ', ' , $ this -> fillable ) . ');' . LF . LF ; $ file .= wordwrap ( $ wrap , ModelGenerator :: $ lineWrap , LF . TAB . TAB ) ; // except for the hidden ones if ( ! empty ( $ this -> hidden ) ) { $ file .= TAB . 'protected $hidden = array(' . StringUtils :: implodeAndQuote ( ', ' , $ this -> hidden ) . ');' . LF . LF ; } // add all relations $ file .= rtrim ( $ this -> relations ) . LF ; // remove one LF from end // close the class $ file .= '}' . LF ; $ this -> fileContents = $ file ; }
Secondly, create the model.
Secondly create the model .