Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Sameer Anand authored Apr 22, 2017
1 parent 46ebf1c commit 59e0d36
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ This will create `app\Transformers\UserTransformer.php`

A generated transformer will look like this:
```php
class UserTransformer extends Transformer
class UserTransformer extends Transformer
{
public function transform($user)
{
public function transform($user)
{
return [
'name' => $user->first . ' ' . $user->last
];
}
return [
'name' => $user->first . ' ' . $user->last
];
}
}
```

Modify the returned array in the transform method to define how you want the data to be transformed.
Expand All @@ -48,23 +48,23 @@ Modify the returned array in the transform method to define how you want the dat
You can transform a single item using the transform method. For example:

```php
public function show(User $user, UserTransformer $transformer)
{
return $transformer->transform($user);
}
public function show(User $user, UserTransformer $transformer)
{
return $transformer->transform($user);
}
```

You can transform a collection of items using the transformCollection method. For example:

```php
public function index(UserTransformer $transformer)
{
$users = User::all();
$transformer->transformCollection($users);
}
public function index(UserTransformer $transformer)
{
$users = User::all();

$transformer->transformCollection($users);
}
```

## License

Released under the MIT License, Copyright (c) 2017 - Sameer Anand (<[email protected]>)
Released under the MIT License, Copyright (c) 2017 - Sameer Anand (<[email protected]>)

0 comments on commit 59e0d36

Please sign in to comment.