v2 first commit

This commit is contained in:
denisdulici
2019-11-16 10:21:14 +03:00
parent 5b23e9c2c4
commit 6d50fa8442
3075 changed files with 3451681 additions and 65594 deletions

View File

@@ -0,0 +1,62 @@
<?php
namespace App\Exports\Common;
use App\Models\Common\Item as Model;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithTitle;
class Items implements FromCollection, ShouldAutoSize, WithHeadings, WithMapping, WithTitle
{
public $ids;
public function __construct($ids = null)
{
$this->ids = $ids;
}
public function collection()
{
$model = Model::usingSearchString(request('search'));
if (!empty($this->ids)) {
$model->whereIn('id', (array) $this->ids);
}
return $model->get();
}
public function map($model): array
{
return [
$model->name,
$model->description,
$model->sale_price,
$model->purchase_price,
$model->category_id,
$model->tax_id,
$model->enabled,
];
}
public function headings(): array
{
return [
'name',
'description',
'sale_price',
'purchase_price',
'category_id',
'tax_id',
'enabled',
];
}
public function title(): string
{
return 'items';
}
}

View File

@@ -0,0 +1,31 @@
<?php
namespace App\Exports\Common;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithTitle;
class Reports implements FromView, ShouldAutoSize, WithTitle
{
protected $view;
protected $class;
public function __construct($view, $class)
{
$this->view = $view;
$this->class = $class;
}
public function view(): View
{
return view($this->view, ['class' => $this->class]);
}
public function title(): string
{
return 'reports';
}
}