Completed
Push — master ( 1408f3...b929a0 )
by wen
14:35
created

Link::getValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
4
namespace Sco\Admin\View\Columns;
5
6
class Link extends Column
7
{
8
    protected $template = '<router-link :to="value.url">{{value.title}}</router-link>';
9
10
    private $url;
11
12
    public function getUrl()
13
    {
14
        if ($this->url) {
15
            return $this->url;
16
        }
17
        $model = app('admin.components')->get(get_class($this->getModel()))->getName();
18
        $id    = $this->getModel()->getKey();
19
        return route('admin.model.edit', [$model, $id], false);
20
    }
21
22
    public function setUrl($value)
23
    {
24
        $this->url = $value;
25
26
        return $this;
27
    }
28
29
    public function getValue()
30
    {
31
        return [
32
            'url'   => $this->getUrl(),
33
            'title' => parent::getValue(),
34
        ];
35
    }
36
}
37