Reputation: 33
I have created a laravel helper something like this which generates an sql file in /sql/ under my database folder location so database/sqls/xxxxx.sql
class Helpsql {
public function cd(string $file = '')
{
$destinationFile = 'mysql';
$destinationPath = database_path(sprintf('sql/', $destinationFile));
$this->callerPassthrough('info', 'create file');
return $destinationPath;
}
}
I create a controller function like this AbcController.php
public function index(){
$urlpath = new Helpsql;
$urlpath->cd();
return response()->download($destinationPath);
}
My route is: Route::get('path', 'AbcController@index');
but it is not returning the path to download the file.
Upvotes: 0
Views: 1474
Reputation: 1249
You're not passing any variable data to
$urlpath->cd();
and
$destinationPath
variable is undefined, you have not set any data to it.
It should be this:
public function index(){
$urlpath = new Helpsql;
return response()->download($urlpath->cd());
}
Upvotes: 0
Reputation: 11
Try return from your controller this response:
return response()->download($destinationPath);
Upvotes: 1