I have the following set up in my route file
Route::resource('reports', 'CampaignReport\CampaignReportController');
Route::get('reports/generateExcel', array('as' => 'reports.generateExcel', 'uses' => 'CampaignReport\CampaignReportController@generateExcel'));
I am not tieing it to a Model as it is just for creating generic reports. If I output my routes I see (I have removed some of the common ones)
| | GET|HEAD | reports | reports.index | App\Http\Controllers\CampaignReport\CampaignReportController@index | auth
| | GET|HEAD | reports/create | reports.create | App\Http\Controllers\CampaignReport\CampaignReportController@create | auth
| | GET|HEAD | reports/generateExcel | reports.generateExcel | App\Http\Controllers\CampaignReport\CampaignReportController@generateExcel | auth
| | GET|HEAD | reports/{reports} | reports.show | App\Http\Controllers\CampaignReport\CampaignReportController@show | auth
So everything looks fine. Now in one of my views, I have the following
<td>{!! link_to_route('reports.generateExcel', 'Generate Excel', null, array('class' => 'btn btn-info')) !!}</td>
So that should trigger the generateExcel function within my controller. At the moment, my controller is like so
public function show()
{
return "SHOW PAGE";
}
public function generateExcel()
{
return "EXCEL GENERATED";
}
Now the strange thing is, that link to route returns SHOW PAGE for some reason, when it should return EXCEL GENERATED. However, if I make a change in my route and remove the show route e.g.
Route::resource('reports', 'CampaignReport\CampaignReportController', ['except' => ['show']]);
The same link to route will now show what it is supposed too and that is EXCEL GENERATED.
So why would the show function be called in the first instance?
Thanks
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/22OwaBo
via IFTTT
Aucun commentaire:
Enregistrer un commentaire