WidgetController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 28
c 0
b 0
f 0
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setTranslatable() 0 4 1
A setLocalesAttributes() 0 4 1
A index() 0 3 1
1
<?php
2
3
namespace Diglabby\Doika\Http\Controllers\Widget;
4
5
use App\Http\Controllers\Controller;
6
use Illuminate\Contracts\Support\Renderable;
7
use Illuminate\Support\Facades\View;
8
9
class WidgetController extends Controller
10
{
11
    public function index(): Renderable
12
    {
13
        return view('widget.campaign');
14
    }
15
16
    /**
17
     * Push attributes in order to correctly localize slugs.
18
     *
19
     * @param $attributes
20
     */
21
    protected function setLocalesAttributes($attributes)
22
    {
23
        View::composer(['partials.alternates', 'partials.locales'], function (\Illuminate\View\View $view) use ($attributes) {
24
            $view->withAttributes($attributes);
25
        });
26
    }
27
28
    /**
29
     * Push translatable object in order to correctly localize slugs.
30
     *
31
     * @param $translatable
32
     */
33
    protected function setTranslatable($translatable)
34
    {
35
        View::composer(['partials.alternates', 'partials.locales'], function (\Illuminate\View\View $view) use ($translatable) {
36
            $view->withTranslatable($translatable);
37
        });
38
    }
39
}
40