1
|
|
|
<?php namespace WITR\Http\Controllers\Admin; |
2
|
|
|
|
3
|
|
|
use WITR\Http\Requests\Admin\Eboard as Requests; |
4
|
|
|
use WITR\Http\Controllers\Controller; |
5
|
|
|
use WITR\Eboard; |
6
|
|
|
use Input; |
7
|
|
|
|
8
|
|
|
use Illuminate\Http\Request; |
9
|
|
|
|
10
|
|
View Code Duplication |
class EboardController extends Controller { |
|
|
|
|
11
|
|
|
|
12
|
|
|
public function __construct() |
13
|
|
|
{ |
14
|
|
|
$this->middleware('auth'); |
15
|
|
|
$this->middleware('editor'); |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Display a listing of the resource. |
20
|
|
|
* |
21
|
|
|
* @return Response |
22
|
|
|
*/ |
23
|
|
|
public function index() |
24
|
|
|
{ |
25
|
|
|
$eboard = Eboard::orderBy('position', 'asc')->get(); |
26
|
|
|
return view('admin.eboard.index', ['eboard' => $eboard]); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Display a listing of the resource. |
31
|
|
|
* |
32
|
|
|
* @return Response |
33
|
|
|
*/ |
34
|
|
|
public function new_position() |
35
|
|
|
{ |
36
|
|
|
return view('admin.eboard.create'); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Save the new eboard position. |
41
|
|
|
* |
42
|
|
|
*@return Response |
43
|
|
|
*/ |
44
|
|
|
public function create(Requests\CreateRequest $request) |
45
|
|
|
{ |
46
|
|
|
$input = $request->all(); |
47
|
|
|
$position = new Eboard($input); |
48
|
|
|
$position->save(); |
49
|
|
|
return redirect()->route('admin.eboard.index') |
50
|
|
|
->with('success', 'Position Saved!'); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function edit($id) |
54
|
|
|
{ |
55
|
|
|
$position = Eboard::findOrFail($id); |
56
|
|
|
|
57
|
|
|
return view('admin.eboard.edit', ['eboard' => $position]); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function update(Requests\UpdateRequest $request, $id) |
61
|
|
|
{ |
62
|
|
|
$position = Eboard::findOrFail($id); |
63
|
|
|
$position->fill($request->all()); |
64
|
|
|
$position->save(); |
65
|
|
|
return redirect()->route('admin.eboard.index') |
66
|
|
|
->with('success', 'Position Saved!'); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function delete($id) |
70
|
|
|
{ |
71
|
|
|
Eboard::destroy($id); |
72
|
|
|
return redirect()->route('admin.eboard.index') |
73
|
|
|
->with('success', 'Position Deleted!'); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
} |
77
|
|
|
|
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.