1
|
|
|
<?php namespace Bantenprov\YankesInfoKamar\Http\Controllers; |
2
|
|
|
|
3
|
|
|
use App\Http\Controllers\Controller; |
4
|
|
|
use Illuminate\Http\Request; |
5
|
|
|
use Bantenprov\YankesInfoKamar\Facades\InfoKamar; |
6
|
|
|
use Bantenprov\YankesInfoKamar\Models\Kelasrawat; |
7
|
|
|
use Bantenprov\YankesInfoKamar\Requests\StoreKelas; |
8
|
|
|
use Bantenprov\YankesInfoKamar\Requests\UpdateKelas; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* The InfoKamarController class. |
12
|
|
|
* |
13
|
|
|
* @package Supriyanih\InfoKamar |
14
|
|
|
* @author supriyanih <[email protected]> |
15
|
|
|
*/ |
16
|
|
|
class KelasController extends Controller |
17
|
|
|
{ |
18
|
|
|
|
19
|
|
|
public function index(){ |
20
|
|
|
|
21
|
|
|
$kelas = Kelasrawat::paginate(5); |
22
|
|
|
|
23
|
|
|
return view('info-kamar::kelas.index', compact('kelas')); |
24
|
|
|
|
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function create() |
28
|
|
|
{ |
29
|
|
|
return view('info-kamar::kelas.create'); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
View Code Duplication |
public function store(StoreKelas $req) |
|
|
|
|
33
|
|
|
{ |
34
|
|
|
$this->validate($req,[ |
35
|
|
|
'kode_kelas' =>'required', |
36
|
|
|
'nama_kelas' => 'required' |
37
|
|
|
]); |
38
|
|
|
|
39
|
|
|
$kelas = new Kelasrawat; |
40
|
|
|
$kelas->kode_kelas = $req->kode_kelas; |
41
|
|
|
$kelas->nama_kelas = $req->nama_kelas; |
42
|
|
|
$kelas->save(); |
43
|
|
|
|
44
|
|
|
\Session::flash('flash_message', 'Kelas Rawat Inap Berhasil Di buat'); |
45
|
|
|
return redirect()->route('kelas.index'); |
46
|
|
|
|
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function show($id) |
50
|
|
|
{ |
51
|
|
|
$kelas = Kelasrawat::findOrFail($id); |
52
|
|
|
return view('info-kamar::kelas.show', compact('kelas')); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function edit($id) |
56
|
|
|
{ |
57
|
|
|
$kelas = Kelasrawat::findOrFail($id); |
58
|
|
|
|
59
|
|
|
return view('info-kamar::kelas.edit', compact('kelas')); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
View Code Duplication |
public function update(UpdateKelas $request, $id) |
|
|
|
|
63
|
|
|
{ |
64
|
|
|
$this->validate($request,[ |
65
|
|
|
'kode_kelas' => 'required', |
66
|
|
|
'nama_kelas' => 'required', |
67
|
|
|
]); |
68
|
|
|
$kelas = Kelasrawat::findOrFail($id); |
69
|
|
|
$kelas->kode_kelas = $request->kode_kelas; |
70
|
|
|
$kelas->nama_kelas = $request->nama_kelas; |
71
|
|
|
$kelas->save(); |
72
|
|
|
\Session::flash('flash_message', 'Kelas Rawat Inap Berhasil di UPDATE'); |
73
|
|
|
return redirect()->route('kelas.index'); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function destroy($id) |
77
|
|
|
{ |
78
|
|
|
|
79
|
|
|
Kelasrawat::find($id)->delete(); |
80
|
|
|
return redirect()->route('kelas.index'); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
} |
84
|
|
|
|
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.