Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support to model helpers for chaining relationship methods #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SammyK
Copy link

@SammyK SammyK commented Jan 8, 2014

Now we can add ->withPivot() and ->withTimestamps() methods to model relationship methods without errors.

return $this->belongsToMany('User')->withPivot('foo')->withTimestamps();

This fixes issue #30.

endorama added a commit to endorama/Laravel-Test-Helpers that referenced this pull request Mar 13, 2014
…ionship methods

* sammyk/fix-relationship-chain:
  Added support to model helpers for chaining ->withPivot() and ->withTimestamps() to model realtionship methods
@pacobony
Copy link

I'm trying to test one similar function but I get the same error:

public function testBelongsToEmployee()
    {
        $this->assertBelongsToMany('employees', Service::class);
    }
public function employees()
    {
        return $this->belongsToMany(
            Employee::class,
            'catalogo_servicios_roles_empleados',
            'id_servicio',
            'id_empleado'
        )->withPivot('id_rol');
    }

*PHP Fatal error: Call to a member function withPivot() on a non-object in /srv/www/vhosts/api.globalsuite/app/Models/Services/Service.php on line 162
*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants