API Resources (Laravel)
Në shqip përdoret i njëjti emër.
ShpjegimiSQ
API Resources e kthejnë një model Eloquent në JSON me formën që dëshiron — p.sh. fsheh fushat sekrete dhe shton fusha të llogaritura — pa e shkruar me dorë në çdo controller.
EnglishEN
API Resources turn an Eloquent model into JSON in the shape you want — e.g. hiding secret fields and adding computed ones — without hand-writing it in every controller.
Si ta mendosh
Si një kartëvizitë e printuar me vetëm të dhënat publike.
Lexoje në anglisht
Like a printed business card with only the public details.
Shembull kodiphp
class NxenesResource extends JsonResource {
public function toArray($request): array {
return ['id' => $this->id, 'emri' => $this->emri];
}
}