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/exams-module / Transformers / ExamsDatatableTransformer.php
Size: Mime:
<?php
/**
 * Created by PhpStorm.
 * User: danilo
 * Date: 18/12/15
 * Time: 16:47
 */
namespace Modules\Exams\Transformers;

use League\Fractal\TransformerAbstract;
use Modules\Exams\Entities\Exam;
use \Html;

class ExamsDatatableTransformer extends TransformerAbstract {

    public function transform(Exam $model)
    {

        $showBtn = [
            'href' => route('questions.index', [$model->id]),
            'class' => 'btn btn-primary btn-xs'
        ];

        $editBtn = [
            'href' => route('exams.edit', [$model->id]),
            'class' => 'btn btn-primary btn-xs'
        ];

        $deletBtn = [
            'href' => route('exams.destroy', [$model->id]),
            'class' => 'btn btn-danger btn-xs confirm-delete'
        ];
        $data = [
            'id'     => (int) $model->id,
            'title' => $model->title,
            'total_questions' => $model->question->count(),
            'is_active' => (boolean) $model->is_active ? Html::icon('check') : Html::icon('remove'),
            'action' => Html::linkWithIcon(trans('exams::exams.actions_btn.questions'), 'list-ol', $showBtn).' '.
                        Html::linkWithIcon(trans('exams::exams.actions_btn.edit'), 'pencil', $editBtn).' '.
                        Html::linkWithIcon(trans('exams::exams.actions_btn.delete'), 'trash', $deletBtn)
        ];

        if (module_enabled('Courses')) {
            $data['course'] = $model->course ? $model->course->title : '--';
        }
        return $data;
    }
}