PageItemDisplay::render()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 8
rs 10
1
<?php
2
3
namespace App\View\Components;
4
5
use Illuminate\View\Component;
6
use Cohensive\OEmbed\Facades\OEmbed;
7
8
9
class PageItemDisplay extends Component
10
{
11
    public $link;
12
    public $id = '';
13
    /**
14
     * Create a new component instance.
15
     *
16
     * @return void
17
     */
18
    public function __construct($link)
19
    {
20
        // $this->title = $title;
21
         $this->link = $link;
22
    }
23
24
    /**
25
     * Get the view / contents that represent the component.
26
     *
27
     * @return \Illuminate\Contracts\View\View|\Closure|string
28
     */
29
    public function render()
30
    {
31
32
        $params = json_decode($this->link->type_params);
33
34
35
36
        return view('components.pageitems.'.$this->link->typename.'-display', ['link' => $this->link, 'params' => $params]);
37
    }
38
39
    public function getModalIdString(): string
40
    {
41
        if ($this->id != '') {
42
            return $this->id;
43
        }
44
45
        return "model" . rand(1111, 9999);
46
    }
47
}
48