Commit 7745e815 by Juliper

no message

parent 6dc43c0c
...@@ -35,6 +35,7 @@ class RegisterController extends Controller ...@@ -35,6 +35,7 @@ class RegisterController extends Controller
*/ */
public function showRegistrationForm() public function showRegistrationForm()
{ {
dd('masyk diads');
return view('adminlte::auth.register'); return view('adminlte::auth.register');
} }
...@@ -52,6 +53,7 @@ class RegisterController extends Controller ...@@ -52,6 +53,7 @@ class RegisterController extends Controller
*/ */
public function __construct() public function __construct()
{ {
$this->middleware('guest'); $this->middleware('guest');
} }
......
...@@ -119,34 +119,6 @@ class CustomerController extends Controller ...@@ -119,34 +119,6 @@ class CustomerController extends Controller
return view('adminlte::layouts.customers.profiles')->with('data',$data[0]); return view('adminlte::layouts.customers.profiles')->with('data',$data[0]);
} }
//Menyimpan data Pelanggan disaat melakukan Pendaftaran
public function registerStore(Request $data){
$user = new User();
$user->name = $data['name'];
$user->username = $data['username'];
$user->email = $data['email'];
$user->password = bcrypt($data['password']);
$user->role = "Customer";
$user->foto = "gravatar.png";
$user->save();
$dataPel = DB::table('users')
->select('users.id')
->where('users.username','=',$data['username'])
->get();
$cus = new Customer();
$cus->id_akun = $dataPel[0]->id;
$cus->nama = $data['name'] ;
$cus->alamat = "---";
$cus->no_telepon = "---";
$cus->pekerjaan = "---";
$cus->save();
return redirect('login');
}
//Mengakses Halaman untuk mengedit/mengubah profile //Mengakses Halaman untuk mengedit/mengubah profile
public function editProfile($id){ public function editProfile($id){
$data = Customer::find($id); $data = Customer::find($id);
...@@ -206,6 +178,19 @@ class CustomerController extends Controller ...@@ -206,6 +178,19 @@ class CustomerController extends Controller
$lb = new ListBook(); $lb = new ListBook();
$dataPelanggan = DB::table('users')
->join('pelanggan','users.id','=','pelanggan.id_akun')
->select('pelanggan.id','pelanggan.nama')
->where('users.id','=',Auth::user()->id)
->get();
$dataHasilValidPelanggan = $this->dataValidation($dataPelanggan[0]->id);
if($dataHasilValidPelanggan > 0 ){
//dd($dataHasilValidPelanggan,'nggak boleh');
return redirect('customerProfile')->with('message','Lengkkapi data diri anda!!');
}
$dataHomestay = DB::table('homestay') $dataHomestay = DB::table('homestay')
->join('kamar','homestay.id','=','kamar.id_homestay') ->join('kamar','homestay.id','=','kamar.id_homestay')
->select('kamar.*','homestay.harga','homestay.jumlah_kamar') ->select('kamar.*','homestay.harga','homestay.jumlah_kamar')
...@@ -249,12 +234,6 @@ class CustomerController extends Controller ...@@ -249,12 +234,6 @@ class CustomerController extends Controller
} }
} }
$dataPelanggan = DB::table('users')
->join('pelanggan','users.id','=','pelanggan.id_akun')
->select('pelanggan.id','pelanggan.nama')
->where('users.id','=',Auth::user()->id)
->get();
$time = explode('-', $request['tanggal']); $time = explode('-', $request['tanggal']);
if ($time[1]==2){ if ($time[1]==2){
...@@ -331,5 +310,30 @@ class CustomerController extends Controller ...@@ -331,5 +310,30 @@ class CustomerController extends Controller
return redirect('customerHistory'); return redirect('customerHistory');
} }
public function dataValidation($id){
$dataPelanggan = DB::table('pelanggan')
->select('pelanggan.*')
->where('pelanggan.id','=',$id)
->get();
$counter = 0;
if($dataPelanggan[0]->nama == "---"){
$counter +=1;
}
if($dataPelanggan[0]->alamat =="---"){
$counter +=1;
}
if($dataPelanggan[0]->no_telepon =="---"){
$counter +=1;
}
if($dataPelanggan[0]->pekerjaan == "---"){
$counter +=1;
}
return $counter;
}
} }
...@@ -34,6 +34,33 @@ class GuestController extends Controller ...@@ -34,6 +34,33 @@ class GuestController extends Controller
return view('welcome'); return view('welcome');
} }
//Menyimpan data Pelanggan disaat melakukan Pendaftaran
public function registerStore(Request $data){
$user = new User();
$user->name = $data['name'];
$user->username = $data['username'];
$user->email = $data['email'];
$user->password = bcrypt($data['password']);
$user->role = "Customer";
$user->foto = "gravatar.png";
$user->save();
$dataPel = DB::table('users')
->select('users.id')
->where('users.username','=',$data['username'])
->get();
$cus = new Customer();
$cus->id_akun = $dataPel[0]->id;
$cus->nama = $data['name'] ;
$cus->alamat = "---";
$cus->no_telepon = "---";
$cus->pekerjaan = "---";
$cus->save();
return redirect('login');
}
public function register(){ public function register(){
return view('adminlte::auth.register'); return view('adminlte::auth.register');
......
...@@ -36,6 +36,12 @@ ...@@ -36,6 +36,12 @@
<a class="agileits w3layoutswow slideInLeft" href="{{url('editProfileCustomer/'.$data->id)}}" >Edit Profile <span class="glyphicon agileits w3layouts glyphicon-arrow-right" aria-hidden="true"></span></a> <a class="agileits w3layoutswow slideInLeft" href="{{url('editProfileCustomer/'.$data->id)}}" >Edit Profile <span class="glyphicon agileits w3layouts glyphicon-arrow-right" aria-hidden="true"></span></a>
<a class="agileits w3layoutswow slideInLeft" href="{{url('customerHistory')}}">History <span class="glyphicon agileits w3layouts glyphicon-arrow-right" aria-hidden="true"></span></a> <a class="agileits w3layoutswow slideInLeft" href="{{url('customerHistory')}}">History <span class="glyphicon agileits w3layouts glyphicon-arrow-right" aria-hidden="true"></span></a>
</div> </div>
<br><br>
@if(Session::has('message'))
<div class="alert alert-danger">
{{ Session::get('message') }}
</div>
@endif
</div> </div>
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
......
...@@ -15,6 +15,11 @@ ...@@ -15,6 +15,11 @@
<div class="details agileits w3layouts" style="margin-top: 10px; padding:0px"> <div class="details agileits w3layouts" style="margin-top: 10px; padding:0px">
<br> <br>
@if(Session::has('message'))
<div class="alert alert-danger">
{{ Session::get('message') }}
</div>
@endif
<div class="container"> <div class="container">
@if (count($errors) > 0) @if (count($errors) > 0)
<div class="alert alert-danger"> <div class="alert alert-danger">
......
...@@ -82,12 +82,12 @@ Route::group(['middleware' => 'owner'], function () { ...@@ -82,12 +82,12 @@ Route::group(['middleware' => 'owner'], function () {
Route::get('detailhomestay/{id}','GuestController@detailhomestay'); Route::get('detailhomestay/{id}','GuestController@detailhomestay');
Route::get('daftar','GuestController@register'); Route::get('daftar','GuestController@register');
Route::post('daftar','GuestController@registerStore');
Route::group(['middleware' => 'customer'], function () { Route::group(['middleware' => 'customer'], function () {
Route::delete('batalkanPemesanan/{id}','CustomerController@cancelPemesanan'); Route::delete('batalkanPemesanan/{id}','CustomerController@cancelPemesanan');
Route::put('upload/{id}','CustomerController@upload'); Route::put('upload/{id}','CustomerController@upload');
Route::get('customerHistory','CustomerController@history'); Route::get('customerHistory','CustomerController@history');
Route::post('daftar','CustomerController@registerStore');
Route::post('book','CustomerController@booking'); Route::post('book','CustomerController@booking');
Route::get('buktipembayaran/{id}','CustomerController@bukti'); Route::get('buktipembayaran/{id}','CustomerController@bukti');
Route::get('editProfileCustomer/{id}','CustomerController@editProfile'); Route::get('editProfileCustomer/{id}','CustomerController@editProfile');
......
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