<?php

namespace App\Exports;

use App\MemberRegistration;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;

class MemberRegistrationSpecific implements FromView
{
    /**
    * @return \Illuminate\Support\Collection
    */
    private $from_date,$to_date;

    public function __construct($from_date,$to_date,$from,$to)
    {
        $this->from_date = $from_date;
        $this->to_date = $to_date;
        $this->from = $from;
        $this->to = $to;
    }
    
    public function view(): View
    {
        $members = MemberRegistration::latest()->whereBetween('created_at',[$this->from_date,$this->to_date])->get();
        $title = "LIST OF ALL REGISTERED MEMBERS BETWEEN $this->from TO $this->to.";
        return view('backend.exports.members',compact(['members','title']));                                            
    }
}
