33 lines
800 B
PHP
Executable File
33 lines
800 B
PHP
Executable File
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
use Illuminate\Support\Facades\App;
|
|
|
|
class OrderResource extends JsonResource
|
|
{
|
|
public static $wrap = false;
|
|
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(Request $request): array
|
|
{
|
|
$lang = $request->header('Accept-Language') ?? 'ru';
|
|
|
|
// Set the application locale to the retrieved language
|
|
App::setLocale($lang);
|
|
|
|
return [
|
|
'id' => $this->id,
|
|
'status' => new StatusResource($this->getStatus),
|
|
'created_at' => $this->created_at->format('Y-m-d H:i:s'),
|
|
'total_amount' => $this->price_total,
|
|
];
|
|
}
|
|
}
|