0

I have been searching alot for this problem solution. I need to access current app locale set earlier inside my controller function using \App::setLocale('en'). But later on i was unable to get current locale inside model using app()->getLocale() or App::isLocale('en') or App::getLocale(). Please Look at below code inside orders model:

public function getOrderDetailAttribute($value)
{
    $new = [];
    $arr = json_decode($value,true);
    if(!empty($arr))
    foreach($arr as $val)
    {
       $temp["id"] = $val["id"];

           if(App::isLocale('en'))
               $temp['itemName'] = $val["name"];
           else
               $temp['itemName'] = $val["name_ar"];

       if(!empty($val["size"]))
       $temp['size'] = $val["size"];
       $temp['Qty'] = $val["quantity"];
       $temp['price'] = $val["price"];
       $temp['image'] = $val["p_img_url"];
       $new[] = $temp;
       unset($temp);
    }
    return $new;
}

Please suggest.

Thanks.

0 Answers0