Export data in database to various file format . Currently xls,json and csv file formats are supported
use YS\Export\Csv;
use App\User;
public function exportUsers()
{
$csv = new Csv( User::select('*'));
return $csv->response();
}
use YS\Export\Csv;
use App\User;
public function exportUsers()
{
$csv = new Csv( DB::table('users')->select('name','email'));
return $csv->response();
}
use YS\Export\Csv;
use App\User;
public function exportUsers()
{
$query = User::join('companies', 'companies.id','users.company_id')->select('users.name','users.email','companies.name as company');
$csv = new Csv( $query );
return $csv->response();
}
use YS\Export\Json;
use App\User;
public function exportUsers()
{
$json = new Json( DB::table('users')->select('name','email'));
return $json->response();
}
use YS\Export\Xls;
use App\User;
public function exportUsers()
{
$json = new Xls( DB::table('users')->select('name','email'));
return $json->response();
}
You can provide column names inside select statement in order to export only selected columns from database.Optionally you can also define column names inside ys-export config file which you do not want to export in file like id,password etc...
To do this just run php artisan vendor:publish and select ys-export:config group