Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
webbingbrasil/clients-module / Transformers / ClientDatatableTransformer.php
Size: Mime:
<?php
/**
 * Created by PhpStorm.
 * User: danilo
 * Date: 18/12/15
 * Time: 16:47
 */

namespace Modules\Clients\Transformers;

use Html;
use League\Fractal\TransformerAbstract;
use Modules\Clients\Entities\Client;

/**
 * Class ClientDatatableTransformer
 * @package Modules\Clients\Transformers
 */
class ClientDatatableTransformer extends TransformerAbstract
{

    /**
     * @param Client $model
     * @return array
     */
    public function transform(Client $model)
    {

        $editBtn = Html::linkWithIcon('Editar', 'pencil', [
            'href' => route('admin.clients.edit', [$model->id]),
            'class' => 'btn btn-primary btn-xs'
        ]);

        $deletBtn = Html::linkWithIcon('Excluir', 'trash', [
            'href' => route('admin.clients.destroy', [$model->id]),
            'class' => 'btn btn-danger btn-xs confirm-delete'
        ]);

        /** @noinspection PhpUndefinedMethodInspection */
        return [
            'id' => (int)$model->id,
            'position' => (int)$model->position,
            'name' => $model->name,
            'url' => $model->url,
            'logo' => $model->logo ? '<img src="'.$model->logo->getUrl('thumb').'" width="90" alt="'.$model->name.'"/>' : '',
            'created_at' => $model->created_at->timestamp <= 0 ? '--' : $model->created_at->format('d/m/Y'),
            'action' => $editBtn . ' ' . $deletBtn
        ];
    }
}