Php 如何从laravel 5.2中的另一个控制器调用控制器函数?

Php 如何从laravel 5.2中的另一个控制器调用控制器函数?,php,api,laravel,laravel-5,Php,Api,Laravel,Laravel 5,我在laravel 5.2中有2个控制器 1) Apiauth控制器 <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Http\Requests; use App\Api_auth; class Apiauth extends Controller { public function checkauth($reqauthkey

我在laravel 5.2中有2个控制器

1) Apiauth控制器

   <?php

   namespace App\Http\Controllers;

   use Illuminate\Http\Request;

   use App\Http\Requests;
   use App\Api_auth;

   class Apiauth extends Controller
   {
       public function checkauth($reqauthkey)
       {
             $authkey=Api_auth::orderBy('id', 'desc')->first();


             if($authkey->authkey!=$reqauthkey)
            return response()->json(['response'=>'false','message'=>'Authentication Failed','code'=>403],403);  
        }

 }
现在在MobileregistrationController中,对于每个我想调用的函数

     public function checkauth($reqauthkey){} 
Apiauth控制器的设计

   <?php

   namespace App\Http\Controllers;

   use Illuminate\Http\Request;

   use App\Http\Requests;
   use App\Api_auth;

   class Apiauth extends Controller
   {
       public function checkauth($reqauthkey)
       {
             $authkey=Api_auth::orderBy('id', 'desc')->first();


             if($authkey->authkey!=$reqauthkey)
            return response()->json(['response'=>'false','message'=>'Authentication Failed','code'=>403],403);  
        }

 }
但是当我使用这个代码调用这个函数时,我得到了一条错误消息

    App\Http\Controllers\Apiauth->checkauth($request->authkey);
    FatalErrorException in MobileregistrationController.php line 20:
    Class 'App\Http\Controllers\App\Http\Controllers\Apiauth' not found
错误消息

    App\Http\Controllers\Apiauth->checkauth($request->authkey);
    FatalErrorException in MobileregistrationController.php line 20:
    Class 'App\Http\Controllers\App\Http\Controllers\Apiauth' not found
我在Stackoverflow上搜索了很多答案,但没有一个解决方案对我有效。有人帮我纠正一下。

我有一条路要走

Route::get('/test/index', 'TestController@index');
带函数测试的Apiauth()


您应该更改使用App\Http\Controllers\Apiauth;as使用Apiauth;否,使其生成另一个错误,MobileregistrationController.php第20行中的FatalErrorException:语法错误,意外的'->'(T_OBJECT_操作符)
$controller=new Apiauth
$controller->checkauth($request->authkey)您好,它不工作,我使用了“名称空间应用程序\Http\Controllers;”以及"使用Apiauth",,在代码中,我使用了“$controller=newapiauth$controller->checkauth($request->authkey);'但我收到的错误消息是Apiauth未找到,如果我使用此use App\Http\Controllers\Apiauth,则我不会收到错误消息,但它不会调用checkauth($request->authkey)方法