feat(category): add banner functionality to categories with related resource and migration tests
This commit is contained in:
24
app/Domains/Commerce/Catalog/Resources/CategoryResource.php
Normal file
24
app/Domains/Commerce/Catalog/Resources/CategoryResource.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Commerce\Catalog\Resources;
|
||||
|
||||
use App\Domains\Commerce\Catalog\Models\Category;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
/** @mixin Category */
|
||||
class CategoryResource extends JsonResource
|
||||
{
|
||||
/** @return array<string, mixed> */
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'nombre' => $this->nombre,
|
||||
'categoria_id' => $this->categoria_id,
|
||||
'banner_url' => $this->banner_enabled
|
||||
? $this->banner?->getTemporaryUrl(1440)
|
||||
: null,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user