Laravel Excel export relation columns give array and Arabic words is become like \u0633\u0627\u0645\u0633\u0648\u0646\u062c
how to solve it ? I tried to use json_encode($subcategory->name, JSON_UNESCAPED_UNICODE)
and it is not working also and give same results. Does anyone have some suggestions to solve this?
Export file
class CategoriesExport implements FromQuery, WithMapping, WithHeadings
{
use Exportable;
protected $checked;
public function __construct($checked)
{
$this->checked = $checked;
}
public function map($category): array
{
return [
$category->id,
$category->name,
$category->status == 1 ? trans('applang.active') : trans('applang.suspended'),
$category->section->name,
$category->brands->map(function ($brand){ return $brand->name; }),
$category->subCategories->map(function ($subcategory){ return $subcategory->name; })
];
}
public function headings(): array
{
return [
'#ID',
trans('applang.the_category'),
trans('applang.status'),
trans('applang.the_section'),
trans('applang.the_brand'),
trans('applang.sub_cat'),
];
}
public function query()
{
return Category::with(['section', 'brands', 'subCategories', 'products'])->whereIn('id', $this->checked);
}
}