PHP code example of sdiazsaez / laravel-excel

1. Go to this page and download the library: Download sdiazsaez/laravel-excel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sdiazsaez / laravel-excel example snippets


'providers' => [
	Cyberduck\LaravelExcel\ExcelLegacyServiceProvider::class,
],

'providers' => [
	Cyberduck\LaravelExcel\ExcelServiceProvider::class,
],

namespace App\Serialisers;

use Illuminate\Database\Eloquent\Model;
use Cyberduck\LaravelExcel\Contract\SerialiserInterface;

class ExampleSerialiser implements SerialiserInterface
{
    public function getData($data)
    {
        $row = [];

        $row[] = $data->field1;
        $row[] = $data->relationship->field2;

        return $row;
    }

    public function getHeaderRow()
    {
        return [
            'Field 1',
            'Field 2 (from a relationship)'
        ];
    }
}