1. Go to this page and download the library: Download dan-har/presentit 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/ */
$array = $presentation->show();
// if birthday is not public ->
// $array = [
// 'id' => $user->id,
// 'first_name' => ucfirst($user->first_name),
// ]
// birthday key is not visible.
class UserTransformer
{
public function transform(User $user)
{
return [
'id' => $user->id,
'first_name' => ucfirst($user->first_name),
// ...
];
}
}
$presentation = Present::each($usersList)->with(UserTransformer::class);
$tranformer = new UserTransformer();
$presentation = Present::item($user)->with($transformer);
$presentation = Present::each($usersList)->with($transformer);
use Presentit\Present;
class UserTransformer
{
public function transform(User $user)
{
return [
'id' => $user->id,
'first_name' => ucfirst($user->first_name),
'friends' => $user->friends ? Present::each($user->friends)->with(UserTransformer::class) : [],
// ...
];
}
}
$presentation = Present::each($usersList)->with(UserTransformer::class);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.