Completed
Pull Request — master (#91)
by
unknown
06:31
created

CartCollection   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 15
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A associate() 0 11 1
1
<?php namespace Darryldecode\Cart;
2
3
use Illuminate\Support\Collection;
4
5
class CartCollection extends Collection {
6
7
    public function associate($model, $field = 'id'){
8
9
        $associated = new $model;
10
11
        $this->transform(function($item, $key) use ($associated, $field) {
12
            $item['association'] = $associated->where($field,$key)->first();
13
            return $item;
14
        });
15
16
        return $this;
17
    }
18
19
}