I want to export posts data from Admin Pannel i added a button in:
\vendor\tcg\voyager\resources\views\bread\browse.blade.php
<a href="">
<button id="export-to-excel" type="button" class="btn btn-danger">EXPORT</button>
</a>
i use Maatwebsite package.. i installed the package via composer..
Can anyone suggest me that what's I'm doing wrong.
My Code :
. .
Web.php:
Route::group(['prefix' => 'admin','as' => 'voyager.', 'middleware' => 'admin.user'], function()
{
Route::get('ExportCommandes','ExportController@getExport');
});
ExcelController:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\browse;
use Input;
use Excel;
class ExcelController extends Controller
{
//
public function getExport(){
$post=Post::all();
Excel::create('Export Data', function($excel) use($post){
$excel->sheet('Sheet 1', function($sheet) use($post){
$sheet->fromArray($post);
});
})->export('xlsx');
}
}
ExportCommandes.blade.php:
@extends('voyager::master')
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire