Skip to content

Commit

Permalink
build: predis was installed to work with the queues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Josemprog committed Nov 15, 2020
1 parent fecaebd commit 34df210
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 27 deletions.
15 changes: 6 additions & 9 deletions app/Exports/ProductsExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@
namespace App\Exports;

use App\Product;
use Illuminate\Contracts\Queue\ShouldQueue;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\FromQuery;

class ProductsExport implements FromCollection
class ProductsExport implements FromQuery, ShouldQueue
{

use Exportable;

/**
* @return \Illuminate\Support\Collection
*/
public function collection()
public function query()
{
return Product::all();
return Product::query();
}
}
}
7 changes: 7 additions & 0 deletions app/Http/Controllers/Admin/ProductController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Controllers\Admin;

use App\Exports\ProductsExport;
use App\Product;
use Illuminate\Http\Request;
use Intervention\Image\Facades\Image;
Expand Down Expand Up @@ -156,4 +157,10 @@ public function destroy(Product $product): \Illuminate\Http\RedirectResponse
->route('products.index')
->with('message', 'Product Removed');
}

public function export()
{
(new ProductsExport())->store('products.csv');
return back()->with('message', 'Export started!');
}
}
13 changes: 0 additions & 13 deletions app/Http/Controllers/ExportController.php

This file was deleted.

3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"laravel/framework": "^7.0",
"laravel/tinker": "^2.0",
"laravel/ui": "^2.0",
"maatwebsite/excel": "^3.1"
"maatwebsite/excel": "^3.1",
"predis/predis": "^1.1"
},
"require-dev": {
"facade/ignition": "^2.0",
Expand Down
81 changes: 80 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions resources/views/admin/products/panel.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@

<div class="container">
<h1 class="text-dark d-flex justify-content-center h-big">Products</h1>

<div>
<a class="btn btn-info" href="{{ route('export') }}">Exportar</a>
</div>
<table class="table table-striped p-edit-2">
<thead>
<tr class="text-muted">
Expand Down
4 changes: 2 additions & 2 deletions resources/views/layouts/app.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
{{-- Links añadidos --}}
@auth
<li class="nav-item">
<a class="nav-link text-white" href="{{ route('home') }}">{{ __('Home') }}</a>
<a class="nav-link text-white" href="{{ route('products.index') }}">{{ __('Home') }}</a>
</li>

<li class="nav-item">
<a class="nav-link text-white" href="{{ route('products.index') }}">{{ __('Products') }}</a>
<a class="nav-link text-white" href="{{ route('products.panel') }}">{{ __('Products') }}</a>
</li>

<li class="nav-item">
Expand Down
2 changes: 1 addition & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
Route::post('orders/{order}', 'OrderController@retry')->name('orders.retry')->middleware('verified');

// Export
Route::get('/export', 'ProductController@export')->name('export');
Route::get('/export', 'Admin\ProductController@export')->name('export');

// pruebas
Route::get('/rangualiado', function ()
Expand Down

0 comments on commit 34df210

Please sign in to comment.