fix editing orders

This commit is contained in:
Ludovic CANDELLIER
2022-11-19 23:43:12 +01:00
parent caee665758
commit 73763bb146
19 changed files with 314 additions and 174 deletions

View File

@@ -3,7 +3,7 @@
namespace App\Repositories\Shop;
use Illuminate\Support\Str;
use Carbon\Carbon;
use App\Models\Shop\Invoice;
class Invoices
@@ -19,6 +19,17 @@ class Invoices
return $relations ? Invoice::with($relations)->findOrFail($id) : Invoice::findOrFail($id);
}
public static function count()
{
return Invoice::count();
}
public static function countByMonth()
{
$start = Carbon::now()->beginOfMonth();
return Invoice::where('created_at', '>', $start);
}
public static function store($data)
{
return ($data['id'] ?? false) ? self::update($data) : self::create($data);
@@ -53,4 +64,9 @@ class Invoices
$last_ref = Invoice::orderBy('ref', 'desc')->where('ref', '>', $ref)->first();
return $last_ref ? $last_ref->ref + 1 : $ref + 1;
}
public static function statuses()
{
return ['En attente', 'Non soldée', 'Soldée'];
}
}