<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Maatwebsite\Excel\Facades\Excel;

class ExportRankingCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'export:ranking {type?}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        Excel::create('weekly_report', function($excel) {
            $excel->sheet('Sheetname', function($sheet) {
                // Sheet manipulation
                $sheet->cell('A1', function($cell) {
                    // manipulate the cell
                    $cell->setValue('data1');
                });

                /*$sheet->cells('A1:A5', function($cells) {
                    // manipulate the range of cells
                });*/

            });
        })->store('xlsx', storage_path('exports/weekly_report'));
    }
}