add function forgot password-reset password
This commit is contained in:
@@ -14,6 +14,7 @@ use App\Models\Pengesahan;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Cawangan;
|
||||
use App\Models\LelongBid;
|
||||
use Hash;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
@@ -181,4 +182,75 @@ class HomeController extends Controller
|
||||
|
||||
return view('home',compact('lelong', 'arrayinfo'));
|
||||
}
|
||||
|
||||
public function editprofile()
|
||||
{
|
||||
// $user = Auth::user();
|
||||
// $user->assignRole('admin');
|
||||
return view('profil');
|
||||
}
|
||||
|
||||
public function profileUpdate(Request $request){
|
||||
//validation rules
|
||||
|
||||
$request->validate([
|
||||
'name' =>'required|min:4|string|max:255',
|
||||
'username' =>'required|min:4|string|max:255',
|
||||
'email'=>'required|email|string|max:255'
|
||||
]);
|
||||
$user =Auth::user();
|
||||
$user->name = $request['name'];
|
||||
$user->email = $request['email'];
|
||||
$user->save();
|
||||
return back()->with('message','Profil Telah Kemaskini');
|
||||
}
|
||||
public function tukarkatalaluan()
|
||||
{
|
||||
// $user = Auth::user();
|
||||
// $user->assignRole('admin');
|
||||
return view('tukarkatalaluan');
|
||||
}
|
||||
public function tukarkatalaluanupdate(Request $request){
|
||||
//validation rules
|
||||
|
||||
$request->validate([
|
||||
'name' =>'required|min:4|string|max:255',
|
||||
'username' =>'required|min:4|string|max:255',
|
||||
'email'=>'required|email|string|max:255'
|
||||
]);
|
||||
$user =Auth::user();
|
||||
$user->name = $request['name'];
|
||||
$user->email = $request['email'];
|
||||
$user->save();
|
||||
return back()->with('message','Profil Telah Kemaskini');
|
||||
}
|
||||
|
||||
public function showChangePasswordGet() {
|
||||
return view('tukarkatalaluan');
|
||||
}
|
||||
|
||||
public function changePasswordPost(Request $request) {
|
||||
if (!(Hash::check($request->get('current-password'), Auth::user()->password))) {
|
||||
// The passwords matches
|
||||
return redirect()->back()->with("error","Katalaluan Lama Tidak Sama Dengan katalaluan.");
|
||||
}
|
||||
|
||||
if(strcmp($request->get('current-password'), $request->get('new-password')) == 0){
|
||||
// Current password and new password same
|
||||
return redirect()->back()->with("error","Katalaluan Baru Tidak Boleh Sama Dengan Katalaluan Lama.");
|
||||
}
|
||||
|
||||
$validatedData = $request->validate([
|
||||
'current-password' => 'required',
|
||||
'new-password' => 'required|string|min:8|confirmed',
|
||||
]);
|
||||
|
||||
//Change Password
|
||||
$user = Auth::user();
|
||||
$user->password = bcrypt($request->get('new-password'));
|
||||
$user->save();
|
||||
|
||||
return redirect()->back()->with("success","Katalaluan Berjaya Dikemaskini!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -99,6 +99,7 @@ class LelongController extends Controller
|
||||
->select('cawangan.caw_name', 'cawangan.caw_code', 'cawangan.id')
|
||||
->where('lelong.id', $lelongid)
|
||||
->get();
|
||||
// dd($lelongbycaw);
|
||||
|
||||
foreach ($lelongbycaw as $index => $data) {
|
||||
$lelongbycaw[$index]['lelong'] = $lelong->toArray();
|
||||
@@ -107,13 +108,21 @@ class LelongController extends Controller
|
||||
->where('lelongbid.caw_id', $data['id'])
|
||||
->where('status_jual', 1)
|
||||
->where('lelongbidder.status_bidder', 1)
|
||||
->where('lelongbidder.status_payment', 1)
|
||||
// ->where('lelongbidder.status_payment', 1)
|
||||
->get();
|
||||
// dd($lelongbid);
|
||||
|
||||
foreach ($lelongbid as $index2 => $value) {
|
||||
$lelongbidmarhun = LelongBidMarhun::where('lelongbid_id', $value['id'])
|
||||
->get();
|
||||
foreach ($lelongbid as $index2 => $value)
|
||||
{
|
||||
$lelongbidmarhun = LelongBidMarhun::where('lelongbid_id', $value['id'])->get();
|
||||
$lelongbid[$index2]['lelongbidmarhun'] = $lelongbidmarhun->toArray();
|
||||
|
||||
$insertbatchlel = Http::withOptions(['verify' => config('app.api_verify')])
|
||||
->post(config('app.api_url').'taglel/update',[
|
||||
'kodcaw'=>$cawsimulasi['cawangan']->caw_code,
|
||||
'norujukan'=>$data->norujukan
|
||||
])
|
||||
->json();
|
||||
}
|
||||
$lelongbycaw[$index]['lelongbid'] = $lelongbid->toArray();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
|
||||
use App\Models\Lelong;
|
||||
use App\Models\CawanganLelong;
|
||||
use App\Models\Pengesahan;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Cawangan;
|
||||
use App\Models\LelongBid;
|
||||
use Hash;
|
||||
// use Auth;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Support\Renderable
|
||||
*/
|
||||
public function logout(Request $request) {
|
||||
Auth::logout();
|
||||
return redirect('/login');
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ use App\Models\GadaiMarhun;
|
||||
use App\Models\ScanSemak;
|
||||
use App\Models\TangguhLelong;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\ScanMarhun;
|
||||
|
||||
class MarhunController extends Controller
|
||||
{
|
||||
@@ -129,10 +130,11 @@ class MarhunController extends Controller
|
||||
->where('status_ubah', 6)
|
||||
->first();
|
||||
|
||||
$statusSemakMarhun = ScanMarhun::where('lelongbid_id', $bid['id'])
|
||||
$statusSemakMarhun = ScanSemak::where('lelongbid_id', $bid['id'])
|
||||
->whereNotNull('masa_terima')
|
||||
->whereNull('masa_serah')
|
||||
->first();
|
||||
dd($statusSemakMarhun);
|
||||
if ($statusSemakMarhun) {
|
||||
$lelongbid[$index1]['statusterimamarhun'] = 1;
|
||||
}
|
||||
@@ -839,14 +841,14 @@ class MarhunController extends Controller
|
||||
$gadai = GadaiMarhun::on($datagadai[0]['kodcaw'])->whereIn('norujukan', $arraygadai)
|
||||
->get()->toArray();
|
||||
|
||||
foreach($gadai as $index1=>$gadai2)
|
||||
foreach($gadai as $index2=>$gadai2)
|
||||
{
|
||||
|
||||
$listgadai = GadaiMarhun::on($datagadai[0]['kodcaw'])->whereIn('norujukan', $arraygadai)
|
||||
->get();
|
||||
|
||||
$gadai[$index2]['listgadai'] = $listgadai;
|
||||
}
|
||||
$gadai[$index1]['listgadai'] = $listgadai;
|
||||
// $gadai[$index2]['listgadai'] = $listgadai;
|
||||
// dd($gadai);
|
||||
$arraylelbidmarhun = [];
|
||||
$bakilelong = 0;
|
||||
|
||||
@@ -215,31 +215,59 @@ class PembidaController extends Controller
|
||||
|
||||
public function senlelbelumbayarbidaan(Request $request)
|
||||
{
|
||||
//$kodcaw = $request->kodcaw;
|
||||
// //$kodcaw = $request->kodcaw;
|
||||
|
||||
|
||||
//$arrayinfo = [];
|
||||
// //$arrayinfo = [];
|
||||
|
||||
$lelong = LelongBid::join('cawangan_lelong','lelongbid.lelong_id','=','cawangan_lelong.lelong_id')
|
||||
->join('lelongbidder','lelongbid.id','=','lelongbidder.lelongbid_id')
|
||||
->join('lelong','lelong.id','=','lelongbid.lelong_id')
|
||||
->join('cawangan','cawangan.id','=','lelongbid.caw_id')
|
||||
->select('lelongbid.lelong_id','lelongbid.caw_id','lelongbid.kodcaw','lelongbid.t_lelong','lelong.sts_lelong','cawangan.caw_name')
|
||||
// $lelong = LelongBid::join('cawangan_lelong','lelongbid.lelong_id','=','cawangan_lelong.lelong_id')
|
||||
// ->join('lelongbidder','lelongbid.id','=','lelongbidder.lelongbid_id')
|
||||
// ->join('lelong','lelong.id','=','lelongbid.lelong_id')
|
||||
// ->join('cawangan','cawangan.id','=','lelongbid.caw_id')
|
||||
// ->select('lelongbid.lelong_id','lelongbid.caw_id','lelongbid.kodcaw','lelongbid.t_lelong','lelong.sts_lelong','cawangan.caw_name')
|
||||
// ->distinct()
|
||||
// ->orderBy('lelongbid.lelong_id')
|
||||
// ->where('lelongbid.status_jual', 1)
|
||||
// ->where('lelong.sts_lelong', 3)
|
||||
// ->where(function($query){
|
||||
// $query->whereNull('lelongbidder.status_payment')
|
||||
// ->orWhere('lelongbidder.status_payment',2)
|
||||
// ->where('lelongbidder.status_bidder', 1);
|
||||
// })
|
||||
// ->get();
|
||||
// //->toArray();
|
||||
// dd($lelong);
|
||||
|
||||
$kodcaw = $request->kodcaw;
|
||||
|
||||
|
||||
$arrayinfo = [];
|
||||
|
||||
$lelong = Lelong::join('cawangan_lelong','lelong.id','=','cawangan_lelong.lelong_id')
|
||||
->select('lelong_id','tarikh_lelong','lelong.fasa','harga_emas_asas','jbg','cajlelong','sts_lelong')
|
||||
->distinct()
|
||||
->orderBy('lelongbid.lelong_id')
|
||||
->where('lelongbid.status_jual', 1)
|
||||
->where('lelong.sts_lelong', 3)
|
||||
->where(function($query){
|
||||
$query->whereNull('lelongbidder.status_payment')
|
||||
->orWhere('lelongbidder.status_payment',2)
|
||||
->where('lelongbidder.status_bidder', 1);
|
||||
})
|
||||
->get();
|
||||
//->toArray();
|
||||
//dd($lelong);
|
||||
->orderBy('lelong_id')
|
||||
->where('lelong.sts_lelong', 3)
|
||||
->get()
|
||||
->toArray();
|
||||
|
||||
foreach($lelong as $details)
|
||||
{
|
||||
|
||||
$detailsinfo = CawanganLelong::join('cawangan','cawangan_lelong.caw_id','=','cawangan.id')
|
||||
->select('cawangan_lelong.lelong_id','cawangan_lelong.caw_id','caw_name','caw_code','cawangan_lelong.export_data_sts')
|
||||
->where('lelong_id',$details['lelong_id'])
|
||||
->distinct()
|
||||
->orderBy('lelong_id')
|
||||
->get()
|
||||
->toArray();
|
||||
// dd($detailsinfo);
|
||||
|
||||
array_push($arrayinfo,['detail'=>$details, 'detailsinfo'=>$detailsinfo]);
|
||||
}
|
||||
|
||||
|
||||
return view('pembida.senlelbelumbayarbidaan', compact('lelong'));
|
||||
return view('pembida.senlelbelumbayarbidaan', compact('lelong','arrayinfo'));
|
||||
}
|
||||
|
||||
public function pembayaranbidaan(Request $request)
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Mail\ResetPassword;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
/**
|
||||
* Register user
|
||||
* @param request
|
||||
* @return response
|
||||
*/
|
||||
public function register(Request $request)
|
||||
{
|
||||
|
||||
$this->validate($request, [
|
||||
'name' => 'required',
|
||||
'email' => 'required|email',
|
||||
'password' => 'required|min:6'
|
||||
]);
|
||||
|
||||
User::create([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'password' => Hash::make($request->password)
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Login page
|
||||
* @param NA
|
||||
* @return view
|
||||
*/
|
||||
public function login()
|
||||
{
|
||||
return view('auth.login');
|
||||
}
|
||||
|
||||
/**
|
||||
* User Login
|
||||
* @param request
|
||||
* @return response
|
||||
*/
|
||||
public function loginValidate(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'email' => 'required|email',
|
||||
'password' => 'required|min:6'
|
||||
]);
|
||||
|
||||
$user = User::where('email', $request->email)->first();
|
||||
if ($user) {
|
||||
if (Hash::check($request->password, $user->password)) {
|
||||
return back()->with('success', 'Success! You are logged in');
|
||||
}
|
||||
return back()->with('failed', 'Failed! Invalid password');
|
||||
}
|
||||
return back()->with('failed', 'Failed! Invalid email');
|
||||
}
|
||||
|
||||
/**
|
||||
* Forgot password
|
||||
* @param NA
|
||||
* @return view
|
||||
*/
|
||||
public function forgotPassword()
|
||||
{
|
||||
return view('auth.forgot-password');
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate token for forgot password
|
||||
* @param token
|
||||
* @return view
|
||||
*/
|
||||
public function forgotPasswordValidate($token)
|
||||
{
|
||||
$user = User::where('token', $token)->where('is_verified', 0)->first();
|
||||
// dd($user);
|
||||
if ($user) {
|
||||
$email = $user->email;
|
||||
return view('auth.change-password', compact('email'));
|
||||
}
|
||||
return redirect()->route('forgot-password')->with('failed', 'Password reset link is expired');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset password
|
||||
* @param request
|
||||
* @return response
|
||||
*/
|
||||
public function resetPassword(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'email' => 'required|email',
|
||||
]);
|
||||
|
||||
$user = User::where('email', $request->email)->first();
|
||||
// dd($user);
|
||||
if (!$user) {
|
||||
return back()->with('failed', 'Gagal! Alamat Ini Belum Didaftarkan.');
|
||||
}
|
||||
|
||||
$token = Str::random(60);
|
||||
|
||||
$user['token'] = $token;
|
||||
$user['is_verified'] = 0;
|
||||
$user->save();
|
||||
|
||||
Mail::to($request->email)->send(new ResetPassword($user->name, $token));
|
||||
|
||||
if(Mail::failures() != 0) {
|
||||
return back()->with('success', 'Berjaya DiHantar! Pautan Lupa Katalaluan Telah Dihantarkan Kepada Alamat Emel Anda.');
|
||||
}
|
||||
return back()->with('failed', 'Failed! there is some issue with email provider');
|
||||
}
|
||||
|
||||
/**
|
||||
* Change password
|
||||
* @param request
|
||||
* @return response
|
||||
*/
|
||||
public function updatePassword(Request $request) {
|
||||
$this->validate($request, [
|
||||
'email' => 'required',
|
||||
'password' => 'required|min:6',
|
||||
'confirm_password' => 'required|same:password'
|
||||
]);
|
||||
|
||||
$user = User::where('email', $request->email)->first();
|
||||
if ($user) {
|
||||
$user['is_verified'] = 0;
|
||||
$user['token'] = '';
|
||||
$user['password'] = Hash::make($request->password);
|
||||
$user->save();
|
||||
return redirect()->route('login')->with('success', 'Berjaya! Katalaluan Anda Telah Didaftarkan.');
|
||||
}
|
||||
return redirect()->route('forgot-password')->with('failed', 'Gadal! Sila Cuba Lagi...');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user