66 lines
1.7 KiB
PHP
66 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Http\Option;
|
|
use App\Models\Invoice;
|
|
use Illuminate\Contracts\View\View;
|
|
use Illuminate\Support\Facades\Date;
|
|
|
|
class InvoiceController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*/
|
|
public function index(): View
|
|
{
|
|
if (\App\Models\Option::where('name', '=', 'invoice_from')->count() > 0) {
|
|
$first = \App\Models\Option::where('name', '=', 'invoice_from')->first()->value;
|
|
} else {
|
|
$first = Date::now()->firstOfMonth()->format('Y-m-d');
|
|
}
|
|
|
|
if (\App\Models\Option::where('name', '=', 'invoice_end')->count() > 0) {
|
|
$last = \App\Models\Option::where('name', '=', 'invoice_end')->first()->value;
|
|
} else {
|
|
$last = Date::now()->format('Y-m-d');
|
|
}
|
|
|
|
return view('invoice.index', ['first' => $first, 'last' => $last]);
|
|
}
|
|
|
|
/**
|
|
* Show the form for creating a new resource.
|
|
*/
|
|
public function create(): View
|
|
{
|
|
return view('invoice.create', ['options' => Option::optionsAsObject()]);
|
|
}
|
|
|
|
/**
|
|
* Display the specified resource.
|
|
*/
|
|
public function show(Invoice $invoice): View
|
|
{
|
|
return view('invoice.show', ['invoice' => $invoice]);
|
|
}
|
|
|
|
/**
|
|
* Show the form for editing the specified resource.
|
|
*/
|
|
public function edit(Invoice $invoice): View
|
|
{
|
|
return view('invoice.edit', ['invoice' => $invoice]);
|
|
}
|
|
|
|
/**
|
|
* Show the form for sending the specified invoice.
|
|
*/
|
|
public function mail(int $id): View
|
|
{
|
|
$invoice = Invoice::find($id);
|
|
|
|
return view('invoice.mail', ['invoice' => $invoice]);
|
|
}
|
|
}
|