PHP code example of innovator-japan / laravel-csv
1. Go to this page and download the library: Download innovator-japan/laravel-csv library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
innovator-japan / laravel-csv example snippets
namespace App\Export;
use App\User;
use Illuminate\Database\Query\Builder;
use InnovatorJapan\LaravelCsv\AbstractCsv;
use InnovatorJapan\LaravelCsv\Exportable;
class UserCsv extends AbstractCsv
{
use Exportable;
public function query(): Builder
{
return User::latest()->getQuery();
}
}
use App\Export\UserCsv;
use App\Http\Controllers\Controller;
class UserController extends Controller
{
public function export()
{
return (new UserCsv())->download('user.csv');
}
}