mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-09 20:52:56 +01:00
Updates for static analysis
This commit is contained in:
parent
98efe4b4a9
commit
68ce3be42b
@ -85,7 +85,7 @@ class ProductSalesExport extends BaseExport
|
||||
$t = app('translator');
|
||||
$t->replace(Ninja::transformTranslations($this->company->settings));
|
||||
|
||||
$this->products = Product::where('company_id', $this->company->id)->withTrashed()->get();
|
||||
$this->products = Product::query()->where('company_id', $this->company->id)->withTrashed()->get();
|
||||
|
||||
//load the CSV document from a string
|
||||
$this->csv = Writer::createFromString();
|
||||
|
@ -72,8 +72,8 @@ abstract class QueryFilters
|
||||
/**
|
||||
* Apply the filters to the builder.
|
||||
*
|
||||
* @param Builder $builder
|
||||
* @return Builder
|
||||
* @param \Illuminate\Database\Eloquent\Builder $builder
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function apply(Builder $builder)
|
||||
{
|
||||
@ -239,7 +239,11 @@ abstract class QueryFilters
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $value
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function is_deleted($value = 'true')
|
||||
{
|
||||
if ($value == 'true') {
|
||||
|
@ -181,6 +181,7 @@ class PreviewPurchaseOrderController extends BaseController
|
||||
DB::connection(config('database.default'))->beginTransaction();
|
||||
|
||||
if ($request->has('entity_id')) {
|
||||
/** @var \Illuminate\Database\Eloquent\Builder|\App\Models\PurchaseOrder $entity_obj|\Illuminate\Database\Eloquent\SoftDeletes */
|
||||
$entity_obj = $class::on(config('database.default'))
|
||||
->with('vendor.company')
|
||||
->where('id', $this->decodePrimaryKey($request->input('entity_id')))
|
||||
|
@ -327,8 +327,11 @@ class TaskController extends BaseController
|
||||
* )
|
||||
*/
|
||||
public function create(CreateTaskRequest $request)
|
||||
{
|
||||
$task = TaskFactory::create(auth()->user()->company()->id, auth()->user()->id);
|
||||
{
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
$task = TaskFactory::create($user->company()->id, $user->id);
|
||||
|
||||
return $this->itemResponse($task);
|
||||
}
|
||||
@ -373,10 +376,13 @@ class TaskController extends BaseController
|
||||
*/
|
||||
public function store(StoreTaskRequest $request)
|
||||
{
|
||||
$task = $this->task_repo->save($request->all(), TaskFactory::create(auth()->user()->company()->id, auth()->user()->id));
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
$task = $this->task_repo->save($request->all(), TaskFactory::create($user->company()->id, $user->id));
|
||||
$task = $this->task_repo->triggeredActions($request, $task);
|
||||
|
||||
event(new TaskWasCreated($task, $task->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null)));
|
||||
event(new TaskWasCreated($task, $task->company, Ninja::eventVars($user->id)));
|
||||
|
||||
event('eloquent.created: App\Models\Task', $task);
|
||||
|
||||
@ -499,7 +505,9 @@ class TaskController extends BaseController
|
||||
$tasks = Task::withTrashed()->find($this->transformKeys($ids));
|
||||
|
||||
$tasks->each(function ($task, $key) use ($action) {
|
||||
if (auth()->user()->can('edit', $task)) {
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
if ($user->can('edit', $task)) {
|
||||
$this->task_repo->{$action}($task);
|
||||
}
|
||||
});
|
||||
@ -621,10 +629,13 @@ class TaskController extends BaseController
|
||||
{
|
||||
$task_statuses = $request->input('status_ids');
|
||||
$tasks = $request->input('task_ids');
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
collect($task_statuses)->each(function ($task_status_hashed_id, $key) {
|
||||
$task_status = TaskStatus::where('id', $this->decodePrimaryKey($task_status_hashed_id))
|
||||
->where('company_id', auth()->user()->company()->id)
|
||||
collect($task_statuses)->each(function ($task_status_hashed_id, $key) use($user){
|
||||
$task_status = TaskStatus::query()->where('id', $this->decodePrimaryKey($task_status_hashed_id))
|
||||
->where('company_id', $user->company()->id)
|
||||
->withTrashed()
|
||||
->first();
|
||||
|
||||
@ -636,8 +647,8 @@ class TaskController extends BaseController
|
||||
$sort_status_id = $this->decodePrimaryKey($key);
|
||||
|
||||
foreach ($task_list as $key => $task) {
|
||||
$task_record = Task::where('id', $this->decodePrimaryKey($task))
|
||||
->where('company_id', auth()->user()->company()->id)
|
||||
$task_record = Task::query()->where('id', $this->decodePrimaryKey($task))
|
||||
->where('company_id', $user->company()->id)
|
||||
->withTrashed()
|
||||
->first();
|
||||
|
||||
|
@ -26,6 +26,10 @@ class VendorContactHashLoginController extends Controller
|
||||
return redirect('/vendors/purchase_orders');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Facades\Redirect
|
||||
*/
|
||||
|
||||
public function magicLink(string $magic_link)
|
||||
{
|
||||
return redirect($this->setRedirectPath());
|
||||
|
@ -298,7 +298,10 @@ class WebhookController extends BaseController
|
||||
*/
|
||||
public function create(CreateWebhookRequest $request)
|
||||
{
|
||||
$webhook = WebhookFactory::create(auth()->user()->company()->id, auth()->user()->id);
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
$webhook = WebhookFactory::create($user->company()->id, $user->id);
|
||||
$webhook->fill($request->all());
|
||||
$webhook->save();
|
||||
|
||||
@ -483,7 +486,10 @@ class WebhookController extends BaseController
|
||||
$webhooks = Webhook::withTrashed()->find($this->transformKeys($ids));
|
||||
|
||||
$webhooks->each(function ($webhook, $key) use ($action) {
|
||||
if (auth()->user()->can('edit', $webhook)) {
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
if ($user->can('edit', $webhook)) {
|
||||
$this->base_repo->{$action}($webhook);
|
||||
}
|
||||
});
|
||||
@ -493,6 +499,8 @@ class WebhookController extends BaseController
|
||||
|
||||
public function retry(RetryWebhookRequest $request, Webhook $webhook)
|
||||
{
|
||||
$includes = '';
|
||||
|
||||
match ($request->entity) {
|
||||
'invoice' => $includes ='client',
|
||||
'payment' => $includes ='invoices,client',
|
||||
@ -504,13 +512,16 @@ class WebhookController extends BaseController
|
||||
|
||||
$class = 'App\Models\\'.ucfirst(Str::camel($request->entity));
|
||||
|
||||
$entity = $class::withTrashed()->where('id', $this->decodePrimaryKey($request->entity_id))->company()->first();
|
||||
$entity = $class::query()->withTrashed()->where('id', $this->decodePrimaryKey($request->entity_id))->company()->first();
|
||||
|
||||
if (!$entity) {
|
||||
return response()->json(['message' => ctrans('texts.record_not_found')], 400);
|
||||
}
|
||||
|
||||
/** @var \App\Models\User $user */
|
||||
$user = auth()->user();
|
||||
|
||||
WebhookSingle::dispatchSync($webhook->id, $entity, auth()->user()->company()->db, $includes);
|
||||
WebhookSingle::dispatchSync($webhook->id, $entity, $user->company()->db, $includes);
|
||||
|
||||
return $this->itemResponse($webhook);
|
||||
}
|
||||
|
@ -78,7 +78,6 @@ class BillingPortalPurchase extends Component
|
||||
/**
|
||||
* Rules for validating the form.
|
||||
*
|
||||
* @var \string[][]
|
||||
*/
|
||||
protected $rules = [
|
||||
'email' => ['required', 'email'],
|
||||
|
@ -57,6 +57,6 @@ class CreateStatementRequest extends Request
|
||||
|
||||
public function client(): ?Client
|
||||
{
|
||||
return Client::without('company')->where('id', $this->client_id)->withTrashed()->first();
|
||||
return Client::query()->without('company')->where('id', $this->client_id)->withTrashed()->first();
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ class UniqueCreditNumberRule implements Rule
|
||||
*/
|
||||
private function checkIfCreditNumberUnique() : bool
|
||||
{
|
||||
$credit = Credit::where('client_id', $this->input['client_id'])
|
||||
$credit = Credit::query()->where('client_id', $this->input['client_id'])
|
||||
->where('number', $this->input['number'])
|
||||
->withTrashed()
|
||||
->exists();
|
||||
|
@ -53,7 +53,7 @@ class UniqueInvoiceNumberRule implements Rule
|
||||
return true;
|
||||
}
|
||||
|
||||
$invoice = Invoice::where('client_id', $this->input['client_id'])
|
||||
$invoice = Invoice::query()->where('client_id', $this->input['client_id'])
|
||||
->where('number', $this->input['number'])
|
||||
->withTrashed()
|
||||
->exists();
|
||||
|
@ -46,8 +46,7 @@ class ValidRefundableRequest implements Rule
|
||||
return false;
|
||||
}
|
||||
|
||||
/**@var \App\Models\Payment $payment **/
|
||||
$payment = Payment::where('id', $this->input['id'])->withTrashed()->first();
|
||||
$payment = Payment::query()->where('id', $this->input['id'])->withTrashed()->first();
|
||||
|
||||
if (! $payment) {
|
||||
$this->error_msg = ctrans('texts.unable_to_retrieve_payment');
|
||||
@ -77,7 +76,7 @@ class ValidRefundableRequest implements Rule
|
||||
private function checkInvoiceIsPaymentable($invoice, $payment)
|
||||
{
|
||||
/**@var \App\Models\Invoice $invoice **/
|
||||
$invoice = Invoice::where('id', $invoice['invoice_id'])->where('company_id', $payment->company_id)->withTrashed()->first();
|
||||
$invoice = Invoice::query()->where('id', $invoice['invoice_id'])->where('company_id', $payment->company_id)->withTrashed()->first();
|
||||
|
||||
if (! $invoice) {
|
||||
$this->error_msg = 'Invoice not found for refund';
|
||||
|
@ -49,7 +49,7 @@ class UniqueQuoteNumberRule implements Rule
|
||||
*/
|
||||
private function checkIfQuoteNumberUnique() : bool
|
||||
{
|
||||
$quote = Quote::where('client_id', $this->input['client_id'])
|
||||
$quote = Quote::query()->where('client_id', $this->input['client_id'])
|
||||
->where('number', $this->input['number'])
|
||||
->withTrashed()
|
||||
->exists();
|
||||
|
@ -53,7 +53,7 @@ class UniqueRecurringInvoiceNumberRule implements Rule
|
||||
return true;
|
||||
}
|
||||
|
||||
$invoice = RecurringInvoice::where('client_id', $this->input['client_id'])
|
||||
$invoice = RecurringInvoice::query()->where('client_id', $this->input['client_id'])
|
||||
->where('number', $this->input['number'])
|
||||
->withTrashed()
|
||||
->exists();
|
||||
|
@ -53,7 +53,7 @@ class UniqueRecurringQuoteNumberRule implements Rule
|
||||
return true;
|
||||
}
|
||||
|
||||
$invoice = RecurringQuote::where('client_id', $this->input['client_id'])
|
||||
$invoice = RecurringQuote::query()->where('client_id', $this->input['client_id'])
|
||||
->where('number', $this->input['number'])
|
||||
->withTrashed()
|
||||
->exists();
|
||||
|
@ -95,6 +95,7 @@ class BaseImport
|
||||
ini_set('auto_detect_line_endings', '1');
|
||||
}
|
||||
|
||||
/** @var strin $base64_encoded_csv */
|
||||
$base64_encoded_csv = Cache::pull($this->hash.'-'.$entity_type);
|
||||
|
||||
if (empty($base64_encoded_csv)) {
|
||||
@ -103,7 +104,7 @@ class BaseImport
|
||||
|
||||
$csv = base64_decode($base64_encoded_csv);
|
||||
$csv = mb_convert_encoding($csv, 'UTF-8', 'UTF-8');
|
||||
nlog($csv);
|
||||
|
||||
$csv = Reader::createFromString($csv);
|
||||
$csvdelimiter = self::detectDelimiter($csv);
|
||||
|
||||
|
@ -158,7 +158,7 @@ class ProcessBankTransactions implements ShouldQueue
|
||||
$now = now();
|
||||
|
||||
foreach ($transactions as $transaction) {
|
||||
if (BankTransaction::where('transaction_id', $transaction['transaction_id'])->where('company_id', $this->company->id)->withTrashed()->exists()) {
|
||||
if (BankTransaction::query()->where('transaction_id', $transaction['transaction_id'])->where('company_id', $this->company->id)->withTrashed()->exists()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ class CompanyExport implements ShouldQueue
|
||||
})->all();
|
||||
|
||||
|
||||
$this->export_data['credit_invitations'] = CreditInvitation::where('company_id', $this->company->id)->withTrashed()->cursor()->map(function ($credit) {
|
||||
$this->export_data['credit_invitations'] = CreditInvitation::query()->where('company_id', $this->company->id)->withTrashed()->cursor()->map(function ($credit) {
|
||||
$credit = $this->transformArrayOfKeys($credit, ['company_id', 'user_id', 'client_contact_id', 'credit_id']);
|
||||
|
||||
return $credit->makeVisible(['id']);
|
||||
@ -236,7 +236,7 @@ class CompanyExport implements ShouldQueue
|
||||
})->all();
|
||||
|
||||
|
||||
$this->export_data['invoice_invitations'] = InvoiceInvitation::where('company_id', $this->company->id)->withTrashed()->cursor()->map(function ($invoice) {
|
||||
$this->export_data['invoice_invitations'] = InvoiceInvitation::query()->where('company_id', $this->company->id)->withTrashed()->cursor()->map(function ($invoice) {
|
||||
$invoice = $this->transformArrayOfKeys($invoice, ['company_id', 'user_id', 'client_contact_id', 'invoice_id']);
|
||||
|
||||
return $invoice->makeVisible(['id']);
|
||||
@ -280,7 +280,7 @@ class CompanyExport implements ShouldQueue
|
||||
})->all();
|
||||
|
||||
|
||||
$this->export_data['quote_invitations'] = QuoteInvitation::where('company_id', $this->company->id)->withTrashed()->cursor()->map(function ($quote) {
|
||||
$this->export_data['quote_invitations'] = QuoteInvitation::query()->where('company_id', $this->company->id)->withTrashed()->cursor()->map(function ($quote) {
|
||||
$quote = $this->transformArrayOfKeys($quote, ['company_id', 'user_id', 'client_contact_id', 'quote_id']);
|
||||
|
||||
return $quote->makeVisible(['id']);
|
||||
@ -301,7 +301,7 @@ class CompanyExport implements ShouldQueue
|
||||
})->all();
|
||||
|
||||
|
||||
$this->export_data['recurring_invoice_invitations'] = RecurringInvoiceInvitation::where('company_id', $this->company->id)->withTrashed()->cursor()->map(function ($ri) {
|
||||
$this->export_data['recurring_invoice_invitations'] = RecurringInvoiceInvitation::query()->where('company_id', $this->company->id)->withTrashed()->cursor()->map(function ($ri) {
|
||||
$ri = $this->transformArrayOfKeys($ri, ['company_id', 'user_id', 'client_contact_id', 'recurring_invoice_id']);
|
||||
|
||||
return $ri;
|
||||
@ -381,7 +381,7 @@ class CompanyExport implements ShouldQueue
|
||||
'company_id',]);
|
||||
})->all();
|
||||
|
||||
$this->export_data['purchase_order_invitations'] = PurchaseOrderInvitation::where('company_id', $this->company->id)->withTrashed()->cursor()->map(function ($purchase_order) {
|
||||
$this->export_data['purchase_order_invitations'] = PurchaseOrderInvitation::query()->where('company_id', $this->company->id)->withTrashed()->cursor()->map(function ($purchase_order) {
|
||||
$purchase_order = $this->transformArrayOfKeys($purchase_order, ['company_id', 'user_id', 'vendor_contact_id', 'purchase_order_id']);
|
||||
|
||||
return $purchase_order->makeVisible(['id']);
|
||||
|
@ -1482,7 +1482,7 @@ class Import implements ShouldQueue
|
||||
|
||||
try {
|
||||
$invoice_id = $this->transformId('invoices', $resource['invoice_id']);
|
||||
$entity = Invoice::where('id', $invoice_id)->withTrashed()->first();
|
||||
$entity = Invoice::query()->where('id', $invoice_id)->withTrashed()->first();
|
||||
} catch(\Exception $e) {
|
||||
nlog("i couldn't find the invoice document {$resource['invoice_id']}, perhaps it is a quote?");
|
||||
nlog($e->getMessage());
|
||||
@ -1493,7 +1493,7 @@ class Import implements ShouldQueue
|
||||
if ($try_quote && array_key_exists('quotes', $this->ids)) {
|
||||
try {
|
||||
$quote_id = $this->transformId('quotes', $resource['invoice_id']);
|
||||
$entity = Quote::where('id', $quote_id)->withTrashed()->first();
|
||||
$entity = Quote::query()->where('id', $quote_id)->withTrashed()->first();
|
||||
} catch(\Exception $e) {
|
||||
nlog("i couldn't find the quote document {$resource['invoice_id']}, perhaps it is a quote?");
|
||||
nlog($e->getMessage());
|
||||
@ -1509,7 +1509,7 @@ class Import implements ShouldQueue
|
||||
|
||||
if (array_key_exists('expense_id', $resource) && $resource['expense_id'] && array_key_exists('expenses', $this->ids)) {
|
||||
$expense_id = $this->transformId('expenses', $resource['expense_id']);
|
||||
$entity = Expense::where('id', $expense_id)->withTrashed()->first();
|
||||
$entity = Expense::query()->where('id', $expense_id)->withTrashed()->first();
|
||||
}
|
||||
|
||||
$file_url = $resource['url'];
|
||||
|
@ -37,10 +37,12 @@ use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundExceptio
|
||||
* @property int $assigned_user_id
|
||||
* @method BaseModel service()
|
||||
* @property \App\Models\Company $company
|
||||
* @property \App\Models\Vendor $vendor
|
||||
* @method static BaseModel find($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel<static> company()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel|Illuminate\Database\Eloquent\Relations\BelongsTo|\Awobaz\Compoships\Database\Eloquent\Relations\BelongsTo|\App\Models\Company company()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel|Illuminate\Database\Eloquent\Relations\HasMany|BaseModel orderBy()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel on(?string $connection = null)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude($columns)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel with($value)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel newModelQuery($query)
|
||||
@ -55,6 +57,7 @@ use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundExceptio
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel orderBy($column, $direction)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel invitations()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel whereHas($query)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel without($query)
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\InvoiceInvitation | \App\Models\CreditInvitation | \App\Models\QuoteInvitation | \App\Models\RecurringInvoiceInvitation> $invitations
|
||||
* @property-read int|null $invitations_count
|
||||
* @method int companyId()
|
||||
|
@ -79,50 +79,33 @@ use Illuminate\Contracts\Translation\HasLocalePreference;
|
||||
* @property int|null $updated_at
|
||||
* @property int|null $deleted_at
|
||||
* @property string|null $id_number
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
|
||||
* @property-read int|null $activities_count
|
||||
* @property-read \App\Models\User|null $assigned_user
|
||||
* @property-read \App\Models\Company $company
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyLedger> $company_ledger
|
||||
* @property-read int|null $company_ledger_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ClientContact> $contacts
|
||||
* @property-read int|null $contacts_count
|
||||
* @property-read \App\Models\Country|null $country
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Credit> $credits
|
||||
* @property-read int|null $credits_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
|
||||
* @property-read int|null $documents_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Expense> $expenses
|
||||
* @property-read int|null $expenses_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ClientGatewayToken> $gateway_tokens
|
||||
* @property-read int|null $gateway_tokens_count
|
||||
* @property-read mixed $hashed_id
|
||||
* @property-read \App\Models\User|null $assigned_user
|
||||
* @property-read \App\Models\User $user
|
||||
* @property-read \App\Models\Company $company
|
||||
* @property-read \App\Models\Country|null $country
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyLedger> $company_ledger
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ClientContact> $contacts
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Credit> $credits
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Expense> $expenses
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ClientGatewayToken> $gateway_tokens
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Invoice> $invoices
|
||||
* @property-read int|null $invoices_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\CompanyLedger> $ledger
|
||||
* @property-read int|null $ledger_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Payment> $payments
|
||||
* @property-read int|null $payments_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\ClientContact> $primary_contact
|
||||
* @property-read int|null $primary_contact_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Project> $projects
|
||||
* @property-read int|null $projects_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Quote> $quotes
|
||||
* @property-read int|null $quotes_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\RecurringExpense> $recurring_expenses
|
||||
* @property-read int|null $recurring_expenses_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\RecurringInvoice> $recurring_invoices
|
||||
* @property-read int|null $recurring_invoices_count
|
||||
* @property-read \App\Models\Country|null $shipping_country
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\SystemLog> $system_logs
|
||||
* @property-read int|null $system_logs_count
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Task> $tasks
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\RecurringInvoice> $recurring_invoices
|
||||
* @property-read int|null $tasks_count
|
||||
* @property-read \App\Models\User $user
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Client exclude($columns)
|
||||
* @method static \Database\Factories\ClientFactory factory($count = null, $state = [])
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Client filter(\App\Filters\QueryFilters $filters)
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Client without()
|
||||
* @property string $payment_balance
|
||||
* @property mixed $tax_data
|
||||
* @property int $is_tax_exempt
|
||||
|
@ -112,6 +112,8 @@ use Illuminate\Support\Facades\Storage;
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\PurchaseOrderInvitation> $invitations
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Invoice> $invoices
|
||||
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Payment> $payments
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Task withTrashed()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Task withoutTrashed()
|
||||
* @mixin \Eloquent
|
||||
*/
|
||||
class PurchaseOrder extends BaseModel
|
||||
|
@ -54,7 +54,7 @@ class CompanyGatewayObserver
|
||||
public function restored(CompanyGateway $company_gateway)
|
||||
{
|
||||
//When we restore the gateway, bring back the tokens!
|
||||
ClientGatewayToken::where('company_gateway_id', $company_gateway->id)
|
||||
ClientGatewayToken::query()->where('company_gateway_id', $company_gateway->id)
|
||||
->withTrashed()->cursor()->each(function ($cgt) {
|
||||
$cgt->restore();
|
||||
});
|
||||
|
@ -99,7 +99,7 @@ class ActivityRepository extends BaseRepository
|
||||
{
|
||||
if ($event_vars['token']) {
|
||||
/** @var \App\Models\CompanyToken $company_token **/
|
||||
$company_token = CompanyToken::where('token', $event_vars['token'])->first();
|
||||
$company_token = CompanyToken::query()->where('token', $event_vars['token'])->first();
|
||||
|
||||
if ($company_token) {
|
||||
return $company_token->id;
|
||||
|
@ -224,7 +224,7 @@ class BaseRepository
|
||||
/* Get array of Keys which have been removed from the invitations array and soft delete each invitation */
|
||||
$model->invitations->pluck('key')->diff($invitations->pluck('key'))->each(function ($invitation) use ($resource) {
|
||||
$invitation_class = sprintf('App\\Models\\%sInvitation', $resource);
|
||||
$invitation = $invitation_class::where('key', $invitation)->first();
|
||||
$invitation = $invitation_class::query()->where('key', $invitation)->first();
|
||||
|
||||
if ($invitation) {
|
||||
$invitation->delete();
|
||||
|
@ -41,7 +41,7 @@ class CreditRepository extends BaseRepository
|
||||
|
||||
public function getInvitationByKey($key) :?CreditInvitation
|
||||
{
|
||||
return CreditInvitation::where('key', $key)->first();
|
||||
return CreditInvitation::query()->where('key', $key)->first();
|
||||
}
|
||||
|
||||
public function delete($credit)
|
||||
|
@ -49,7 +49,7 @@ class InvoiceRepository extends BaseRepository
|
||||
|
||||
public function getInvitationByKey($key) :?InvoiceInvitation
|
||||
{
|
||||
return InvoiceInvitation::where('key', $key)->first();
|
||||
return InvoiceInvitation::query()->where('key', $key)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,9 +38,9 @@ class InvoiceMigrationRepository extends BaseRepository
|
||||
$class = new ReflectionClass($model);
|
||||
|
||||
if (array_key_exists('client_id', $data)) {
|
||||
$client = Client::where('id', $data['client_id'])->withTrashed()->first();
|
||||
$client = Client::query()->where('id', $data['client_id'])->withTrashed()->first();
|
||||
} else {
|
||||
$client = Client::where('id', $model->client_id)->withTrashed()->first();
|
||||
$client = Client::query()->where('id', $model->client_id)->withTrashed()->first();
|
||||
}
|
||||
|
||||
$state = [];
|
||||
|
@ -206,7 +206,7 @@ class PaymentMigrationRepository extends BaseRepository
|
||||
return $payment;
|
||||
}
|
||||
|
||||
$client = Client::where('id', $data['client_id'])->withTrashed()->first();
|
||||
$client = Client::query()->where('id', $data['client_id'])->withTrashed()->first();
|
||||
|
||||
$client_currency = $client->getSetting('currency_id');
|
||||
$company_currency = $client->company->settings->currency_id;
|
||||
|
@ -76,7 +76,7 @@ class PaymentRepository extends BaseRepository
|
||||
$is_existing_payment = false;
|
||||
|
||||
\DB::connection(config('database.default'))->transaction(function () use ($data) {
|
||||
$client = Client::where('id', $data['client_id'])->withTrashed()->lockForUpdate()->first();
|
||||
$client = Client::query()->where('id', $data['client_id'])->withTrashed()->lockForUpdate()->first();
|
||||
|
||||
/*We only update the paid to date ONCE per payment*/
|
||||
if (array_key_exists('invoices', $data) && is_array($data['invoices']) && count($data['invoices']) > 0) {
|
||||
|
@ -36,7 +36,7 @@ class PurchaseOrderRepository extends BaseRepository
|
||||
|
||||
/* Get array of Keys which have been removed from the invitations array and soft delete each invitation */
|
||||
$purchase_order->invitations->pluck('key')->diff($invitations->pluck('key'))->each(function ($invitation) {
|
||||
$invitation = PurchaseOrderInvitation::where('key', $invitation)->first();
|
||||
$invitation = PurchaseOrderInvitation::query()->where('key', $invitation)->first();
|
||||
|
||||
if ($invitation) {
|
||||
$invitation->delete();
|
||||
@ -86,7 +86,7 @@ class PurchaseOrderRepository extends BaseRepository
|
||||
|
||||
public function getInvitationByKey($key) :?PurchaseOrderInvitation
|
||||
{
|
||||
return PurchaseOrderInvitation::where('key', $key)->first();
|
||||
return PurchaseOrderInvitation::query()->where('key', $key)->first();
|
||||
}
|
||||
|
||||
public function getInvitation($invitation, $resource = null)
|
||||
@ -95,7 +95,7 @@ class PurchaseOrderRepository extends BaseRepository
|
||||
return false;
|
||||
}
|
||||
|
||||
$invitation = PurchaseOrderInvitation::where('key', $invitation['key'])->first();
|
||||
$invitation = PurchaseOrderInvitation::query()->where('key', $invitation['key'])->first();
|
||||
|
||||
return $invitation;
|
||||
}
|
||||
|
@ -26,6 +26,6 @@ class QuoteRepository extends BaseRepository
|
||||
|
||||
public function getInvitationByKey($key) :?QuoteInvitation
|
||||
{
|
||||
return QuoteInvitation::where('key', $key)->first();
|
||||
return QuoteInvitation::query()->where('key', $key)->first();
|
||||
}
|
||||
}
|
||||
|
@ -22,12 +22,12 @@ class TaskStatusRepository extends BaseRepository
|
||||
public function delete($task_status)
|
||||
{
|
||||
/** @var \App\Models\TaskStatus $ts **/
|
||||
$ts = TaskStatus::where('company_id', $task_status->company_id)
|
||||
$ts = TaskStatus::query()->where('company_id', $task_status->company_id)
|
||||
->first();
|
||||
|
||||
$new_status = $ts ? $ts->id : null;
|
||||
|
||||
Task::where('status_id', $task_status->id)
|
||||
Task::query()->where('status_id', $task_status->id)
|
||||
->where('company_id', $task_status->company_id)
|
||||
->update(['status_id' => $new_status]);
|
||||
|
||||
@ -60,7 +60,7 @@ class TaskStatusRepository extends BaseRepository
|
||||
public function reorder(TaskStatus $task_status)
|
||||
{
|
||||
|
||||
TaskStatus::where('company_id', $task_status->company_id)
|
||||
TaskStatus::query()->where('company_id', $task_status->company_id)
|
||||
->where('id', '!=', $task_status->id)
|
||||
->orderByRaw('ISNULL(status_order), status_order ASC')
|
||||
->cursor()
|
||||
@ -77,7 +77,7 @@ class TaskStatusRepository extends BaseRepository
|
||||
});
|
||||
|
||||
|
||||
TaskStatus::where('company_id', $task_status->company_id)
|
||||
TaskStatus::query()->where('company_id', $task_status->company_id)
|
||||
->orderByRaw('ISNULL(status_order), status_order ASC')
|
||||
->cursor()
|
||||
->each(function ($ts, $key) {
|
||||
|
@ -81,7 +81,7 @@ class UserRepository extends BaseRepository
|
||||
$user->save();
|
||||
|
||||
if (isset($data['company_user'])) {
|
||||
$cu = CompanyUser::whereUserId($user->id)->whereCompanyId($company->id)->withTrashed()->first();
|
||||
$cu = CompanyUser::query()->whereUserId($user->id)->whereCompanyId($company->id)->withTrashed()->first();
|
||||
|
||||
/*No company user exists - attach the user*/
|
||||
if (! $cu) {
|
||||
@ -129,7 +129,7 @@ class UserRepository extends BaseRepository
|
||||
|
||||
$company = auth()->user()->company();
|
||||
|
||||
$cu = CompanyUser::whereUserId($user->id)
|
||||
$cu = CompanyUser::query()->whereUserId($user->id)
|
||||
->whereCompanyId($company->id)
|
||||
->first();
|
||||
|
||||
@ -151,7 +151,7 @@ class UserRepository extends BaseRepository
|
||||
{
|
||||
$company = auth()->user()->company();
|
||||
|
||||
$cu = CompanyUser::whereUserId($user->id)
|
||||
$cu = CompanyUser::query()->whereUserId($user->id)
|
||||
->whereCompanyId($company->id)
|
||||
->first();
|
||||
|
||||
@ -190,7 +190,7 @@ class UserRepository extends BaseRepository
|
||||
}
|
||||
|
||||
if (Ninja::isHosted()) {
|
||||
$count = User::where('account_id', auth()->user()->account_id)->count();
|
||||
$count = User::query()->where('account_id', auth()->user()->account_id)->count();
|
||||
if ($count >= auth()->user()->account->num_users) {
|
||||
return;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ class BankMatchingService implements ShouldQueue
|
||||
{
|
||||
MultiDB::setDb($this->db);
|
||||
|
||||
BankTransaction::where('company_id', $this->company_id)
|
||||
BankTransaction::query()->where('company_id', $this->company_id)
|
||||
->where('status_id', BankTransaction::STATUS_UNMATCHED)
|
||||
->cursor()
|
||||
->each(function ($bt) {
|
||||
|
@ -24,7 +24,7 @@ class BankService
|
||||
public function matchInvoiceNumber()
|
||||
{
|
||||
if (strlen($this->bank_transaction->description) > 1) {
|
||||
$i = Invoice::where('company_id', $this->bank_transaction->company_id)
|
||||
$i = Invoice::query()->where('company_id', $this->bank_transaction->company_id)
|
||||
->whereIn('status_id', [1,2,3])
|
||||
->where('is_deleted', 0)
|
||||
->where('number', 'LIKE', '%'.$this->bank_transaction->description.'%')
|
||||
|
@ -49,7 +49,7 @@ class ProcessBankRules extends AbstractService
|
||||
private function matchCredit()
|
||||
{
|
||||
/** @var \Illuminate\Database\Eloquent\Collection<Invoice> $this->invoices */
|
||||
$this->invoices = Invoice::where('company_id', $this->bank_transaction->company_id)
|
||||
$this->invoices = Invoice::query()->where('company_id', $this->bank_transaction->company_id)
|
||||
->whereIn('status_id', [1,2,3])
|
||||
->where('is_deleted', 0)
|
||||
->get();
|
||||
@ -153,7 +153,7 @@ class ProcessBankRules extends AbstractService
|
||||
{
|
||||
$category = $this->categories->firstWhere('highLevelCategoryId', $this->bank_transaction->category_id);
|
||||
|
||||
$ec = ExpenseCategory::where('company_id', $this->bank_transaction->company_id)->where('bank_category_id', $this->bank_transaction->category_id)->first();
|
||||
$ec = ExpenseCategory::query()->where('company_id', $this->bank_transaction->company_id)->where('bank_category_id', $this->bank_transaction->category_id)->first();
|
||||
|
||||
if ($ec) {
|
||||
return $ec->id;
|
||||
|
@ -78,7 +78,7 @@ class ClientService
|
||||
|
||||
public function updatePaymentBalance()
|
||||
{
|
||||
$amount = Payment::where('client_id', $this->client->id)
|
||||
$amount = Payment::query()->where('client_id', $this->client->id)
|
||||
->where('is_deleted', 0)
|
||||
->whereIn('status_id', [Payment::STATUS_COMPLETED, Payment::STATUS_PENDING, Payment::STATUS_PARTIALLY_REFUNDED, Payment::STATUS_REFUNDED])
|
||||
->sum(DB::Raw('amount - applied'));
|
||||
@ -115,7 +115,7 @@ class ClientService
|
||||
|
||||
public function getCredits()
|
||||
{
|
||||
return Credit::where('client_id', $this->client->id)
|
||||
return Credit::query()->where('client_id', $this->client->id)
|
||||
->where('is_deleted', false)
|
||||
->where('balance', '>', 0)
|
||||
->where(function ($query) {
|
||||
|
@ -71,7 +71,7 @@ class Merge extends AbstractService
|
||||
{
|
||||
$balance = 0;
|
||||
|
||||
$company_ledger = CompanyLedger::whereClientId($this->client->id)
|
||||
$company_ledger = CompanyLedger::query()->whereClientId($this->client->id)
|
||||
->orderBy('id', 'DESC')
|
||||
->first();
|
||||
|
||||
|
@ -233,7 +233,7 @@ class InstantPayment
|
||||
$hash_data['billing_context'] = Cache::get($this->request->query('hash'));
|
||||
} elseif ($this->request->hash) {
|
||||
$hash_data['billing_context'] = Cache::get($this->request->hash);
|
||||
} elseif ($old_hash = PaymentHash::where('fee_invoice_id', $first_invoice->id)->whereNull('payment_id')->first()) {
|
||||
} elseif ($old_hash = PaymentHash::query()->where('fee_invoice_id', $first_invoice->id)->whereNull('payment_id')->first()) {
|
||||
if (isset($old_hash->data->billing_context)) {
|
||||
$hash_data['billing_context'] = $old_hash->data->billing_context;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ class CreateInvitations extends AbstractService
|
||||
} else {
|
||||
$contact = $contacts->first();
|
||||
|
||||
$invitation = CreditInvitation::where('company_id', $this->credit->company_id)
|
||||
$invitation = CreditInvitation::query()->where('company_id', $this->credit->company_id)
|
||||
->where('client_contact_id', $contact->id)
|
||||
->where('credit_id', $this->credit->id)
|
||||
->withTrashed()
|
||||
|
@ -250,7 +250,7 @@ class AutoBillInvoice extends AbstractService
|
||||
*/
|
||||
private function applyCreditPayment(): self
|
||||
{
|
||||
$available_credits = Credit::where('client_id', $this->client->id)
|
||||
$available_credits = Credit::query()->where('client_id', $this->client->id)
|
||||
->where('is_deleted', false)
|
||||
->where('balance', '>', 0)
|
||||
->orderBy('created_at')
|
||||
|
@ -39,7 +39,7 @@ class CreateInvitations extends AbstractService
|
||||
}
|
||||
|
||||
$contacts->each(function ($contact) {
|
||||
$invitation = InvoiceInvitation::where('company_id', $this->invoice->company_id)
|
||||
$invitation = InvoiceInvitation::query()->where('company_id', $this->invoice->company_id)
|
||||
->where('client_contact_id', $contact->id)
|
||||
->where('invoice_id', $this->invoice->id)
|
||||
->withTrashed()
|
||||
@ -62,7 +62,7 @@ class CreateInvitations extends AbstractService
|
||||
} else {
|
||||
$contact = $contacts->first();
|
||||
|
||||
$invitation = InvoiceInvitation::where('company_id', $this->invoice->company_id)
|
||||
$invitation = InvoiceInvitation::query()->where('company_id', $this->invoice->company_id)
|
||||
->where('client_contact_id', $contact->id)
|
||||
->where('invoice_id', $this->invoice->id)
|
||||
->withTrashed()
|
||||
|
@ -165,7 +165,7 @@ class HandleRestore extends AbstractService
|
||||
}
|
||||
|
||||
try {
|
||||
$exists = Invoice::where(['company_id' => $this->invoice->company_id, 'number' => $new_invoice_number])->exists();
|
||||
$exists = Invoice::query()->where(['company_id' => $this->invoice->company_id, 'number' => $new_invoice_number])->exists();
|
||||
|
||||
if ($exists) {
|
||||
$this->invoice->number = $this->getNextInvoiceNumber($this->invoice->client, $this->invoice, $this->invoice->recurring_id);
|
||||
|
@ -44,7 +44,7 @@ class HandleReversal extends AbstractService
|
||||
$total_paid = $this->invoice->amount - $this->invoice->balance;
|
||||
|
||||
/*Adjust payment applied and the paymentables to the correct amount */
|
||||
$paymentables = Paymentable::wherePaymentableType('invoices')
|
||||
$paymentables = Paymentable::query()->wherePaymentableType('invoices')
|
||||
->wherePaymentableId($this->invoice->id)
|
||||
->get();
|
||||
|
||||
|
@ -58,7 +58,7 @@ class DeletePayment
|
||||
$this->payment->is_deleted = true;
|
||||
$this->payment->delete();
|
||||
|
||||
BankTransaction::where('payment_id', $this->payment->id)->cursor()->each(function ($bt){
|
||||
BankTransaction::query()->where('payment_id', $this->payment->id)->cursor()->each(function ($bt){
|
||||
$bt->payment_id = null;
|
||||
$bt->save();
|
||||
});
|
||||
|
@ -51,7 +51,7 @@ class CreateInvitations extends AbstractService
|
||||
}
|
||||
|
||||
$contacts->each(function ($contact) {
|
||||
$invitation = PurchaseOrderInvitation::where('company_id', $this->purchase_order->company_id)
|
||||
$invitation = PurchaseOrderInvitation::query()->where('company_id', $this->purchase_order->company_id)
|
||||
->where('vendor_contact_id', $contact->id)
|
||||
->where('purchase_order_id', $this->purchase_order->id)
|
||||
->withTrashed()
|
||||
@ -78,7 +78,7 @@ class CreateInvitations extends AbstractService
|
||||
} else {
|
||||
$contact = $contacts->first();
|
||||
|
||||
$invitation = PurchaseOrderInvitation::where('company_id', $this->purchase_order->company_id)
|
||||
$invitation = PurchaseOrderInvitation::query()->where('company_id', $this->purchase_order->company_id)
|
||||
->where('vendor_contact_id', $contact->id)
|
||||
->where('purchase_order_id', $this->purchase_order->id)
|
||||
->withTrashed()
|
||||
|
@ -28,7 +28,7 @@ class PurchaseOrderInventory
|
||||
$line_items = $this->purchase_order->line_items;
|
||||
|
||||
foreach ($line_items as $item) {
|
||||
$p = Product::where('product_key', $item->product_key)->where('company_id', $this->purchase_order->company_id)->first();
|
||||
$p = Product::query()->where('product_key', $item->product_key)->where('company_id', $this->purchase_order->company_id)->first();
|
||||
|
||||
if (!$p) {
|
||||
continue;
|
||||
|
@ -65,7 +65,7 @@ class CreateInvitations
|
||||
} else {
|
||||
$contact = $contacts->first();
|
||||
|
||||
$invitation = QuoteInvitation::where('company_id', $this->quote->company_id)
|
||||
$invitation = QuoteInvitation::query()->where('company_id', $this->quote->company_id)
|
||||
->where('client_contact_id', $contact->id)
|
||||
->where('quote_id', $this->quote->id)
|
||||
->withTrashed()
|
||||
|
@ -43,7 +43,7 @@ class CreateRecurringInvitations extends AbstractService
|
||||
{
|
||||
try {
|
||||
$this->entity->client->contacts->each(function ($contact) {
|
||||
$invitation = $this->invitation_class::whereCompanyId($this->entity->company_id)
|
||||
$invitation = $this->invitation_class::query()->whereCompanyId($this->entity->company_id)
|
||||
->whereClientContactId($contact->id)
|
||||
->where($this->entity_id_name, $this->entity->id)
|
||||
->withTrashed()
|
||||
@ -64,7 +64,7 @@ class CreateRecurringInvitations extends AbstractService
|
||||
}
|
||||
|
||||
if ($this->entity->invitations()->count() == 0) {
|
||||
$invitation = $this->invitation_class::where('company_id', $this->entity->company_id)
|
||||
$invitation = $this->invitation_class::query()->where('company_id', $this->entity->company_id)
|
||||
->where($this->entity_id_name, $this->entity->id)
|
||||
->withTrashed()
|
||||
->first();
|
||||
|
@ -28,7 +28,7 @@ class UpdatePrice extends AbstractService
|
||||
foreach ($line_items as $key => $line_item) {
|
||||
|
||||
/** @var \App\Models\Product $product **/
|
||||
$product = Product::where('company_id', $this->recurring_invoice->company_id)
|
||||
$product = Product::query()->where('company_id', $this->recurring_invoice->company_id)
|
||||
->where('product_key', $line_item->product_key)
|
||||
->where('is_deleted', 0)
|
||||
->first();
|
||||
|
@ -105,7 +105,7 @@ class ClientBalanceReport extends BaseExport
|
||||
}
|
||||
private function buildRow(Client $client): array
|
||||
{
|
||||
$query = Invoice::where('client_id', $client->id)
|
||||
$query = Invoice::query()->where('client_id', $client->id)
|
||||
->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL]);
|
||||
|
||||
$query = $this->addDateRange($query);
|
||||
|
@ -99,7 +99,7 @@ class ClientSalesReport extends BaseExport
|
||||
|
||||
private function buildRow(Client $client): array
|
||||
{
|
||||
$query = Invoice::where('client_id', $client->id)
|
||||
$query = Invoice::query()->where('client_id', $client->id)
|
||||
->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL, Invoice::STATUS_PAID]);
|
||||
|
||||
$query = $this->addDateRange($query);
|
||||
|
@ -270,7 +270,7 @@ class ProfitLoss
|
||||
{
|
||||
$this->invoice_payment_map = [];
|
||||
|
||||
Payment::where('company_id', $this->company->id)
|
||||
Payment::query()->where('company_id', $this->company->id)
|
||||
->whereIn('status_id', [1, 4, 5])
|
||||
->where('is_deleted', 0)
|
||||
->whereBetween('date', [$this->start_date, $this->end_date])
|
||||
@ -452,7 +452,7 @@ class ProfitLoss
|
||||
|
||||
private function expenseData()
|
||||
{
|
||||
$expenses = Expense::where('company_id', $this->company->id)
|
||||
$expenses = Expense::query()->where('company_id', $this->company->id)
|
||||
->where('is_deleted', 0)
|
||||
->withTrashed()
|
||||
->whereBetween('date', [$this->start_date, $this->end_date])
|
||||
|
@ -347,7 +347,7 @@ class SubscriptionService
|
||||
|
||||
$outstanding_amounts = $outstanding->sum('balance');
|
||||
|
||||
$outstanding_invoice = Invoice::where('client_id', $recurring_invoice->client_id)
|
||||
$outstanding_invoice = Invoice::query()->where('client_id', $recurring_invoice->client_id)
|
||||
->where('is_deleted', 0)
|
||||
->where('is_proforma', 0)
|
||||
->where('subscription_id', $this->subscription->id)
|
||||
@ -356,7 +356,7 @@ class SubscriptionService
|
||||
|
||||
//sometimes the last document could be a credit if the user is paying for their service with credits.
|
||||
if (!$outstanding_invoice) {
|
||||
$outstanding_invoice = Credit::where('subscription_id', $this->subscription->id)
|
||||
$outstanding_invoice = Credit::query()->where('subscription_id', $this->subscription->id)
|
||||
->where('client_id', $recurring_invoice->client_id)
|
||||
->where('is_proforma', 0)
|
||||
->where('is_deleted', 0)
|
||||
@ -655,7 +655,7 @@ class SubscriptionService
|
||||
$pro_rata_refund_amount = 0;
|
||||
$is_credit = false;
|
||||
|
||||
$last_invoice = Invoice::where('subscription_id', $recurring_invoice->subscription_id)
|
||||
$last_invoice = Invoice::query()->where('subscription_id', $recurring_invoice->subscription_id)
|
||||
->where('client_id', $recurring_invoice->client_id)
|
||||
->where('is_deleted', 0)
|
||||
->withTrashed()
|
||||
@ -667,7 +667,7 @@ class SubscriptionService
|
||||
} elseif (!$last_invoice) {
|
||||
$is_credit = true;
|
||||
|
||||
$last_invoice = Credit::where('subscription_id', $recurring_invoice->subscription_id)
|
||||
$last_invoice = Credit::query()->where('subscription_id', $recurring_invoice->subscription_id)
|
||||
->where('client_id', $recurring_invoice->client_id)
|
||||
->where('is_deleted', 0)
|
||||
->withTrashed()
|
||||
@ -728,7 +728,7 @@ class SubscriptionService
|
||||
$pro_rata_charge_amount = 0;
|
||||
$pro_rata_refund_amount = 0;
|
||||
|
||||
$last_invoice = Invoice::where('subscription_id', $recurring_invoice->subscription_id)
|
||||
$last_invoice = Invoice::query()->where('subscription_id', $recurring_invoice->subscription_id)
|
||||
->where('client_id', $recurring_invoice->client_id)
|
||||
->where('is_proforma', 0)
|
||||
->where('is_deleted', 0)
|
||||
@ -773,7 +773,7 @@ class SubscriptionService
|
||||
$pro_rata_charge_amount = 0;
|
||||
$pro_rata_refund_amount = 0;
|
||||
|
||||
$last_invoice = Invoice::where('subscription_id', $recurring_invoice->subscription_id)
|
||||
$last_invoice = Invoice::query()->where('subscription_id', $recurring_invoice->subscription_id)
|
||||
->where('client_id', $recurring_invoice->client_id)
|
||||
->where('is_deleted', 0)
|
||||
->where('is_proforma', 0)
|
||||
@ -1127,7 +1127,7 @@ class SubscriptionService
|
||||
$body = $response->getStatusCode();
|
||||
}
|
||||
|
||||
$client = Client::where('id', $this->decodePrimaryKey($body['client']))->withTrashed()->first();
|
||||
$client = Client::query()->where('id', $this->decodePrimaryKey($body['client']))->withTrashed()->first();
|
||||
|
||||
SystemLogger::dispatch(
|
||||
$body,
|
||||
@ -1168,7 +1168,7 @@ class SubscriptionService
|
||||
if (is_array($keys)) {
|
||||
return Product::query()->whereIn('id', $keys)->get();
|
||||
} else {
|
||||
return Product::where('id', $keys)->get();
|
||||
return Product::query()->where('id', $keys)->get();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1188,7 +1188,7 @@ class SubscriptionService
|
||||
if (is_array($keys)) {
|
||||
return Product::query()->whereIn('id', $keys)->get();
|
||||
} else {
|
||||
return Product::where('id', $keys)->get();
|
||||
return Product::query()->where('id', $keys)->get();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1209,7 +1209,7 @@ class SubscriptionService
|
||||
if (is_array($keys)) {
|
||||
return Product::query()->whereIn('id', $keys)->get();
|
||||
} else {
|
||||
return Product::where('id', $keys)->get();
|
||||
return Product::query()->where('id', $keys)->get();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1229,7 +1229,7 @@ class SubscriptionService
|
||||
if (is_array($keys)) {
|
||||
return Product::query()->whereIn('id', $keys)->get();
|
||||
} else {
|
||||
return Product::where('id', $keys)->get();
|
||||
return Product::query()->where('id', $keys)->get();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1267,7 +1267,7 @@ class SubscriptionService
|
||||
$gateway_refund_attempted = false;
|
||||
|
||||
//only refund if they are in the refund window.
|
||||
$outstanding_invoice = Invoice::where('subscription_id', $this->subscription->id)
|
||||
$outstanding_invoice = Invoice::query()->where('subscription_id', $this->subscription->id)
|
||||
->where('client_id', $recurring_invoice->client_id)
|
||||
->where('status_id', Invoice::STATUS_PAID)
|
||||
->where('is_deleted', 0)
|
||||
|
@ -98,17 +98,17 @@ class TemplateEngine
|
||||
if (strlen($this->entity) > 1 && strlen($this->entity_id) > 1) {
|
||||
$class = 'App\Models\\' . ucfirst(Str::camel($this->entity));
|
||||
$this->entity_obj = $class::withTrashed()->where('id', $this->decodePrimaryKey($this->entity_id))->company()->first();
|
||||
} elseif (stripos($this->template, 'quote') !== false && $quote = Quote::whereHas('invitations')->withTrashed()->company()->first()) {
|
||||
} elseif (stripos($this->template, 'quote') !== false && $quote = Quote::query()->whereHas('invitations')->withTrashed()->company()->first()) {
|
||||
$this->entity = 'quote';
|
||||
$this->entity_obj = $quote;
|
||||
} elseif (stripos($this->template, 'purchase') !== false && $purchase_order = PurchaseOrder::whereHas('invitations')->withTrashed()->company()->first()) {
|
||||
} elseif (stripos($this->template, 'purchase') !== false && $purchase_order = PurchaseOrder::query()->whereHas('invitations')->withTrashed()->company()->first()) {
|
||||
$this->entity = 'purchase_order';
|
||||
$this->entity_obj = $purchase_order;
|
||||
}elseif (stripos($this->template, 'payment') !== false && $payment = Payment::withTrashed()->company()->first()) {
|
||||
}elseif (stripos($this->template, 'payment') !== false && $payment = Payment::query()->withTrashed()->company()->first()) {
|
||||
$this->entity = 'payment';
|
||||
$this->entity_obj = $payment;
|
||||
}
|
||||
elseif ($invoice = Invoice::whereHas('invitations')->withTrashed()->company()->first()) {
|
||||
elseif ($invoice = Invoice::query()->whereHas('invitations')->withTrashed()->company()->first()) {
|
||||
$this->entity_obj = $invoice;
|
||||
} else {
|
||||
$this->mockEntity();
|
||||
|
@ -23,7 +23,7 @@ return new class extends Migration {
|
||||
{
|
||||
Gateway::query()->update(['visible' => 0]);
|
||||
|
||||
Gateway::whereIn('id', [1, 15, 20, 39])->update(['visible' => 1]);
|
||||
Gateway::query()->whereIn('id', [1, 15, 20, 39])->update(['visible' => 1]);
|
||||
|
||||
Schema::table('recurring_invoice_invitations', function ($t) {
|
||||
$t->string('transaction_reference')->nullable();
|
||||
|
@ -13,8 +13,8 @@ return new class extends Migration {
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$countries = Country::whereNull('thousand_separator')->update(['thousand_separator' => '']);
|
||||
$countries = Country::whereNull('decimal_separator')->update(['decimal_separator' => '']);
|
||||
$countries = Country::query()->whereNull('thousand_separator')->update(['thousand_separator' => '']);
|
||||
$countries = Country::query()->whereNull('decimal_separator')->update(['decimal_separator' => '']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,7 +23,7 @@ return new class extends Migration {
|
||||
$table->integer('default_password_timeout')->default(30);
|
||||
});
|
||||
|
||||
Company::whereNotNull('id')->update(['default_password_timeout' => 30]);
|
||||
Company::query()->whereNotNull('id')->update(['default_password_timeout' => 30]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,8 +27,8 @@ return new class extends Migration {
|
||||
Gateway::create($gateway);
|
||||
|
||||
if (Ninja::isHosted()) {
|
||||
Gateway::whereIn('id', [20])->update(['visible' => 0]);
|
||||
Gateway::whereIn('id', [56])->update(['visible' => 1]);
|
||||
Gateway::query()->whereIn('id', [20])->update(['visible' => 0]);
|
||||
Gateway::query()->whereIn('id', [56])->update(['visible' => 1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ return new class extends Migration {
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$gateway = Gateway::where('key', '3758e7f7c6f4cecf0f4f348b9a00f456')->first();
|
||||
$gateway = Gateway::query()->where('key', '3758e7f7c6f4cecf0f4f348b9a00f456')->first();
|
||||
|
||||
if ($gateway) {
|
||||
$fields = json_decode($gateway->fields);
|
||||
@ -25,7 +25,7 @@ return new class extends Migration {
|
||||
$gateway->save();
|
||||
}
|
||||
|
||||
CompanyGateway::where('gateway_key', '3758e7f7c6f4cecf0f4f348b9a00f456')->each(function ($checkout) {
|
||||
CompanyGateway::query()->where('gateway_key', '3758e7f7c6f4cecf0f4f348b9a00f456')->each(function ($checkout) {
|
||||
$config = json_decode(decrypt($checkout->config));
|
||||
|
||||
$config->threeds = false;
|
||||
|
@ -11,7 +11,7 @@ return new class extends Migration {
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Gateway::where('id', 50)->update(['visible' => 1]);
|
||||
Gateway::query()->where('id', 50)->update(['visible' => 1]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,7 +13,7 @@ return new class extends Migration {
|
||||
public function up()
|
||||
{
|
||||
if (Gateway::count() >= 1 && Ninja::isHosted()) {
|
||||
Gateway::whereIn('id', [49])->update(['visible' => true]);
|
||||
Gateway::query()->whereIn('id', [49])->update(['visible' => true]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,14 +18,14 @@ return new class extends Migration {
|
||||
$table->unsignedInteger('assigned_user_id')->nullable()->change();
|
||||
});
|
||||
|
||||
Document::where('assigned_user_id', 0)->update(['assigned_user_id' => null]);
|
||||
Document::query()->where('assigned_user_id', 0)->update(['assigned_user_id' => null]);
|
||||
|
||||
if (config('ninja.db.multi_db_enabled')) {
|
||||
foreach (MultiDB::$dbs as $db) {
|
||||
Document::on($db)->where('assigned_user_id', 0)->update(['assigned_user_id' => null]);
|
||||
}
|
||||
} else {
|
||||
Document::where('assigned_user_id', 0)->update(['assigned_user_id' => null]);
|
||||
Document::query()->where('assigned_user_id', 0)->update(['assigned_user_id' => null]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ return new class extends Migration {
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Gateway::whereIn('id', [11])->update(['visible' => 1]);
|
||||
Gateway::query()->whereIn('id', [11])->update(['visible' => 1]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -14,7 +14,7 @@ return new class extends Migration {
|
||||
{
|
||||
Model::unguard();
|
||||
|
||||
$pt = PaymentType::where('name', 'Zelle')->first();
|
||||
$pt = PaymentType::query()->where('name', 'Zelle')->first();
|
||||
|
||||
if (! $pt) {
|
||||
$payment_type = new PaymentType();
|
||||
|
@ -25,7 +25,7 @@ return new class extends Migration {
|
||||
];
|
||||
|
||||
foreach ($currencies as $currency) {
|
||||
$record = Currency::whereCode($currency['code'])->first();
|
||||
$record = Currency::query()->whereCode($currency['code'])->first();
|
||||
if ($record) {
|
||||
$record->name = $currency['name'];
|
||||
$record->symbol = $currency['symbol'];
|
||||
|
@ -32,7 +32,7 @@ return new class extends Migration {
|
||||
];
|
||||
|
||||
foreach ($currencies as $currency) {
|
||||
$record = Currency::whereCode($currency['code'])->first();
|
||||
$record = Currency::query()->whereCode($currency['code'])->first();
|
||||
if ($record) {
|
||||
$record->name = $currency['name'];
|
||||
$record->symbol = $currency['symbol'];
|
||||
|
@ -18,7 +18,7 @@ return new class extends Migration {
|
||||
];
|
||||
|
||||
foreach ($currencies as $currency) {
|
||||
$record = Currency::whereCode($currency['code'])->first();
|
||||
$record = Currency::query()->whereCode($currency['code'])->first();
|
||||
if ($record) {
|
||||
$record->name = $currency['name'];
|
||||
$record->symbol = $currency['symbol'];
|
||||
|
@ -11,7 +11,7 @@ return new class extends Migration {
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
CompanyGateway::whereIn('gateway_key', ['d14dd26a47cecc30fdd65700bfb67b34', 'd14dd26a37cecc30fdd65700bfb55b23'])->cursor()->each(function ($cg) {
|
||||
CompanyGateway::query()->whereIn('gateway_key', ['d14dd26a47cecc30fdd65700bfb67b34', 'd14dd26a37cecc30fdd65700bfb55b23'])->cursor()->each(function ($cg) {
|
||||
$config = $cg->getConfig();
|
||||
|
||||
if (! property_exists($config, 'appleDomainVerification')) {
|
||||
|
@ -22,7 +22,7 @@ return new class extends Migration {
|
||||
$g->save();
|
||||
}
|
||||
|
||||
CompanyGateway::where('gateway_key', 'f7ec488676d310683fb51802d076d713')->cursor()->each(function ($cg) {
|
||||
CompanyGateway::query()->where('gateway_key', 'f7ec488676d310683fb51802d076d713')->cursor()->each(function ($cg) {
|
||||
$config = $cg->getConfig();
|
||||
$config->threeds = false;
|
||||
$cg->setConfig($config);
|
||||
|
@ -43,7 +43,7 @@ return new class extends Migration {
|
||||
];
|
||||
|
||||
foreach ($currencies as $currency) {
|
||||
$record = Currency::whereCode($currency['code'])->first();
|
||||
$record = Currency::query()->whereCode($currency['code'])->first();
|
||||
if ($record) {
|
||||
$record->name = $currency['name'];
|
||||
$record->symbol = $currency['symbol'];
|
||||
|
@ -19,7 +19,7 @@ return new class extends Migration {
|
||||
];
|
||||
|
||||
foreach ($currencies as $currency) {
|
||||
$record = Currency::whereCode($currency['code'])->first();
|
||||
$record = Currency::query()->whereCode($currency['code'])->first();
|
||||
if ($record) {
|
||||
$record->name = $currency['name'];
|
||||
$record->symbol = $currency['symbol'];
|
||||
|
@ -42,7 +42,7 @@ return new class extends Migration
|
||||
$table->string('name', 191)->nullable()->change();
|
||||
});
|
||||
|
||||
CompanyUser::where('is_admin', 0)->cursor()->each(function ($cu) {
|
||||
CompanyUser::query()->where('is_admin', 0)->cursor()->each(function ($cu) {
|
||||
$permissions = $cu->permissions;
|
||||
|
||||
if (!$permissions || strlen($permissions) == 0) {
|
||||
|
@ -13,7 +13,7 @@ return new class extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$ir = \App\Models\Currency::where('code', 'IDR')->first();
|
||||
$ir = \App\Models\Currency::query()->where('code', 'IDR')->first();
|
||||
|
||||
if($ir){
|
||||
$ir->thousand_separator = '.';
|
||||
|
@ -13,7 +13,7 @@ return new class extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
\App\Models\CompanyUser::where('is_admin', 0)->cursor()->each(function ($cu) {
|
||||
\App\Models\CompanyUser::query()->where('is_admin', 0)->cursor()->each(function ($cu) {
|
||||
$permissions = $cu->permissions;
|
||||
|
||||
if (!$permissions || strlen($permissions) == 0) {
|
||||
|
@ -17,6 +17,5 @@ parameters:
|
||||
ignoreErrors:
|
||||
- '#Call to an undefined method [a-zA-Z0-9\\_]+::company\(\)#'
|
||||
- '#Call to an undefined method [a-zA-Z0-9\\_]+::entityFilter\(\)#'
|
||||
- '#Call to an undefined method [a-zA-Z0-9\\_]+::withTrashed\(\)#'
|
||||
- '#Call to an undefined method [a-zA-Z0-9\\_]+::exclude\(\)#'
|
||||
- '#Undefined method#'
|
@ -147,7 +147,7 @@ class BankTransactionApiTest extends TestCase
|
||||
'ids' => [$this->encodePrimaryKey($bank_transaction->id)],
|
||||
];
|
||||
|
||||
nlog($bank_transaction->toArray());
|
||||
// nlog($bank_transaction->toArray());
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
|
@ -113,7 +113,7 @@ class ClientTest extends TestCase
|
||||
|
||||
$c = $c->fresh();
|
||||
|
||||
nlog($c->contacts->pluck('email'));
|
||||
// nlog($c->contacts->pluck('email'));
|
||||
|
||||
$this->assertEquals(4, $c->contacts->count());
|
||||
|
||||
|
@ -143,7 +143,7 @@ class CompanyTest extends TestCase
|
||||
|
||||
$company->settings = $settings;
|
||||
|
||||
nlog($company->toArray());
|
||||
// nlog($company->toArray());
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
|
Loading…
Reference in New Issue
Block a user