如何在laravel中覆盖我的默认响应方法

I have a method named response in my controller. But it shows the following error

Fatal error: Cannot redeclare response()

HomeController.php

<?php

namespace App\Http\Controllers;
use Illuminate\Http\Request;

class HomeController extends Controller
{
    function response($params, $salt) {
        if (!is_array($params))
            throw new Exception('response params is empty');
        if (empty($salt))
            throw new Exception('Salt is empty');
        if (empty($params['status']))
            throw new Exception('Status is empty');
        $response = new Response($salt);
        $result = $response->get_response($_POST);
        unset($response);
        return $result;
    }
}

You can extend the response class...

use Illuminate\Support\Facades\Response;

class myResponse extends Response{

   public function __construct()
   {
      // do something cool...
   }   
}

Or maybe...

use Illuminate\Support\Facades\Response as BaseResponse;

class Response extends BaseResponse{

   public function __construct()
   {
      // do something cool...
   }   
}

Then you need to replace Laravels facade with your own in config/app.php.

'Response'        => 'Path\Facades\Response',

The response method is already defined in laravel base controller and can't be overridden. Its provided by the framework as a convenience to create a new response object.

If you want to change the base response functionnality, just extend the Response class

If you want something else, just use another name.