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 @@