Files
InvoiceShelf/app/Http/Resources/RoleResource.php
agencetwogether 3b61440e1f Complete dashboard translations & small UI improvements (#69)
* fix dropdown action Estimate Dashboard and fix translating full Dasboard page

* Update app.php

* fix locale in app.php config

* Wizard install with translation, customer portal with translation, and fixing hardcoding strings to get translation

* fixes asked to review

* fixes pint

---------

Co-authored-by: Max <contact@agencetwogether.fr>
Co-authored-by: Darko Gjorgjijoski <5760249+gdarko@users.noreply.github.com>
2024-06-05 12:07:46 +02:00

35 lines
855 B
PHP

<?php
namespace App\Http\Resources;
use App\Models\CompanySetting;
use Carbon\Carbon;
use Illuminate\Http\Resources\Json\JsonResource;
class RoleResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
*/
public function toArray($request): array
{
return [
'id' => $this->id,
'name' => $this->name,
'title' => $this->title,
'level' => $this->level,
'formatted_created_at' => $this->getFormattedAt(),
'abilities' => $this->getAbilities(),
];
}
public function getFormattedAt()
{
$dateFormat = CompanySetting::getSetting('carbon_date_format', $this->scope);
return Carbon::parse($this->created_at)->translatedFormat($dateFormat);
}
}