Commit d23344dd by Juliper

generate homestay dan kamar

parent 077da9b7
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Homestay extends Model
{
protected $table = "homestay";
protected $fillable = [
'idPemilik', 'nama', 'owner','alamat','jumlahKamar','harga','status',
];
}
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Homestay;
use App\RequestHomestay; use App\RequestHomestay;
use App\Room;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\User; use App\User;
use Validator; use Validator;
...@@ -124,9 +126,47 @@ class AdminController extends Controller ...@@ -124,9 +126,47 @@ class AdminController extends Controller
} }
public function AccPengajuanHomestay($id){ public function AccPengajuanHomestay($id){
$RH = RequestHomestay::where('idPengajuan',$id)->first()->get();
dd("masuk gan",$id,$RH); //dd("masuk gan");
$RH = RequestHomestay::find($id);
$RH->status = 1;
$data = DB::table('pengajuan_homestay')
->join('pemilikhomestay','pemilikhomestay.id','=','pengajuan_homestay.idPemilikHomestay')
->select('pemilikhomestay.nama','pemilikhomestay.alamat')
->where('pemilikhomestay.id','=',$RH->idPemilikHomestay)
->get();
//dd($data[0]->nama,$data[0]->alamat);
$hs = new Homestay();
$hs->idPemilik = $RH->idPemilikHomestay;
$hs->nama = $RH->namaHomestay;
$hs->owner = $data[0]->nama ;
$hs->alamat = $data[0]->alamat;
$hs->jumlahKamar = $RH->jumlahKamar;
$hs->harga = 150000;
$hs->status='----';
$hs->save();
$idHts = DB::table('homestay')
->select('homestay.*')
->where('homestay.owner','=',$data[0]->nama)
->get();
//dd("sampai sini dulu",$idHts);
for ($i = 1;$i<=$RH->jumlahKamar;$i++){
$km = new Room();
$km->idHomestay = $idHts[0]->id;
$km->nomor_kamar = $i;
$km->jumlah_bed = 2;
$km->save();
}
$RH->update();
return redirect('requestHomestay');
} }
......
...@@ -54,13 +54,13 @@ ...@@ -54,13 +54,13 @@
<td>Ditolak</td> <td>Ditolak</td>
@elseif($a->status==0) @elseif($a->status==0)
<td> <td>
<form action="{{url('listPengajuanFasilitas/'.$a->idPengajuan)}}" method="post"> <form action="{{url('listPengajuanHomestay/'.$a->id)}}" method="post">
{{csrf_field()}} {{csrf_field()}}
<input type="hidden" name="_method" value="PUT"> <input type="hidden" name="_method" value="PUT">
<button type="submit" class="btn btn-info"><i class="glyphicon glyphicon-apple"> Terima</i></button> <button type="submit" class="btn btn-info"><i class="glyphicon glyphicon-apple"> Terima</i></button>
</form> </form>
<td> <td>
<form action="{{url('requestFasilitass/'.$a->idPengajuan)}}" method="post"> <form action="{{url('listPengajuanHomestay/'.$a->id)}}" method="post">
{{csrf_field()}} {{csrf_field()}}
<input type="hidden" name="_method" value="PUT"> <input type="hidden" name="_method" value="PUT">
<button type="submit" class="btn btn-danger"><i class="glyphicon glyphicon-trash"> Tolak</i></button> <button type="submit" class="btn btn-danger"><i class="glyphicon glyphicon-trash"> Tolak</i></button>
......
...@@ -56,10 +56,10 @@ Route::get('requestFasilitas','AdminController@RequestFasilitas'); ...@@ -56,10 +56,10 @@ Route::get('requestFasilitas','AdminController@RequestFasilitas');
Route::get('pengajuanHomestay','OwnerController@pengajuan'); Route::get('pengajuanHomestay','OwnerController@pengajuan');
Route::post('pengajuanHomestay','OwnerController@storePengajuan'); Route::post('pengajuanHomestay','OwnerController@storePengajuan');
Route::get('listPengajuan','OwnerController@listPengajuan'); Route::get('listPengajuan','OwnerController@listPengajuan');
Route::get('listPengajuanFasilitas','OwnerController@listPengajuanFasilitas'); Route::get('listPengajuanHomestay','OwnerController@listPengajuanFasilitas');
Route::put('requestFasilitas/{id}','AdminController@UpdateRequestFasilitas'); Route::put('requestFasilitas/{id}','AdminController@UpdateRequestFasilitas');
Route::put('requestFasilitass/{id}','AdminController@UpdateRequestFasilitass'); Route::put('requestFasilitass/{id}','AdminController@UpdateRequestFasilitass');
Route::put('listPengajuanFasilitas/{id}','AdminController@AccPengajuanHomestay'); Route::put('listPengajuanHomestay/{id}','AdminController@AccPengajuanHomestay');
Route::resource('profile','ProfileController'); Route::resource('profile','ProfileController');
Route::get('reqFasilitas','OwnerController@requestFasilitas'); Route::get('reqFasilitas','OwnerController@requestFasilitas');
......
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