0
I am trying to effect a relationship belongsToMany in my Model but is bringing the error:
Queryexception SQLSTATE[42S02]: Base table or view not found: 1146 Table 'api.codigo' doesn’t 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, 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, 48, 49, 50, 51))
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');
}
}
$this->belongsToMany('App\Model\CadSequenciaAprovacao', 'codigo','sequencia');
here you are wrong, what is the name of the intermediate table! has how to put the bank diagram?– novic
I am without the Diagram here but sequential
– Shaolin Fantastic
If you can put
– novic