private function addRelationshipInModel($modelPath, $relationshipModel, $tableName)
    {
        // load model
        $model = $this->files->get($modelPath);

        // get the position where to insert into file
        $index = strlen($model) - strpos(strrev($model), '}') - 1;

        // load many to many stub
        $stub = $this->files->get(config('generators.' . 'many_many_relationship_stub'));
        $stub = str_replace('{{model}}', $relationshipModel, $stub);
        $stub = str_replace('{{relationship}}', camel_case($tableName), $stub);
        //$stub = str_replace('{{relationship}}', strtolower(str_plural($relationshipModel)), $stub);

        // insert many many stub in model
        $model = substr_replace($model, $stub, $index, 0);

        // save model file
        $this->files->put($modelPath, $model);

        $this->info("{$relationshipModel} many to many Relationship added in {$modelPath}");
    }
private function addRelationshipInModel($modelPath, $relationshipModel, $tableName)
    {
        // load model
        $model = $this->files->get($modelPath);

        // get the position where to insert into file
        $index = strlen($model) - strpos(strrev($model), '}') - 1;

        // load many to many stub
        $stub = $this->files->get(config('generators.' . 'many_many_relationship_stub'));
        $stub = str_replace('{{model}}', $relationshipModel, $stub);
        $stub = str_replace('{{relationship}}', camel_case($tableName), $stub);
        //$stub = str_replace('{{relationship}}', strtolower(str_plural($relationshipModel)), $stub);

        // insert many many stub in model
        $model = substr_replace($model, $stub, $index, 0);

        // save model file
        $this->files->put($modelPath, $model);

        $this->info("{$relationshipModel} many to many Relationship added in {$modelPath}");
    }
private function addRelationshipInModel ( $ modelPath , $ relationshipModel , $ tableName ) { // load model $ model = $ this -> files -> get ( $ modelPath ) ; // get the position where to insert into file $ index = strlen ( $ model ) - strpos ( strrev ( $ model ) , '}' ) - 1 ; // load many to many stub $ stub = $ this -> files -> get ( config ( 'generators.' . 'many_many_relationship_stub' ) ) ; $ stub = str_replace ( '{{model}}' , $ relationshipModel , $ stub ) ; $ stub = str_replace ( '{{relationship}}' , camel_case ( $ tableName ) , $ stub ) ; //$stub = str_replace('{{relationship}}', strtolower(str_plural($relationshipModel)), $stub); // insert many many stub in model $ model = substr_replace ( $ model , $ stub , $ index , 0 ) ; // save model file $ this -> files -> put ( $ modelPath , $ model ) ; $ this -> info ( "{$relationshipModel} many to many Relationship added in {$modelPath}" ) ; }
Insert the many to many relationship in model
@param $modelPath
@param $relationshipModel
@param $tableName
Insert the many to many relationship in model