Completed
Push — master ( 650783...0c9838 )
by wen
15:06
created

Link::getEditUrl()   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
namespace Sco\Admin\Display\Columns;
4
5
use Sco\Admin\Facades\Admin;
6
7
class Link extends Column
8
{
9
    protected $template = '<router-link :to="value.url">{{value.title}}</router-link>';
10
11
    private $url;
12
13
    public function getUrl()
14
    {
15
        if ($this->url) {
16
            return $this->url;
17
        }
18
19
        return $this->getEditUrl();
20
    }
21
22
    public function setUrl($value)
23
    {
24
        $this->url = $value;
25
26
        return $this;
27
    }
28
29
    protected function getEditUrl()
30
    {
31
        $model = Admin::component()->getName();
32
        $id = $this->getModel()->getKey();
33
34
        return route('admin.model.edit', [$model, $id], false);
35
    }
36
37
    public function getValue()
38
    {
39
        return [
40
            'url'   => $this->getUrl(),
41
            'title' => parent::getValue(),
42
        ];
43
    }
44
}
45