I have problems using data inside a laravel function, here is a example:
    public function csvUnique($id){ 
          $date1= ''.$id.' 00:00:00';
          $date2= ''.$id.' 23:59:59';       
        \Excel::create('Customer list', function ($excel) {
         $excel->sheet('Sheetname', function ($sheet) {
             echo  $date1; 
             echo  $date1; 
             });
            })->export('csv');
} //end csv
$id is passed value,and I can see value if use dd($id). The problem is: How to pass values date1 and date2 inside functions?
I tried with global, same error:
**Undefined variable: date1**
 
     
     
    