topclaudy / compoships

Multi-columns relationships for Laravel's Eloquent ORM
MIT License
1.12k stars 132 forks source link

SQLSTATE[42S22]: Column not found #113

Open msgkuna opened 3 years ago

msgkuna commented 3 years ago

Hi,

I have table like this:

namespace Modules\Personalia\Entities\Referensi; use Illuminate\Database\Eloquent\Model; use Modules\Personalia\Entities\Referensi\Satker;

class Kecamatan extends Model { use \Awobaz\Compoships\Compoships;

protected $table = 'master_kecamatan';
protected $primaryKey = ['satker_id', 'keca_id'];
protected $keyType = 'string';
public $incrementing = false;
public $timestamps = false;

protected $guarded = [];

public function satker()
{
    return $this->belongsTo(Satker::class, 'satker_id', 'satker_id');
}

}

but I get error message like this:

Illuminate\Database\QueryException SQLSTATE[42S22]: Column not found: 1054 Unknown column 'master_kecamatansatker_id' in 'where clause' (SQL: select * from master_kecamatan where ((master_kecamatansatker_id = 62060 and master_kecamatankeca_id = 010) or (master_kecamatansatker_id = 62060 and master_kecamatankeca_id = 011) or (master_kecamatansatker_id = 62060 and master_kecamatankeca_id = 020) or (master_kecamatansatker_id = 62060 and master_kecamatankeca_id = 030) or (master_kecamatansatker_id = 62060 and master_kecamatankeca_id = 031)))

I use Laravel 8.31.0 with PHP 7.4.15

What should I do? thank you