Skip to content

Commit

Permalink
Export As Excel is added.
Browse files Browse the repository at this point in the history
  • Loading branch information
alenoosh committed Jan 31, 2015
1 parent 8718438 commit e9675fa
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/controllers/CrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ public function returnView()
throw new Exception('This Controller is not set in Config file yet!');
} else {
return \View::make('panelViews::all', array(
'grid' => $this->grid,
'filter' => $this->filter
'grid' => $this->grid,
'filter' => $this->filter,
'current_entity' => $this->entity
));
}
}
Expand Down
24 changes: 24 additions & 0 deletions src/controllers/ExportController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
namespace Serverfireteam\Panel;

class ExportController extends \Controller {

public function index($entity, $fileType) {

$data = $entity::get();
if (strcmp($fileType, "excel") == 0) {
$excel = \App::make('Excel');
\Excel::create($entity, function($excel) use ($data) {
$excel->sheet('Sheet1', function($sheet) use ($data) {
$sheet->fromModel($data);
});
})->export('xls');
}
}
}
10 changes: 5 additions & 5 deletions src/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@

Route::group(array('prefix' => 'panel' ,'before' => 'auth'), function()
{

// main page for the admin section (app/views/admin/dashboard.blade.php)
Route::get('/', function()
{
return View::make('panelViews::dashboard');
});


Route::any('/{entity}/{methods}', array('uses' => 'Serverfireteam\Panel\MainController@entityUrl'));
Route::post('/edit',array('uses' => 'Serverfireteam\Panel\ProfileController@postEdit'));
Route::get('/edit',array('uses' => 'Serverfireteam\Panel\ProfileController@getEdit'));
Route::any('/{entity}/{methods}', array('uses' => 'Serverfireteam\Panel\MainController@entityUrl'));
Route::any('/{entity}/export/{type}', array('uses' => 'Serverfireteam\Panel\ExportController@index'));
Route::post('/edit',array('uses' => 'Serverfireteam\Panel\ProfileController@postEdit'));
Route::get('/edit',array('uses' => 'Serverfireteam\Panel\ProfileController@getEdit'));

Route::get('/changePassword', array('uses' => 'Serverfireteam\Panel\RemindersController@getChangePassword'));
Route::post('/changePassword', array('uses' => 'Serverfireteam\Panel\RemindersController@postChangePassword'));
Expand Down
4 changes: 3 additions & 1 deletion src/views/all.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

{{ $filter }}

<a href="{{ url('panel/'.$current_entity.'/export/excel') }}">Export As Excel</a>

{{ $grid }}

@stop
@stop

0 comments on commit e9675fa

Please sign in to comment.