Code Duplication    Length = 25-25 lines in 2 locations

src/Traits/WorkflowTransitionTrait.php 1 location

@@ 65-89 (lines=25) @@
62
        return view('workflow::workflow.transitionedit',['transition' => $transition, 'states' => $states]);
63
    }
64
65
    public static function transitionUpdate($request = array(), $id)
66
    {
67
        $name = str_replace('_','-',\Transliteration::clean_filename(strtolower($request->label)));
68
        $label = $request->label;
69
        $from = join(',',$request->from);
70
        $to = $request->to;
71
72
        try
73
        {
74
          WorkflowTransition::where('id',$id)->update([
75
                                                      'label' => $label,
76
                                                      'name' => $name,
77
                                                      'from' => $from,
78
                                                      'to' => $to
79
                                                    ]);
80
        }
81
        catch(\Illuminate\Database\QueryException $e){
82
            // do what you want here with $e->getMessage();
83
            return redirect()->route('transition')->with('message', 'Error');
84
        }
85
86
87
88
        return redirect()->route('transition')->with('message', 'Update data success');
89
    }
90
91
    public static function transitionActive($id){
92
        WorkflowTransition::where('id',$id)->update(['status' => 1]);

src/Http/Controllers/WorkflowTransitionController.php 1 location

@@ 70-94 (lines=25) @@
67
        return view('workflow.transitionedit',['transition' => $transition, 'states' => $states]);
68
    }
69
70
    public function update(Request $request, $id)
71
    {
72
        $name = str_replace('_','-',\Transliteration::clean_filename(strtolower($request->label)));
73
        $label = $request->label;
74
        $from = $request->from;
75
        $to = $request->to;
76
77
        try
78
        {
79
          WorkflowTransition::where('id',$id)->update([
80
                                                      'label' => $label,
81
                                                      'name' => $name,
82
                                                      'from' => $from,
83
                                                      'to' => $to
84
                                                    ]);
85
        }
86
        catch(\Illuminate\Database\QueryException $e){
87
            // do what you want here with $e->getMessage();
88
            return redirect()->route('transition')->with('message', 'Error');
89
        }
90
91
92
93
        return redirect()->route('transition')->with('message', 'Update data success');
94
    }
95
96
    public function Active($id){
97
        WorkflowTransition::where('id',$id)->update(['status' => 1]);