1
|
|
|
<?php namespace WITR\Http\Controllers\Admin; |
2
|
|
|
|
3
|
|
|
use WITR\Http\Requests\Admin\Video as Requests; |
4
|
|
|
use WITR\Http\Controllers\Controller; |
5
|
|
|
use WITR\Video; |
6
|
|
|
use Input; |
7
|
|
|
|
8
|
|
|
use Illuminate\Http\Request; |
9
|
|
|
|
10
|
|
View Code Duplication |
class VideoController 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 Videos. |
20
|
|
|
* |
21
|
|
|
* @return Response |
22
|
|
|
*/ |
23
|
|
|
public function index() |
24
|
|
|
{ |
25
|
|
|
$videos = Video::orderBy('artist', 'asc')->get(); |
26
|
|
|
return view('admin.videos.index', ['videos' => $videos]); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Display a listing of the resource. |
31
|
|
|
* |
32
|
|
|
* @return Response |
33
|
|
|
*/ |
34
|
|
|
public function new_review() |
35
|
|
|
{ |
36
|
|
|
return view('admin.videos.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
|
|
|
$video = new Video($input); |
48
|
|
|
$video->save(); |
49
|
|
|
return redirect()->route('admin.videos.index') |
50
|
|
|
->with('success', 'Video Review Saved!'); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function edit($id) |
54
|
|
|
{ |
55
|
|
|
$video = Video::findOrFail($id); |
56
|
|
|
|
57
|
|
|
return view('admin.videos.edit', ['video' => $video]); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function update(Requests\UpdateRequest $request, $id) |
61
|
|
|
{ |
62
|
|
|
$video = Video::findOrFail($id); |
63
|
|
|
$video->fill($request->all()); |
64
|
|
|
$video->save(); |
65
|
|
|
return redirect()->route('admin.videos.index') |
66
|
|
|
->with('success', 'Video Review Saved!'); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function delete($id) |
70
|
|
|
{ |
71
|
|
|
Video::destroy($id); |
72
|
|
|
return redirect()->route('admin.videos.index') |
73
|
|
|
->with('success', 'Video Review 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.