I am using Eloquent, I managed to set up composite keys in laravel using the Trait as in this question here:
How I can put composite keys in models in Laravel 5?
However, now I get the following error everywhere:
ErrorException in BelongsTo.php line 82:
Array to string conversion (View: /home/www/app/resources/views/relatorios/show.blade.php)
I understand this is because now my models have a composite primary key:
protected $primaryKey = array('cliente', 'id');
and in the relationship I have:
public function medico()
{
return $this->belongsTo('App\Medico','medico');
}
so this is of course wrong.
I tried to modify to:
public function medico()
{
return $this->belongsTo('App\Medico',['medico','cliente'],['id','cliente']);;
}
but no success.
Any ideas?