PHP code example of quieteroks / yii-presenter

1. Go to this page and download the library: Download quieteroks/yii-presenter 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/ */

    

quieteroks / yii-presenter example snippets


/**
 * DocBlock for description all field
 */
class UserPresenter extends \quieteroks\presenter\Presenter
{
}

class UserPresenter extends \quieteroks\presenter\Presenter
{
    /**
     * @var array Protect password hash from access via presenter
     */
    protected $hidden = [
        'password_hash',
    ];
    /**
     * @var array Decorate to camelCase properties
     */
    protected $renamed = [
        'createdAt' => 'created_at',
        'updatedAt' => 'updated_at',
    ];
}

class UserPresenter extends \quieteroks\presenter\Presenter
{
    /**
     * Returns fullname property
     *
     * @return string
     */
    protected function getFullName()
    {
        return implode(' ', array_filter([
            $this->getRealPropertyValue('last_name'),
            $this->getRealPropertyValue('first_name'),
            $this->getRealPropertyValue('middle_name'),
        ]));
    }
}