49 lines
1 KiB
PHP
49 lines
1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use App\Models\Shop;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class ShopResource extends JsonResource
|
|
{
|
|
/** @var \App\Models\Shop */
|
|
private $shop;
|
|
|
|
/** @var array */
|
|
private $skeleton = [
|
|
'id' => 0,
|
|
'name' => '',
|
|
'address' => '',
|
|
'postal_code' => 0,
|
|
'city' => '',
|
|
'phone' => '',
|
|
'gmaps_embed_href' => 0,
|
|
];
|
|
|
|
/**
|
|
* ShopResource
|
|
*
|
|
* @param \App\Models\Shop $shop
|
|
*/
|
|
public function __construct(Shop $shop)
|
|
{
|
|
$this->shop = $shop;
|
|
}
|
|
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param mixed $request
|
|
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
|
* @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
// phpcs:enable
|
|
return array_intersect_key(
|
|
$this->shop->toArray(),
|
|
$this->skeleton
|
|
);
|
|
}
|
|
}
|