Hi there
i make a plugin with builder. almost everything works, but with relations there goes something wrong. my model
<?php namespace Michael\Diesel\Models;
use Model;
/**
* Model
*/
class Eigen extends Model
{
use \October\Rain\Database\Traits\Validation;
use \October\Rain\Database\Traits\SoftDelete;
protected $dates = ['deleted_at'];
/**
* @var string The database table used by the model.
*/
public $table = 'michael_diesel_eigen';
// public $belongsTo = [
// 'kenteken' => [Acme\Blog\Models\Auto::class, 'key' => 'monteur_id', 'otherKey' => 'monteur_id']
// ];
public $hasOne =[
// 'kenteken' => [\michael\Diesel\Models\Auto::class, 'key' => 'kenteken']
'monteur_id' => [Monteur::class, 'key' => 'monteur_id']
];
// 'brand' =>[
// 'michael\Diesel\Models\Auto',
// 'table' => 'michael_diesel_autos'
// ],
// ];
/**
* @var array Validation rules
*/
public $rules = [
];
}
But i get a error that he want to save it in the wrong table
"SQLSTATE[42S22]: Column not found: 1054 Unknown column
'michael_diesel_monteurs.monteur_id' in
'where clause' (SQL:
update
`michael_diesel_monteurs`
set `monteur_id` = ,
`updated_at` = 2021-07-23 08:33:05
where
`michael_diesel_monteurs`.`monteur_id` = 130 and
`michael_diesel_monteurs`.`monteur_id` is not null and
`michael_diesel_monteurs`.`deleted_at` is null)"
why he want to save it to the monteurs table. ? with this line : public $table = 'michael_diesel_eigen';
Last updated