PHP code example of hadder / laravel-presenter

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

    

hadder / laravel-presenter example snippets


use Hadder\LaravelPresenter\Presenter;

class UserPresenter extends Presenter {

    public function nomeCompleto()
    {
        return $this->nome . ' ' . $this->sobrenome;
    }

    public function data_nascimento()
    {
        return $this->data_nascimento->format('d/m/Y');
    }
  
}



use Hadder\LaravelPresenter\PresentableTrait;

class User extends \Eloquent {

    use PresentableTrait;

    protected $presenter = \App\Presenters\UserPresenter::class;

    protected $date = ['data_nascimento'];
}

    <h1>Olá, {{ $user->present()->nomeCompleto }}</h1>