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 @@
namespace App\Http\Controllers;
use App\Homestay;
use App\RequestHomestay;
use App\Room;
use Illuminate\Http\Request;
use App\User;
use Validator;
......@@ -124,9 +126,47 @@ class AdminController extends Controller
}
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 @@
<td>Ditolak</td>
@elseif($a->status==0)
<td>
<form action="{{url('listPengajuanFasilitas/'.$a->idPengajuan)}}" method="post">
<form action="{{url('listPengajuanHomestay/'.$a->id)}}" method="post">
{{csrf_field()}}
<input type="hidden" name="_method" value="PUT">
<button type="submit" class="btn btn-info"><i class="glyphicon glyphicon-apple"> Terima</i></button>
</form>
<td>
<form action="{{url('requestFasilitass/'.$a->idPengajuan)}}" method="post">
<form action="{{url('listPengajuanHomestay/'.$a->id)}}" method="post">
{{csrf_field()}}
<input type="hidden" name="_method" value="PUT">
<button type="submit" class="btn btn-danger"><i class="glyphicon glyphicon-trash"> Tolak</i></button>
......
......@@ -56,10 +56,10 @@ Route::get('requestFasilitas','AdminController@RequestFasilitas');
Route::get('pengajuanHomestay','OwnerController@pengajuan');
Route::post('pengajuanHomestay','OwnerController@storePengajuan');
Route::get('listPengajuan','OwnerController@listPengajuan');
Route::get('listPengajuanFasilitas','OwnerController@listPengajuanFasilitas');
Route::get('listPengajuanHomestay','OwnerController@listPengajuanFasilitas');
Route::put('requestFasilitas/{id}','AdminController@UpdateRequestFasilitas');
Route::put('requestFasilitass/{id}','AdminController@UpdateRequestFasilitass');
Route::put('listPengajuanFasilitas/{id}','AdminController@AccPengajuanHomestay');
Route::put('listPengajuanHomestay/{id}','AdminController@AccPengajuanHomestay');
Route::resource('profile','ProfileController');
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