首页 > 解决方案 > 如何通过登录应用程序访问 laravel 控制器功能

问题描述

我在我的应用程序中有这个控制器,我正在尝试使用 httpRequest 通过 android 应用程序访问该控制器,但我正在获取应用程序 bcz 的登录页面我无法在没有登录的情况下访问此功能

那么我怎样才能使其无需登录即可访问

//控制器代码

class sobha_tab_empVer_Controller extends Controller
{

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //
    }
    public function employeeverification(Request $request){
                     $EmpDetails = employees::select()
                                           ->where('employees.EMPID', '=', $request->emp_id)
                                          //->where('vw_assembly_plan_reports.id', '=', $request->zone)
                                           ->get();
//dd($EmpDetails);
                                    //       dd($ProjectDetails);
                  //  return response($EmpDetails);
  return response()->json($EmpDetails);
        }
}

//安卓端

  //Some url endpoint that you may have
              String myUrl = "http://......./employeeverification?emp_id=1350";
                    //String to place our result in
                    String result;
                    //Instantiate new instance of our class
                    HttpGetRequest getRequest = new HttpGetRequest();
                    //Perform the doInBackground method, passing in our url
                    try {
                        result = getRequest.execute(myUrl).get();
                        Log.e("RESULT", "RESULT: " + result);

                    } catch (ExecutionException e) {
                        e.printStackTrace();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }

标签: androidlaravelhttpwebrequest

解决方案


消除

  $this->middleware('auth');

在 __construct()


推荐阅读