backpack for laravel: how to add a custom action / operation?

Viewed 542

I need to add and operation to handle downloading of a file.

How can i create route, and add setupDownloadOperation in the right way?

Or must I simply do 'laravel-way' manually adding a route?

2 Answers

Actually we did this

First - Create a setupDownloadRoutes

Actually this is called automatically ad boot

protected function setupDownloadRoutes($segment, $routeName, $controller)
{
    Route::get($segment. '/{id}/download', [
        'as'        => $routeName . '.download',
        'uses'      => $controller . '@download',
        'operation' => 'download',
    ]);
}

Create the setupDownloadOperation function

It's automatically launched if found. If you have nothing to do here you can avoid to create it.

protected  function setupDownloadOperation()
{
    ...do things here...
}

Create the download function.

This is the classic controller action of Laravel

protected  function download()
{
    ... do thing as usually in a normal action  ...
}

I do not find these procedure documented actually

Related