Conditions | 4 |
Paths | 4 |
Total Lines | 18 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
35 | public function present($data) |
||
36 | { |
||
37 | if (!class_exists('League\Fractal\Manager')) { |
||
38 | throw new \Exception(trans('repository::packages.league_fractal_required')); |
||
39 | } |
||
40 | |||
41 | if ($data instanceof Collection) { |
||
|
|||
42 | $this->resource = $this->transformCollection($data); |
||
43 | } elseif ($data instanceof AbstractPaginator) { |
||
44 | $this->resource = $this->transformPaginator($data); |
||
45 | } else { |
||
46 | $this->resource = $this->transformItem($data); |
||
47 | } |
||
48 | |||
49 | // set meta |
||
50 | $this->resource->setMeta($this->meta); |
||
51 | |||
52 | return $this->fractal->createData($this->resource)->toArray(); |
||
53 | } |
||
67 |