BedController::index()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 7
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 7
loc 7
rs 9.4285
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\Ruangrawat;
7
use Bantenprov\YankesInfoKamar\Models\Tempattidur;
8
use Bantenprov\YankesInfoKamar\Requests\StoreBed;
9
use Bantenprov\YankesInfoKamar\Requests\UpdateBed;
10
11
12 View Code Duplication
class BedController extends Controller
0 ignored issues
show
Duplication introduced by
This class 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...
13
{
14
15
 public function index(){
16
17
 	$bed = Tempattidur::with('ranjang')->paginate(5);
18
19
 	return view('info-kamar::bed.index', compact('bed'));
20
21
 }
22
23
 public function create()
24
 {
25
   $ruang = Ruangrawat::all();
26
 	return view('info-kamar::bed.create', compact('ruang'));
27
 }
28
29
 public function store(StoreBed $req)
30
 {
31
 	$this->validate($req,[
32
    'ruang_id' => 'required',
33
 		'kode_bed' =>'required'
34
 	]);
35
36
 	$bed = new Tempattidur;
37
    $bed->ruang_id = $req->ruang_id;
38
   	 $bed->kode_bed = $req->kode_bed;
39
   	 $bed->status = 1;
40
   	 $bed->save();
41
42
   	  \Session::flash('flash_message', 'bed Rawat Inap Berhasil Di buat');
43
        return redirect()->route('bed.index');
44
45
 }
46
47
 public function show($id)
48
    {
49
        $bed = Tempattidur::with('ranjang')->findOrFail($id);
50
        return view('info-kamar::bed.show', compact('bed'));
51
    }
52
53
 public function edit($id)
54
   {
55
     $ruang = Ruangrawat::all();
56
   	$bed = Tempattidur::findOrFail($id);
57
58
   		return view('info-kamar::bed.edit', compact('bed','ruang'));
59
   }
60
61
   public function update(UpdateBed $request, $id)
62
   {
63
   		$this->validate($request,[
64
        'ruang_id' => 'required',
65
   		'kode_bed' => 'required',
66
   		'status' => 'required',
67
   	]);
68
   		$bed = Tempattidur::findOrFail($id);
69
      $bed->ruang_id = $request->ruang_id;
70
   		$bed->kode_bed = $request->kode_bed;
71
	   	 $bed->status = $request->status;
72
	   	 $bed->save();
73
   		\Session::flash('flash_message', 'bed Rawat Inap Berhasil di UPDATE');
74
        return redirect()->route('bed.index');
75
   }
76
77
   public function destroy($id)
78
    {
79
80
        Tempattidur::find($id)->delete();
81
        return redirect()->route('bed.index');
82
    }
83
84
}
85