I am using Laravel Translatables. But when I execute I got an error like Call to a member function hasTranslation() on null
. Here is my code.
<?php
if($slider->product->hasTranslation($locale))
{
$type = $slider->product->translate($locale)->product_name;
}
else{
$type = $slider->product->translate('en')->product_name;
} //echo $type; exit;
?>
$slider->product
is not null and $locale
has value 'en'
This code is working fine yesterday, the only change I made is, from the admin panel I just removed the required validation from add product field.