Commit e1f85c35 by Juliper

back to owner

parent 5f547409
......@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use App\RequestFasilitas;
use App\RequestHomestay;
use App\Room;
use Illuminate\Http\Request;
use App\User;
use App\Owner;
......@@ -18,16 +19,35 @@ class OwnerController extends Controller
return view('adminlte::layouts.owner.home');
}
public function updateRoom(Request $request, $id){
$dataKamar = Room::find($id);
$dataKamar->jumlah_bed = $request['jumlah_bed'];
$dataKamar->fasilitas = $request['fasilitas'];
if($request->file('foto')==null){
$dataKamar->foto = $dataKamar->foto;
}else{
$file = $request->file('foto');
$fileName = $file->getClientOriginalName();
$request->file('foto')->move("img/",$fileName);
$dataKamar->gambar = $fileName;
}
$dataKamar->update();
return redirect('daftarKamar');
}
public function editRoom($id){
$dataKamar = Room::find($id);
return view('adminlte::layouts.owner.EditRoom')->with('data',$dataKamar);
}
public function daftarKamar(){
/*$dataTrans = DB::table('homestay')
->join('transaksi','homestay.id','=','transaksi.id_homestay')
->join('pemilikhomestay','homestay.idPemilik','=','pemilikhomestay.id')
->select('transaksi.*','pemilikhomestay.nama','pemilikhomestay.noRekening')
->where('transaksi.id_pelanggan','=',$data[0]->id)
->get();
*/
$pem = DB::table('pemilikhomestay')
$dataPemilik = DB::table('pemilikhomestay')
->select('pemilikhomestay.*')
->where('pemilikhomestay.id_Akun','=',Auth::user()->id)
->get();
......@@ -35,11 +55,11 @@ class OwnerController extends Controller
$data = DB::table('homestay')
->join('pemilikhomestay','homestay.idPemilik','pemilikhomestay.id')
->join('kamar','homestay.id','=','kamar.idHomestay')
->select('kamar.*','homestay.*','pemilikhomestay.*')
->where('pemilikhomestay.id','=',$pem[0]->id)
->select('kamar.*')
->where('pemilikhomestay.id','=',$dataPemilik[0]->id)
->get();
dd("masuk gan",Auth::user()->id,$data,$pem);
//dd($data);
return view('adminlte::layouts.owner.listRoom')->with('data',$data)->with('count',$data->count());
}
public function listTransaction(){
......
......@@ -26,13 +26,13 @@
</div>
@endif
<form action="" method="post" enctype="multipart/form-data">
<form action="{{url('editRoom/'.$data->id)}}" method="post" enctype="multipart/form-data">
<input type="hidden" name="_method" value="PUT">
<!-- {{csrf_field()}} -->
<!-- <label>Nama</label>
<input type="text" name="nama" value="" id="nama" class="form-control"> -->
{{csrf_field()}}
<label>Jumlah Bed</label>
<input class="form-control" value="{{$data->jumlah_bed}}" name="jumlah_bed">
<label>Fasilitas</label>
<textarea name="fasilitas" value="" id="fasilitas" class="form-control" style="height:200px;"></textarea>
<textarea name="fasilitas" value="{{$data->fasilitas}}" id="fasilitas" class="form-control" style="height:200px;"></textarea>
<label>Foto</label>
<input type="file" value="Browse" name="foto" id="picture" >
......
......@@ -7,7 +7,7 @@
@section('main-content')
<div class="container-fluid spark-screen">
<div class="row">
<div class="col-md-10 col-md-offset-1">
<div class="col-md-12">
<div class="panel panel-default">
<div id="app">
......@@ -41,18 +41,22 @@
<th>No Kamar</th>
<th>Jumlah Bed</th>
<td>Detail</td>
<td>Edit</td>
<td>Delete</td>
<td>Foto</td>
<td colspan="2">Aksi</td>
</tr>
@foreach($data as $a)
<tr>
<td>{{$a->nomor_kamar}}</td>
<td>{{$a->jumlah_bed}}</td>
<td>
<a href="{{url('room/'.$a->id)}}" class="btn btn-primary"><i class="glyphicon glyphicon-eye-open"></i></a>
<td>{{$a->fasilitas}}</td>
<td>@if($a->gambar == null)
<img alt="Belum ada foto">
@else
<img src="/img/{{$a->gambar}}">
@endif
</td>
<td>
<a href="{{url('room/'.$a->id.'/edit')}}" class="btn btn-primary"><i class="glyphicon glyphicon-edit"></i></a>
<a href="{{url('editRoom/'.$a->id)}}" class="btn btn-primary"><i class="glyphicon glyphicon-edit"></i></a>
</td>
<td>
<form action="{{url('room/'.$a->id)}}" method="POST">
......@@ -62,8 +66,6 @@
</form>
</td>
</tr>
@endforeach
</table>
......
......@@ -33,7 +33,6 @@
<li><a href="{{url('listowner')}}"><i class='fa fa-list'></i> <span>Melihat Daftar Owner</span></a></li>
@elseif(Auth::user()->role=="Owner")
<li><a href="{{url('EditRoom')}}"><i class='fa fa-list'></i> <span>Edit Room</span></a></li>
<li><a href="{{url('pesanan')}}"><i class='fa fa-list'></i> <span>Daftar Pesanan</span></a></li>
<li><a href="{{url('reqFasilitas')}}"><i class='fa fa-list'></i> <span>Request Fasilitas</span></a></li>
<li><a href="#"><i class='fa fa-list'></i> <span>Add Book Manual</span></a></li>
......
......@@ -47,9 +47,9 @@ Route::group(['middleware' => 'auth'], function () {
});
Route::get('EditRoom', function(){
/*Route::get('EditRoom', function(){
return view('adminlte::layouts.owner.EditRoom');
});
});*/
Route::get('AddBook', function(){
return view('adminlte::layouts.owner.AddBookManual');
});
......@@ -57,7 +57,8 @@ Route::get('DataPemesanan', function(){
return view('adminlte::layouts.admin.dataPemesanan');
});
Route::put('editRoom/{id}','OwnerController@updateRoom');
Route::get('editRoom/{id}','OwnerController@editRoom');
Route::get('daftarKamar','OwnerController@daftarKamar');
Route::get('pesanan','OwnerController@listTransaction');
Route::put('upload/{id}','CustomerController@upload');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment