feat: Implement invoice creation functionality and integrate DataTables for invoice listing with dynamic column rendering.
This commit is contained in:
@@ -16,8 +16,12 @@ class InvoiceCachedRepository extends BaseCachedRepository implements InvoiceRep
|
||||
{
|
||||
return $this->invoiceRepository->getModel();
|
||||
}
|
||||
public function filter(array $data = [], array $relationships = [], array $withCount = [], array $select = ['*'])
|
||||
public function filter(array $data = [], array $relationships = [], array $withCount = [], array $select = ['*'], bool $returnQuery = false)
|
||||
{
|
||||
if ($returnQuery) {
|
||||
return $this->invoiceRepository->filter($data, $relationships, $withCount, $select, $returnQuery);
|
||||
}
|
||||
|
||||
$cacheKey = $this->getCacheKey(md5(json_encode([
|
||||
'filterItem' => [
|
||||
'data' => $data,
|
||||
|
||||
@@ -12,10 +12,13 @@ class InvoiceRepository extends BaseRepository implements InvoiceRepositoryInter
|
||||
{
|
||||
return Invoice::class;
|
||||
}
|
||||
public function filter(array $data = [], array $relationships = [], array $withCount = [], array $select = ['*'])
|
||||
public function filter(array $data = [], array $relationships = [], array $withCount = [], array $select = ['*'], bool $returnQuery = false)
|
||||
{
|
||||
$model = $this->model->with($relationships)->select($select);
|
||||
|
||||
if (isset($data['client']) && ! empty($data['client'])) {
|
||||
$model = $model->where("customer_id", $data['client']);
|
||||
}
|
||||
if (isset($data['invoice_type'])) {
|
||||
$model = $model->where("invoice_type", $data['invoice_type']);
|
||||
}
|
||||
@@ -86,6 +89,11 @@ class InvoiceRepository extends BaseRepository implements InvoiceRepositoryInter
|
||||
if (count($withCount) > 0) {
|
||||
$model = $model->withCount($withCount);
|
||||
}
|
||||
|
||||
if ($returnQuery) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
if (isset($data['limit']) && $data['limit']) {
|
||||
return $model->latest('id')->take($data['limit'])->get();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace App\Repositories\Invoice;
|
||||
use App\Repositories\BaseRepositoryInterface;
|
||||
|
||||
interface InvoiceRepositoryInterface extends BaseRepositoryInterface{
|
||||
public function filter(array $data = [],array $relationships = [],array $withCount = [],array $select = ['*']);
|
||||
public function filter(array $data = [],array $relationships = [],array $withCount = [],array $select = ['*'], bool $returnQuery = false);
|
||||
public function get_billing_year(int $year = 0);
|
||||
public function get_billing_month(int $month = 0);
|
||||
public function get_billing_day(int|string $day = '');
|
||||
|
||||
Reference in New Issue
Block a user