-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
still not working package => laravel excel
- Loading branch information
1 parent
97acd5a
commit 678fcc2
Showing
5 changed files
with
227 additions
and
11 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,34 @@ | ||
<?php | ||
|
||
namespace App\Exports; | ||
|
||
use App\Sale; | ||
use Illuminate\Contracts\View\View; | ||
use Maatwebsite\Excel\Concerns\FromView; | ||
|
||
class SalesExport implements FromView | ||
{ | ||
private $from; | ||
private $to; | ||
private $sales; | ||
private $total; | ||
|
||
public function __construct($from,$to){ | ||
$this->from = $from; | ||
$this->to = $to; | ||
$this->sales = $sales = Sale::whereBetween("created_at",[$from,$to]) | ||
->where("payment_status","Paid")->get();; | ||
$this->total = $this->sales->sum("total_price"); | ||
} | ||
|
||
public function view(): View | ||
{ | ||
return view('reports.export', [ | ||
'total' => $this->total, | ||
'sales' => $this->sales, | ||
'from' => $this->from, | ||
'to' => $this->to | ||
|
||
]); | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>Id</th> | ||
<th>Menus</th> | ||
<th>Quantity</th> | ||
<th>Tables</th> | ||
<th>Servers</th> | ||
<th>Total</th> | ||
<th>Payment type</th> | ||
<th>Payment status</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach ($sales as $sale) | ||
<tr> | ||
<td> | ||
{{ $sale->id }} | ||
</td> | ||
<td> | ||
@foreach ($sale->menus()->where("sale_id",$sale->id)->get() as $menu) | ||
<h5>{{ $menu->title }}</h5> | ||
<h5>{{ $menu->price }} DH</h5> | ||
@endforeach | ||
</td> | ||
<td > | ||
@foreach ($sale->menus()->where("sale_id",$sale->id)->get() as $menu) | ||
<h5>{{ $menu->pivot->quantity }}</h5> | ||
@endforeach | ||
</td> | ||
<td> | ||
@foreach ($sale->tables()->where("sale_id", $sale->id)->get() as $table) | ||
<span>{{ $table->name }}</span> | ||
@endforeach | ||
</td> | ||
<td> | ||
{{ $sale->servant->name }} | ||
</td> | ||
<td> | ||
{{ $sale->total_price }} | ||
</td> | ||
<td> | ||
{{ $sale->payment_type === "cash"? "Cash" : "Credit Card" }} | ||
</td> | ||
<td> | ||
{{ $sale->payment_status }} | ||
</td> | ||
</tr> | ||
@endforeach | ||
<tr> | ||
<td colspan="5"> | ||
Report from {{ Str::substr($startDate, 0, 10) }} to {{ Str::substr($endDate, 0, 10) }} | ||
</td> | ||
</tr> | ||
<tr> | ||
<td colspan="5"> | ||
Total : {{ $total }} DH </td> | ||
</tr> | ||
</tbody> | ||
</table> |