'Search in a non-existing table - relationship

I try to make hasMany relationship in Laravel and I have this problem. If I rename table name in Model to test, relationship works fine, seraching by my new table name.

model:

public $table = 'test';

query:

select * from `test` where `test`.`product_variant_id` = 1 and `test`.`product_variant_id` is not null

But if I try to search by real existing table with name warehouses_product_variants, relationship searching by non existing table with name warehouses_variant_values

model:

public $table = 'warehouses_product_variants';

query:

select * from `warehouses_variant_values` where `warehouses_variant_values`.`id` = 1 limit 1

relationship:

public function warehouses()
    {
        return $this->hasMany(WarehouseProductVariant::class, 'product_variant_id');
    }

Do you know what the reason is? Thank you



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source