This commit is contained in:
Doar Mihai
2026-04-03 01:04:19 +03:00
parent 2b930a0636
commit 1cbe5bfe3b
12 changed files with 536 additions and 2 deletions
@@ -0,0 +1,40 @@
<?php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class JobLocationResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'id' => $this->id,
'city' => $this->city,
'state' => $this->state,
'country' => $this->country,
'country_code' => $this->country_code,
'formatted' => $this->formatted(),
];
}
/**
* Format location as a readable string
*/
private function formatted(): string
{
$parts = array_filter([
$this->city,
$this->state,
$this->country,
]);
return implode(', ', $parts);
}
}