PHP code example of itsdamien / laravel-model-transformer
1. Go to this page and download the library: Download itsdamien/laravel-model-transformer library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
itsdamien / laravel-model-transformer example snippets
class UserTransformer extends \ItsDamien\Transformer\AbstractTransformer
{
public function model($model)
{
return [
'first_name' => $model->first_name,
'last_name' => $model->last_name,
'full_name' => $model->first_name.' '.$model->last_name,
'photos' => PhotoTransformer::transform($model->photos),
];
}
}