BaseDatatable::addTranslationAction()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 12
ccs 0
cts 9
cp 0
rs 9.9666
c 0
b 0
f 0
cc 2
nc 1
nop 2
crap 6
1
<?php namespace Distilleries\Expendable\Http\Datatables;
2
3
use Distilleries\DatatableBuilder\EloquentDatatable;
4
use Distilleries\Expendable\Models\Language;
5
use Distilleries\Expendable\Models\Translation;
6
7
abstract class BaseDatatable extends EloquentDatatable {
8
9
10
    // ------------------------------------------------------------------------------------------------
11
    public function addTranslationAction($template = 'expendable::admin.form.components.datatable.translations', $route = '')
12
    {
13
        $this->add('translation', function($model) use ($template, $route) {
14
15
            $languages    = Language::withoutCurrentLanguage()->get();
16
            $translations = Translation::byElement($model)->pluck('id_element', 'iso')->toArray();
17
            return view($template, array(
18
                'languages'    => $languages,
19
                'translations' => $translations,
20
                'data'         => $model->toArray(),
21
                'route'        => !empty($route) ? $route.'@' : $this->getControllerNameForAction().'@'
22
            ))->render();
23
        });
24
25
    }
26
27
    // ------------------------------------------------------------------------------------------------
28 14
    public function addDefaultAction($template = 'expendable::admin.form.components.datatable.actions', $route = '')
29
    {
30 14
        parent::addDefaultAction($template, $route);
31
    }
32
}