Good morning. I would like to relate two tables in Laravel, from the models, without using the id field.
That is, I have a table with a common field, which is not an ID. And I would like to relate them.
table 1 field 1 field 2 field a - > Field with the same value in the two tables
Table 2 field 3 field 6 field a - > Field with the same value in the two tables
Right now I use:
class Device extends Model
{
public function alarms()
{
return $this->hasMany(Alarm::class, 'device_imei', 'device_imei');
}
}
But it does not work for me.