feat(catalog,contacts): fresh catalog and contacts implementation

This commit is contained in:
Darko Gjorgjijoski
2026-08-20 21:50:34 +02:00
parent b5b4e2c978
commit a93d13a188
34 changed files with 2941 additions and 0 deletions
@@ -0,0 +1,36 @@
<?php
namespace App\Domains\Catalog\Http\Resources;
use App\Domains\Accounts\Http\Resources\CompanyResource;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* The payload for a measurement unit: its identity plus the company it
* belongs to.
*
* The owning company is expanded only when the relation resolves, so the
* `company` key is absent -- not null -- for a unit whose company row is
* missing. Checking that costs an existence query per serialised unit.
*/
class UnitResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param Request $request
*/
public function toArray($request): array
{
return [
'id' => $this->id,
'name' => $this->name,
'company_id' => $this->company_id,
'company' => $this->when(
$this->company()->exists(),
fn () => new CompanyResource($this->company)
),
];
}
}