mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-20 13:04:48 +00:00
48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Transformers;
|
|
|
|
use App\Models\Announcement;
|
|
use Carbon\Carbon;
|
|
use League\Fractal\TransformerAbstract;
|
|
|
|
class AnnouncementTransformer extends TransformerAbstract
|
|
{
|
|
/**
|
|
* List of resources to automatically include
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $defaultIncludes = [
|
|
//
|
|
];
|
|
|
|
/**
|
|
* List of resources possible to include
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $availableIncludes = [
|
|
//
|
|
];
|
|
|
|
/**
|
|
* A Fractal transformer.
|
|
*
|
|
* @param Announcement $announcement
|
|
* @return array
|
|
*/
|
|
public function transform(Announcement $announcement): array
|
|
{
|
|
return [
|
|
'id' => $announcement->id,
|
|
'title' => $announcement->title,
|
|
'description' => $announcement->description,
|
|
'segments' => $announcement->segments,
|
|
'starting_on' => Carbon::parse($announcement->starting_on)->format('d-m-Y'),
|
|
'ending_on' => Carbon::parse($announcement->ending_on)->format('d-m-Y'),
|
|
'created_at' => Carbon::parse($announcement->created_at)->format('d-m-Y'),
|
|
];
|
|
}
|
|
}
|