How do I call a controller function from another controller in laravel 5.2?
<p>I have 2 controllers in laravel  5.2</p>

<p>1) Apiauth controller</p>

<pre><code>   &lt;?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')-&gt;first();


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

 }
</code></pre>

<p>2) MobileregistrationController</p>

<p>

<pre><code>        namespace App\Http\Controllers;


        use Illuminate\Http\Request;
        use App\Http\Controllers\Apiauth;
        use App\Http\Requests;
        use App\Mobile_registration;
        use App\Api_auth;

        use App\Http\Requests\CreateMobileRegistrationRequest;

        class MobileregistrationController extends Controller
        {

            public function index(Request $request)
            {

                App\Http\Controllers\Apiauth-&gt;checkauth($request-&gt;authkey);

                // $authkey=Api_auth::orderBy('id', 'desc')-&gt;first();


                // if($authkey-&gt;authkey!=$request-&gt;authkey)
                //     return response()-&gt;json(['response'=&gt;'false','message'=&gt;'Authentication Failed','code'=&gt;403],403);    

                $mobileregistration=Mobile_registration::all();


                if($mobileregistration-&gt;isEmpty())
                    return response()-&gt;json(['response'=&gt;'false','message'=&gt;'No data found','code'=&gt;404],404);
                else
                    return response()-&gt;json(['response'=&gt;'true','data'=&gt;$mobileregistration],200);
            }


            public function show($id,Request $request)
            {

                $authkey=Api_auth::orderBy('id', 'desc')-&gt;first();


                if($authkey-&gt;authkey!=$request-&gt;authkey)
                    return response()-&gt;json(['response'=&gt;'false','message'=&gt;'Authentication Failed','code'=&gt;403],403);     

                $mobileregistration=Mobile_registration::find($id);

                if(!$mobileregistration)
                    return response()-&gt;json(['response'=&gt;'false','message'=&gt;'No data found','code'=&gt;404],404);
                else
                    return response()-&gt;json(['response'=&gt;'true','data'=&gt;$mobileregistration],200);

            }

            public function store(CreateMobileRegistrationRequest $request)
            {
                $values =$request-&gt;only(['mobile_imei','mobile_number','application_type','version','isverified','reg_date_time','authkey']);

                $authkey=Api_auth::orderBy('id', 'desc')-&gt;first();


                if($authkey-&gt;authkey!=$request-&gt;authkey)
                    return response()-&gt;json(['response'=&gt;'false','message'=&gt;'Authentication Failed','code'=&gt;403],403);   

                Mobile_registration::create($values);

                return response()-&gt;json(['response'=&gt;'true','message'=&gt;'Values Inserted','code'=&gt;201],201);
            }

            public function update($id,CreateMobileRegistrationRequest $request)
            {
                $mobileregistration=Mobile_registration::find($id);

                if(!$mobileregistration)
                    return response()-&gt;json(['response'=&gt;'false','message'=&gt;'No matching data found for editing','code'=&gt;404],404);

                $authkey=Api_auth::orderBy('id', 'desc')-&gt;first();


                if($authkey-&gt;authkey!=$request-&gt;authkey)
                    return response()-&gt;json(['response'=&gt;'false','message'=&gt;'Authentication Failed','code'=&gt;403],403); 

                $mobileregistration-&gt;mobile_imei=$request-&gt;get('mobile_imei');
                $mobileregistration-&gt;mobile_number=$request-&gt;get('mobile_number');
                $mobileregistration-&gt;application_type=$request-&gt;get('application_type');
                $mobileregistration-&gt;version=$request-&gt;get('version');
                $mobileregistration-&gt;isverified=$request-&gt;get('isverified');
                $mobileregistration-&gt;reg_date_time=$request-&gt;get('reg_date_time');

                $mobileregistration-&gt;save();

                return response()-&gt;json(['response'=&gt;'true','message'=&gt;'Mobile Registration details updated successfully','code'=&gt;200],200);


            }

            public function destroy($id,Request $request)
            {
                $mobileregistration=Mobile_registration::find($id);

                if(!$mobileregistration)
                    return response()-&gt;json(['response'=&gt;'false','message'=&gt;'No matching data found for deleting','code'=&gt;404],404);

                $authkey=Api_auth::orderBy('id', 'desc')-&gt;first();


                if($authkey-&gt;authkey!=$request-&gt;authkey)
                    return response()-&gt;json(['response'=&gt;'false','message'=&gt;'Authentication Failed','code'=&gt;403],403); 

                $mobileregistration-&gt;delete();

                return response()-&gt;json(['response'=&gt;'true','message'=&gt;'Provided details are deleted sucessfully','code'=&gt;200],200);
            }
        }
</code></pre>

<p>Now in MobileregistrationController, for every function I want to call this function</p>

<pre><code>     public function checkauth($reqauthkey){} 
</code></pre>

<p>of Apiauth controller</p>

<p>But when I used this code to call this function I am gettig error message</p>

<pre><code>    App\Http\Controllers\Apiauth-&gt;checkauth($request-&gt;authkey);
</code></pre>

<p>Error message</p>

<pre><code>    FatalErrorException in MobileregistrationController.php line 20:
    Class 'App\Http\Controllers\App\Http\Controllers\Apiauth' not found
</code></pre>

<p>I have searched lot on Stackoverflow for the answers but none of solution worked for me correctly. Someone help me to rectify this.</p>