Passed
Push — ft/package ( 5ee474...180175 )
by Philippe
05:16 queued 12s
created

DemoPageController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 58.33%

Importance

Changes 0
Metric Value
dl 0
loc 28
ccs 7
cts 12
cp 0.5833
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 9 2
A show() 0 13 3
1
<?php
2
3
namespace Thinktomorrow\Chief\Demo\Http\Controllers;
4
5
use Thinktomorrow\Chief\App\Http\Controllers\Controller;
6
use Thinktomorrow\Chief\Pages\Application\CreatePage;
7
use Thinktomorrow\Chief\Pages\Page;
8
use Thinktomorrow\Chief\Pages\PageRepository;
0 ignored issues
show
Bug introduced by
The type Thinktomorrow\Chief\Pages\PageRepository was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Illuminate\Http\Request;
10
use Illuminate\Http\Response;
11
use Illuminate\Validation\Rule;
12
use Thinktomorrow\AssetLibrary\Models\Asset;
13
use Thinktomorrow\Chief\App\Http\Requests\PageCreateRequest;
14
use Thinktomorrow\Chief\Pages\Application\UpdatePage;
15
use Thinktomorrow\Chief\App\Http\Requests\PageUpdateRequest;
16
use Thinktomorrow\Chief\Common\Traits\CheckPreviewTrait;
17
18
class DemoPageController extends Controller
19
{
20
    use CheckPreviewTrait;
21
22
    public function index()
23
    {
24
        if ($this->isPreviewAllowed()) {
25
            $pages = Page::all();
26
        } else {
27
            $pages = Page::getAllPublished();
28
        }
29
30
        return view('demo::index', compact('pages'));
31
    }
32
33 2
    public function show(Request $request)
34
    {
35 2
        if ($this->isPreviewAllowed()) {
36 1
            $page = Page::findBySlug($request->slug);
37
        } else {
38 1
            $page = Page::findPublishedBySlug($request->slug);
39
        }
40
41 2
        if (!$page) {
42 1
            return redirect()->route('demo.pages.index')->with('note.default', 'Geen resultaten gevonden.');
43
        }
44
45 1
        return view('demo::pagedetail', compact('page'));
46
    }
47
}
48