fixes
This commit is contained in:
@@ -3,11 +3,14 @@
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\Invoice;
|
||||
use App\Traits\Model\Basic;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Invoices
|
||||
{
|
||||
use Basic;
|
||||
|
||||
public static function getInvoiceHtml($id)
|
||||
{
|
||||
$invoice = self::get($id, ['order.customer', 'order.address', 'order.detail']);
|
||||
@@ -35,16 +38,6 @@ class Invoices
|
||||
return self::store($data);
|
||||
}
|
||||
|
||||
public static function get($id, $relations = false)
|
||||
{
|
||||
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();
|
||||
@@ -52,11 +45,6 @@ class Invoices
|
||||
return Invoice::where('created_at', '>', $start);
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
{
|
||||
return ($data['id'] ?? false) ? self::update($data) : self::create($data);
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
InvoiceStats::increase($data['total_taxed']);
|
||||
@@ -66,15 +54,6 @@ class Invoices
|
||||
return Invoice::create($data);
|
||||
}
|
||||
|
||||
public static function update($data, $id = false)
|
||||
{
|
||||
$id = $id ? $id : $data['id'];
|
||||
$item = self::get($id);
|
||||
$item->update($data);
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function delete($id)
|
||||
{
|
||||
$invoice = self::get($id);
|
||||
@@ -85,7 +64,7 @@ class Invoices
|
||||
|
||||
public static function getNewRef()
|
||||
{
|
||||
$ref = date('ym').'00000';
|
||||
$ref = date('ymd').'00000';
|
||||
$lastRef = Invoice::orderBy('id', 'desc')->first();
|
||||
|
||||
return $lastRef ? $lastRef->ref + 1 : $ref + 1;
|
||||
|
||||
Reference in New Issue
Block a user