Completed
Push — master ( a7b5fe...4405b1 )
by wen
03:16
created

AdminController   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 5
Bugs 1 Features 1
Metric Value
wmc 11
lcom 0
cbo 3
dl 0
loc 58
rs 10
c 5
b 1
f 1

11 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 4 1
A getList() 0 4 1
A config() 0 4 1
A create() 0 4 1
A store() 0 4 1
A edit() 0 4 1
A update() 0 3 1
A delete() 0 5 1
A batchDelete() 0 3 1
A forceDelete() 0 5 1
A restore() 0 5 1
1
<?php
2
3
namespace Sco\Admin\Http\Controllers;
4
5
use Illuminate\Routing\Controller;
6
use Sco\Admin\Contracts\ModelFactoryInterface;
7
8
class AdminController extends Controller
9
{
10
    public function index()
11
    {
12
        return view('admin::app');
13
    }
14
15
    public function getList(ModelFactoryInterface $modelFactory)
16
    {
17
        return $modelFactory->get();
18
    }
19
20
    public function config(ModelFactoryInterface $modelFactory)
21
    {
22
        return $modelFactory->getConfigManager();
23
    }
24
25
    public function create()
26
    {
27
        return view('admin::app');
28
    }
29
30
    public function store(ModelFactoryInterface $modelFactory)
31
    {
32
        $modelFactory->store();
33
    }
34
35
    public function edit(ModelFactoryInterface $modelFactory, $id)
36
    {
37
        dd($modelFactory->find($id));
0 ignored issues
show
Bug introduced by
The method find() does not seem to exist on object<Sco\Admin\Contracts\ModelFactoryInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
38
    }
39
40
    public function update()
41
    {
42
    }
43
44
    public function delete(ModelFactoryInterface $modelFactory, $id)
45
    {
46
        $modelFactory->delete($id);
47
        return response()->json(['message' => 'ok']);
48
    }
49
50
    public function batchDelete(ModelFactoryInterface $modelFactory)
0 ignored issues
show
Unused Code introduced by
The parameter $modelFactory is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
51
    {
52
    }
53
54
    public function forceDelete(ModelFactoryInterface $modelFactory, $id)
55
    {
56
        $modelFactory->forceDelete($id);
57
        return response()->json(['message' => 'ok']);
58
    }
59
60
    public function restore(ModelFactoryInterface $modelFactory, $id)
61
    {
62
        $modelFactory->restore($id);
63
        return response()->json(['message' => 'ok']);
64
    }
65
}
66