Laravel-Test-Helpers icon indicating copy to clipboard operation
Laravel-Test-Helpers copied to clipboard

Added support to model helpers for chaining relationship methods

Open SammyK opened this issue 12 years ago • 1 comments

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.

SammyK avatar Jan 08 '14 22:01 SammyK

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 *

pacobony avatar Apr 11 '16 13:04 pacobony