public function belongsToMany(string $related, ?string $primary_key = null, ?string $foreign_key = null)
    {
        $relatedModel = app()->make($related);
        $local_key = $local_key ?? $this->getKey();
        // Make the table name singular and append ID to it
        // FIXME: Use a more reliable approach
        $foreign_key = $foreign_key ?? rtrim($relatedModel->getTable(), 's').'_id';
        return new BelongsToMany($relatedModel, $this, $primary_key, $foreign_key);
    }
public function belongsToMany(string $related, ?string $primary_key = null, ?string $foreign_key = null)
    {
        $relatedModel = app()->make($related);
        $local_key = $local_key ?? $this->getKey();
        // Make the table name singular and append ID to it
        // FIXME: Use a more reliable approach
        $foreign_key = $foreign_key ?? rtrim($relatedModel->getTable(), 's').'_id';
        return new BelongsToMany($relatedModel, $this, $primary_key, $foreign_key);
    }
public function belongsToMany ( string $ related , ? string $ primary_key = null , ? string $ foreign_key = null ) { $ relatedModel = app ( ) -> make ( $ related ) ; $ local_key = $ local_key ?? $ this -> getKey ( ) ; // Make the table name singular and append ID to it // FIXME: Use a more reliable approach $ foreign_key = $ foreign_key ?? rtrim ( $ relatedModel -> getTable ( ) , 's' ) . '_id' ; return new BelongsToMany ( $ relatedModel , $ this , $ primary_key , $ foreign_key ) ; }
The belongs to many relative

@param strinf $related
@param string $primary_key
@param string $foreign_key
@return BelongsToMany
The belongs to many relative