-1

I am maintaining some Laravel 6 code written by my colleges.

I find that they overrode the callAction method in controllers and initialise some variables in it. But I can't find the callAction method in Laravel 3-8 documentations.

What is the point of initialising variables within the callAction method instead of within the controller's constructor?

use Illuminate\Routing\Controller;

class ControllerA extends Controller
{
    protected $data = [];

    public function callAction($method, $parameters)
    {
        $this->data['title'] = 'Some database query';
    }

    public function index(Request $request)
    {
        return view('index', $this->data);
    }
}
Nelson Luk
  • 171
  • 1
  • 11

1 Answers1

2

callAction(string $method, array $parameters)

Execute an action on the controller.

source: https://laravel.com/api/8.x/Illuminate/Routing/Controller.html#method_callAction

melsaka
  • 82
  • 4