15479603
Alex Savenko
initialize
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
<?php
namespace App\Transformers;
use App\Model\Album;
use PhalconRest\Transformers\Transformer;
class AlbumTransformer extends Transformer
{
protected $availableIncludes = [
'photos'
];
public function includePhotos($album)
{
return $this->collection($album->getPhotos(), new PhotoTransformer);
}
public function transform(Album $album)
{
return [
'id' => $this->int($album->id),
'title' => $album->title,
'updated_at' => $album->updatedAt,
'created_at' => $album->createdAt
];
}
}
|