Hi
I have these two tables related to each other.
products
$this->hasOne('product_id', '\App\Common\Models\ProductsStats', 'product_id', [
'alias' => 'Stats'
]);
products_stats
$this->belongsTo('product_id', '\App\Common\Models\Products', 'product_id', [
'alias' => 'Product'
]);
and in the controller
public function deleteAction($id){
$product = Products::findFirst($id);
$product->Stats->delete();
$product->delete();
}
The problem is that an error occurs if there is no related record in the "products_stats" table. The error only occurs when using hasOne with hasMany does not happen. Is this error normal? Should not it just be ignored?