Laravel-Test-Helpers
Laravel-Test-Helpers copied to clipboard
Added support to model helpers for chaining relationship methods
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.
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 *