Completed
Push — master ( 8f9a32...40960a )
by
unknown
05:49
created

SelectMultipleManyToMany::setup()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
crap 1
1
<?php
2
namespace Anavel\Crud\Abstractor\Eloquent\Relation;
3
4
use Anavel\Crud\Abstractor\Eloquent\Relation\Traits\CheckRelationCompatibility;
5
use Anavel\Crud\Abstractor\Eloquent\Relation\Traits\CheckRelationConfig;
6
use Anavel\Crud\Repository\Criteria\InArrayCriteria;
7
use App;
8
use Doctrine\DBAL\Schema\Column;
9
use Illuminate\Http\Request;
10
11
class SelectMultipleManyToMany extends SelectMultiple
12
{
13
    use CheckRelationCompatibility;
14
15
    protected $compatibleEloquentRelations = array(
16
        'Illuminate\Database\Eloquent\Relations\BelongsToMany'
17
    );
18
19 6
    public function setup()
20
    {
21 6
        $this->checkRelationCompatibility();
22 6
        $this->checkDisplayConfig();
23 6
    }
24
25
    /**
26
     * @param array|null $relationArray
27
     * @return mixed
28
     */
29 1
    public function persist(array $relationArray = null, Request $request)
30
    {
31 1
        if (! empty($relationArray)) {
32 1
            $this->eloquentRelation->sync($relationArray[$this->eloquentRelation->getRelated()->getKeyName()]);
33 1
        }
34 1
    }
35
36
    /**
37
     * @param \ANavallaSuiza\Laravel\Database\Contracts\Dbal\AbstractionLayer $dbal
38
     * @return Column
39
     */
40 1
    protected function getColumn($dbal)
41
    {
42 1
        return $dbal->getTableColumn($this->eloquentRelation->getRelated()->getKeyName());
43
    }
44
45
}
46