generated from Innovix-Matrix-Systems/ims-laravel-api-starter
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from Innovix-Matrix-Systems/develop
Export Functionality Added
- Loading branch information
Showing
11 changed files
with
1,107 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace App\Exports; | ||
|
||
use Illuminate\Contracts\Support\Responsable; | ||
use Illuminate\Support\Collection; | ||
use Maatwebsite\Excel\Concerns\Exportable; | ||
use Maatwebsite\Excel\Concerns\FromCollection; | ||
use Maatwebsite\Excel\Excel; | ||
|
||
class BulkExport implements FromCollection, Responsable | ||
{ | ||
use Exportable; | ||
|
||
private Collection $records; | ||
|
||
private $fileName = 'users.csv'; | ||
|
||
private $writerType = Excel::CSV; | ||
|
||
private $headers = [ | ||
'Content-Type' => 'text/csv', | ||
]; | ||
|
||
public function __construct(Collection $records, $name) | ||
{ | ||
$this->records = $records; | ||
$this->fileName = $name; | ||
} | ||
|
||
/** | ||
* @return \Illuminate\Support\Collection | ||
*/ | ||
public function collection() | ||
{ | ||
return $this->records; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace App\Exports; | ||
|
||
use App\Models\User; | ||
use Maatwebsite\Excel\Concerns\FromCollection; | ||
|
||
class UsersExport implements FromCollection | ||
{ | ||
/** | ||
* @return \Illuminate\Support\Collection | ||
*/ | ||
public function collection() | ||
{ | ||
return User::all(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.