Passed
Push — develop ( 5f0aa7...736d84 )
by Septianata
04:40
created

ConfigurationController   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 83
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 13
c 1
b 0
f 0
dl 0
loc 83
ccs 0
cts 19
cp 0
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 3 1
A create() 0 3 1
A store() 0 5 1
A edit() 0 3 1
A destroy() 0 5 1
A datatable() 0 5 1
A update() 0 5 1
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Http\Resources\DataTables\ConfigurationResource;
6
use App\Models\Configuration;
7
use Illuminate\Http\Request;
8
use Yajra\DataTables\Facades\DataTables;
9
10
class ConfigurationController extends Controller
11
{
12
    /**
13
     * Display a listing of the resource.
14
     *
15
     * @return \Illuminate\Contracts\Support\Renderable
16
     */
17
    public function index()
18
    {
19
        return view('configuration.index');
20
    }
21
22
    /**
23
     * Return datatable server side response.
24
     *
25
     * @return \Illuminate\Http\JsonResponse
26
     */
27
    public function datatable()
28
    {
29
        return DataTables::eloquent(Configuration::query())
30
            ->setTransformer(fn ($model) => ConfigurationResource::make($model)->resolve())
31
            ->toJson();
32
    }
33
34
    /**
35
     * Show the form for creating a new resource.
36
     *
37
     * @return \Illuminate\Contracts\Support\Renderable
38
     */
39
    public function create()
40
    {
41
        return view('configuration.create');
42
    }
43
44
    /**
45
     * Store a newly created resource in storage.
46
     *
47
     * @param  \Illuminate\Http\Request  $request
48
     * @return \Illuminate\Http\RedirectResponse
49
     */
50
    public function store(Request $request)
51
    {
52
        Configuration::create($request->all());
53
54
        return redirect()->route('configuration.index');
55
    }
56
57
    /**
58
     * Show the form for editing the specified resource.
59
     *
60
     * @param  \App\Models\Configuration  $configuration
61
     * @return \Illuminate\Contracts\Support\Renderable
62
     */
63
    public function edit(Configuration $configuration)
64
    {
65
        return view('configuration.edit', compact('configuration'));
66
    }
67
68
    /**
69
     * Update the specified resource in storage.
70
     *
71
     * @param  \Illuminate\Http\Request  $request
72
     * @param  \App\Models\Configuration  $configuration
73
     * @return \Illuminate\Http\RedirectResponse
74
     */
75
    public function update(Request $request, Configuration $configuration)
76
    {
77
        $configuration->update($request->all());
78
79
        return redirect()->route('configuration.index');
80
    }
81
82
    /**
83
     * Remove the specified resource from storage.
84
     *
85
     * @param  \App\Models\Configuration  $configuration
86
     * @return \Illuminate\Http\RedirectResponse
87
     */
88
    public function destroy(Configuration $configuration)
89
    {
90
        $configuration->delete();
91
92
        return redirect()->route('configuration.index');
93
    }
94
}
95