migrate to gtea from bistbucket
This commit is contained in:
26
Modules/Business/App/Exports/ExportTopSupplier.php
Normal file
26
Modules/Business/App/Exports/ExportTopSupplier.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Business\App\Exports;
|
||||
|
||||
use App\Models\Party;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
|
||||
class ExportTopSupplier implements FromView
|
||||
{
|
||||
public function view(): View
|
||||
{
|
||||
$suppliers = Party::with('purchases')
|
||||
->where('business_id', auth()->user()->business_id)
|
||||
->where('type', '=', 'Supplier')
|
||||
->whereHas('purchases')
|
||||
->withCount('purchases')
|
||||
->withSum('purchases', 'totalAmount')
|
||||
->orderByDesc('purchases_count')
|
||||
->orderByDesc('purchases_sum_total_amount')
|
||||
->take(5)
|
||||
->get();
|
||||
|
||||
return view('business::party-reports.top-suppliers.excel-csv', compact('suppliers'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user