codigo actual del servidor, con avances de joan
This commit is contained in:
40
app/Http/Resources/V2/FlashDealCollection.php
Normal file
40
app/Http/Resources/V2/FlashDealCollection.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources\V2;
|
||||
|
||||
use Illuminate\Http\Resources\Json\ResourceCollection;
|
||||
use App\Http\Resources\ProductCollection;
|
||||
use App\Models\FlashDeal;
|
||||
use App\Models\Product;
|
||||
|
||||
class FlashDealCollection extends ResourceCollection
|
||||
{
|
||||
/**
|
||||
* Transform the resource collection into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
return [
|
||||
'data' => $this->collection->map(function($data) {
|
||||
return [
|
||||
'id' => $data->id,
|
||||
'title' => $data->title,
|
||||
'date' => (int) $data->end_date,
|
||||
'banner' => uploaded_asset($data->banner),
|
||||
'products' => new FlashDealProductCollection($data->flash_deal_products()->take(6)->get())
|
||||
];
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
public function with($request)
|
||||
{
|
||||
return [
|
||||
'success' => true,
|
||||
'status' => 200
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user