Looking to hire Laravel developers? Try LaraJobs

laravel-csv maintained by innovator-japan

Description
A library that manipulates CSV with Laravel
Last update
2020/11/17 04:12 (dev-master)
License
Links
Downloads
3 328
Tags

Comments
comments powered by Disqus

Laravel CSV

CircleCI License

Features

  • Easily export to csv from collection
  • Highly memory efficient
  • Wrapper around League\Csv

Requirements

  • PHP 7.1.3 or later
  • Laravel 5.6 or later
  • mbstring extension

Installation

This project using composer.

$ composer require innovator-japan/laravel-csv

Usage

Exporting a database table as a CSV

1️⃣ First of all, Create this class.

<?php

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();
    }
}

2️⃣ Then you will be able to download it.

use App\Export\UserCsv;
use App\Http\Controllers\Controller;

class UserController extends Controller
{
    public function export()
    {
        return (new UserCsv())->download('user.csv');
    }
}

Importing CSV records into a database table

Comming soon...

Maintainers

Innovator Japan Inc.

Contributing

Please see CONTRIBUTING for details.

License

MIT © Innovator Japan Inc.