WorkflowStateController::show()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Jawaraegov\Workflows\Http\Controllers;
4
5
use App\Http\Controllers\Controller;
6
use Illuminate\Http\Request;
7
use Jawaraegov\Workflows\Facades\Workflow;
8
use Jawaraegov\Workflows\Models\WorkflowTransition;
9
use Jawaraegov\Workflows\Models\WorkflowState;
10
use That0n3guy\Transliteration;
11
12
class WorkflowStateController extends Controller
13
{
14
    /**
15
     * Display a listing of the resource.
16
     *
17
     * @return Response
18
     */    
19
    public function index()
20
    {
21
        $states = WorkflowState::paginate(10);
22
                        
23
        return view('workflow.state.index',compact('states'));
24
    }
25
    
26
    /**
27
     * Show the form for creating a new resource.
28
     *
29
     * @return Response
30
     */
31
    public function create()
32
    {
33
        return view('workflow.state.create');
34
    }
35
    
36
    /**
37
     * Store a newly created resource in storage.
38
     *
39
     * @return Response
40
     */
41 View Code Duplication
    public function store(Request $request)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
42
    {
43
        $name = \Transliteration::clean_filename(strtolower($request->label));
44
        $label = $request->label;
45
46
        try
47
        {
48
            WorkflowState::create([
49
                            'name' => $name,
50
                            'label' => $label,
51
                ]);
52
        }
53
        catch(\Illuminate\Database\QueryException $e){
0 ignored issues
show
Bug introduced by
The class Illuminate\Database\QueryException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
54
            // do what you want here with $e->getMessage();
55
            return redirect()->route('state')->with('message', 'Error');
56
        }
57
58
        return redirect()->route('state')->with('message', 'Add data success');
59
    }
60
    
61
    /**
62
     * Display the specified resource.
63
     *
64
     * @param  int  $id
65
     * @return Response
66
     */
67
    public function show($id)
68
    {
69
        //
70
    }
71
    
72
    /**
73
     * Show the form for editing the specified resource.
74
     *
75
     * @param  int  $id
76
     * @return Response
77
     */
78
    public function edit($id)
79
    {
80
        $state = WorkflowState::where('id',$id)->first();
81
        
82
        return view('workflow.state.edit',['state' => $state]);
83
    }
84
    
85
    /**
86
     * Update the specified resource in storage.
87
     *
88
     * @param  int  $id
89
     * @return Response
90
     */
91 View Code Duplication
    public function update(Request $request, $id)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
92
    {
93
        $name = \Transliteration::clean_filename(strtolower($request->label));
94
        $label = $request->label;
95
96
        try
97
        {
98
          WorkflowState::where('id',$id)->update(['label' => $label, 'name' => $name]);
99
        }
100
        catch(\Illuminate\Database\QueryException $e){
0 ignored issues
show
Bug introduced by
The class Illuminate\Database\QueryException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
101
            // do what you want here with $e->getMessage();
102
            return redirect()->route('state')->with('message', 'Error');
103
        }
104
105
        return redirect()->route('state')->with('message', 'Update data success');
106
    }
107
    /**
108
     * Activete the specified resource from storage.
109
     *
110
     * @param  int  $id
111
     * @return Response
112
     */
113
    public function Active($id){
114
        WorkflowState::where('id',$id)->update(['status' => 1]);
115
116
        return redirect()->back();
117
    }
118
    /**
119
     * Deactivete the specified resource from storage.
120
     *
121
     * @param  int  $id
122
     * @return Response
123
     */
124
    public function DeActive($id){
125
        WorkflowState::where('id',$id)->update(['status' => 0]);
126
127
        return redirect()->back();
128
    }
129
    
130
    /**
131
     * Remove the specified resource from storage.
132
     *
133
     * @param  int  $id
134
     * @return Response
135
     */
136
    public function destroy($id)
137
    {
138
        //
139
    }
140
}
141