From 1dce7747d0475eca665ff5618612eb1c483eaecd Mon Sep 17 00:00:00 2001 From: Zakwan Hamdan Date: Tue, 20 Oct 2020 10:52:13 +0800 Subject: [PATCH] add api url in env --- .env.example | 1 + app/Http/Controllers/Auth/LoginController.php | 51 ++++++++++--------- app/Http/Controllers/CustomersController.php | 6 ++- config/api.php | 4 ++ resources/views/customers/index.blade.php | 4 +- resources/views/customers/info.blade.php | 12 ++--- routes/web.php | 14 ++--- 7 files changed, 52 insertions(+), 40 deletions(-) create mode 100644 config/api.php diff --git a/.env.example b/.env.example index ac74863..4e16ae8 100644 --- a/.env.example +++ b/.env.example @@ -3,6 +3,7 @@ APP_ENV=local APP_KEY= APP_DEBUG=true APP_URL=http://localhost +API_URL=http://localhost:8000 LOG_CHANNEL=stack diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 6ca7764..18a0d08 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -8,30 +8,33 @@ use Illuminate\Foundation\Auth\AuthenticatesUsers; class LoginController extends Controller { - public function login() + /* + |-------------------------------------------------------------------------- + | Login Controller + |-------------------------------------------------------------------------- + | + | This controller handles authenticating users for the application and + | redirecting them to your home screen. The controller uses a trait + | to conveniently provide its functionality to your applications. + | + */ + + use AuthenticatesUsers; + + /** + * Where to redirect users after login. + * + * @var string + */ + protected $redirectTo = RouteServiceProvider::HOME; + + /** + * Create a new controller instance. + * + * @return void + */ + public function __construct() { - return view('auth.login'); - } - - public function authenticate(Request $request) - { - $request->validate([ - 'kodlaluan' => 'required|string', - 'katalaluan' => 'required|string', - ]); - - $credentials = $request->only('kodlaluan', 'katalaluan'); - - if (Auth::attempt($credentials)) { - return redirect()->intended('home'); - } - - return redirect('login')->with('error', 'Oppes! You have entered invalid credentials'); - } - - public function logout() { - Auth::logout(); - - return redirect('/'); + $this->middleware('guest')->except('logout'); } } diff --git a/app/Http/Controllers/CustomersController.php b/app/Http/Controllers/CustomersController.php index 0655519..58a11e1 100644 --- a/app/Http/Controllers/CustomersController.php +++ b/app/Http/Controllers/CustomersController.php @@ -2,6 +2,8 @@ namespace App\Http\Controllers; +use Config; + use App\Customer; use App\Media; use Illuminate\Http\Request; @@ -33,7 +35,9 @@ class CustomersController extends Controller public function search(Request $request){ $noic = $request->noic; - $customer_info = $this->customerService->getCustomerInfo($noic); + + $customer_info = Http::get(config('api.url') . '/api/customers/'. $noic)->json(); + // dd($customer_info); $search = true; if($customer_info){ Session::put('customer_info',$customer_info); diff --git a/config/api.php b/config/api.php new file mode 100644 index 0000000..e8ea7a3 --- /dev/null +++ b/config/api.php @@ -0,0 +1,4 @@ + env('API_URL') +]; \ No newline at end of file diff --git a/resources/views/customers/index.blade.php b/resources/views/customers/index.blade.php index 5225a75..31f0788 100644 --- a/resources/views/customers/index.blade.php +++ b/resources/views/customers/index.blade.php @@ -52,7 +52,7 @@
Jantina
Alamat
-
+
Poskod
Daerah
@@ -64,7 +64,7 @@
No Telefon 2
Alamat Surat Menyurat
-
+
Poskod
Negeri
diff --git a/resources/views/customers/info.blade.php b/resources/views/customers/info.blade.php index 8cdff36..ea3c1cd 100644 --- a/resources/views/customers/info.blade.php +++ b/resources/views/customers/info.blade.php @@ -17,7 +17,7 @@ No Kad Pengenalan
- +
@@ -27,7 +27,7 @@ No Pelanggan
- +
@@ -37,7 +37,7 @@ Nama
- +
@@ -47,7 +47,7 @@ Alamat
- +
@@ -57,7 +57,7 @@ No Telefon
- +
@@ -74,7 +74,7 @@
- DAFTAR GADAI + DAFTAR GADAI
diff --git a/routes/web.php b/routes/web.php index 8572350..ec03bef 100644 --- a/routes/web.php +++ b/routes/web.php @@ -13,18 +13,18 @@ use Illuminate\Support\Facades\Route; | */ -// Route::get('/',['as'=>'login','uses'=>'HomeController@index']); +Route::get('/',['as'=>'login','uses'=>'HomeController@index']); -// Auth::routes(); +Auth::routes(); Route::middleware(['auth:juruwang,penilai,khazanah,PPC'])->group(function(){ }); -Route::get('register', 'Auth\RegisterController@register'); -Route::post('register', 'Auth\RegisterController@store'); -Route::get('login', 'Auth\LoginController@login')->name('login'); -Route::post('login', 'Auth\LoginController@authenticate'); -Route::get('logout', 'Auth\LoginController@logout')->name('logout'); +// Route::get('register', 'Auth\RegisterController@register'); +// Route::post('register', 'Auth\RegisterController@store'); +// Route::get('login', 'Auth\LoginController@login')->name('login'); +// Route::post('login', 'Auth\LoginController@authenticate'); +// Route::get('logout', 'Auth\LoginController@logout')->name('logout'); Route::get('/', 'HomeController@index')->name('home'); Route::get('/home', 'HomeController@index')->name('home');