following is the code which I used for export functionality
public function export(){
$users = DB::table('users')->where('user_type','Farmer')->orWhere('user_type','Dealer')->select('id','name','middlename','surname','mobile','state','district','taluka','user_type')->get()->map(function ($item, $key){
return (array) $item;
})
->all();
$usersArray = [];
foreach ($users as $user) {
$usersArray[] =$user;
}
Excel::create('users',function($excel)use($usersArray) {
$excel->setTitle('users');
$excel->setCreator('Laravel');
$excel->setDescription('users file');
$excel->sheet('sheet1',function($sheet)use($usersArray) {
$sheet->fromArray($usersArray,null,'A1',true,true);
});
})->download('xlsx');
}
This code is working fine on localhost,no issue at localhost, But on server it is showing error that "This site can't be reached", I am unable to figure it out that what is the issue on server. I even try some other solutions on stackoverflow but unable to work.