I'm trying to make a belongsToMany relationship in my Model but it's bringing the error:
QueryException SQLSTATE [42S02]: Base table or view not found: 1146 Table 'api.codigo' does not exist (SQL: select
sequenciaaprovacaos
. *,codigo
.sequencia
aspivot_sequencia
,codigo
.sequenciaaprovacao_id
aspivot_sequenciaaprovacao_id
fromsequenciaaprovacaos
inner joincodigo
onsequenciaaprovacaos
.id
=codigo
.sequenciaaprovacao_id
wherecodigo
.sequencia
in (1, 2, 3, 4, 5 , 6, 7, 8, 9, 10,11,12,13,14,15,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30 , 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,42,43,44,45,46,47,49,49,50,50))
My Models
namespace App;
use Illuminate\Database\Eloquent\Model;
class SequenciaUsuario extends Model
{
protected $table = 'sequencia_usuarios';
protected $fillable = [
'sequencia',
'recnum',
'usuario',
'qtde_aprova',
'ordem'
];
public function grupos()
{
return $this->belongsToMany('App\Model\CadSequenciaAprovacao', 'codigo','sequencia');
}
public function cadastro()
{
return $this->belongsToMany('App\Model\CadUsuario','cod_adm');
}
}
namespace App;
use Illuminate\Database\Eloquent\Model;
class CadSequenciaaprovacao extends Model
{
protected $table = 'sequenciaaprovacaos';
protected $fillable = [
'codigo',
'descricao',
];
public function users()
{
return $this->hasMany('App\CadSequenciaUsuario','sequencia');
}
}