Completed
Push — master ( d667fa...79b3cb )
by Abdelrahman
01:13
created

Widget::getFacadeAccessor()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Rinvex\Widgets\Facades;
6
7
use Illuminate\Support\Collection;
8
use Illuminate\Support\Facades\Facade;
9
use Rinvex\Widgets\Models\WidgetGroup;
10
11
class Widget extends Facade
12
{
13
    /**
14
     * Get the registered name of the component.
15
     *
16
     * @return string
17
     */
18
    protected static function getFacadeAccessor()
19
    {
20
        return 'rinvex.widgets';
21
    }
22
23
    /**
24
     * Get the widgets collection.
25
     *
26
     * @return \Illuminate\Support\Collection
27
     */
28
    public static function list(): Collection
29
    {
30
        return app('rinvex.widgets.list');
31
    }
32
33
    /**
34
     * Get the widget groups collection.
35
     *
36
     * @return \Illuminate\Support\Collection
37
     */
38
    public static function groups(): Collection
39
    {
40
        return app('rinvex.widgets.group');
41
    }
42
43
    /**
44
     * Get the given group's widget collection.
45
     *
46
     * @param string $name
47
     *
48
     * @return \Rinvex\Widgets\Models\WidgetGroup
49
     */
50
    public static function group(string $name): WidgetGroup
51
    {
52
        return app('rinvex.widgets.group')->get($name)
53
               ?? app('rinvex.widgets.group')->put($name, new WidgetGroup())->get($name);
54
    }
55
}
56