Static analysis

This commit is contained in:
David Bomba 2025-08-15 15:34:04 +10:00
parent 86c5837929
commit 8208db23d2
10 changed files with 25 additions and 14 deletions

View File

@ -113,7 +113,6 @@ class LoginController extends BaseController
->increment() ->increment()
->batch(); ->batch();
$ip = ''; $ip = '';
if (request()->hasHeader('Cf-Connecting-Ip')) { if (request()->hasHeader('Cf-Connecting-Ip')) {
@ -330,15 +329,15 @@ class LoginController extends BaseController
Auth::login($existing_login_user, false); Auth::login($existing_login_user, false);
/** @var \App\Models\User $user */ /** @var \App\Models\User $user */
$user = auth()->user(); // $user = auth()->user();
$user->update([ $existing_login_user->update([
'oauth_user_id' => $user->id, 'oauth_user_id' => $user->id,
'oauth_provider_id' => $provider, 'oauth_provider_id' => $provider,
]); ]);
/** @var \App\Models\CompanyUser $cu */ /** @var \App\Models\CompanyUser $cu */
$cu = $this->hydrateCompanyUser($user); $cu = $this->hydrateCompanyUser($existing_login_user);
if ($cu->count() == 0) { if ($cu->count() == 0) {
return response()->json(['message' => 'User found, but not attached to any companies, please see your administrator'], 400); return response()->json(['message' => 'User found, but not attached to any companies, please see your administrator'], 400);
@ -378,22 +377,20 @@ class LoginController extends BaseController
$account = (new CreateAccount($new_account, request()->getClientIp()))->handle(); $account = (new CreateAccount($new_account, request()->getClientIp()))->handle();
Auth::login($account->default_company->owner(), false); $account_user = $account->default_company->owner();
Auth::login($account_user, false);
/** @var \App\Models\User $user */ $account_user->email_verified_at = now();
$user = auth()->user(); $account_user->save();
$user->email_verified_at = now();
$user->save();
/** @var \App\Models\CompanyUser $cu */ /** @var \App\Models\CompanyUser $cu */
$cu = $this->hydrateCompanyUser($user); $cu = $this->hydrateCompanyUser($account_user);
if ($cu->count() == 0) { if ($cu->count() == 0) {
return response()->json(['message' => 'User found, but not attached to any companies, please see your administrator'], 400); return response()->json(['message' => 'User found, but not attached to any companies, please see your administrator'], 400);
} }
if (Ninja::isHosted() && !$cu->first()->is_owner && !auth()->user()->account->isEnterprisePaidClient()) { if (Ninja::isHosted() && !$cu->first()->is_owner && !$account_user->account->isEnterprisePaidClient()) {
return response()->json(['message' => 'Pro / Free accounts only the owner can log in. Please upgrade'], 403); return response()->json(['message' => 'Pro / Free accounts only the owner can log in. Please upgrade'], 403);
} }

View File

@ -134,6 +134,9 @@ use Laracasts\Presenter\PresentableTrait;
* @property \App\DataMapper\QuickbooksSettings|null $quickbooks * @property \App\DataMapper\QuickbooksSettings|null $quickbooks
* @property boolean $smtp_verify_peer * @property boolean $smtp_verify_peer
* @property int|null $legal_entity_id * @property int|null $legal_entity_id
* @property bool $invoice_task_item_description
* @property bool $show_task_item_description
* @property bool $invoice_task_project_header
* @property-read \App\Models\Account $account * @property-read \App\Models\Account $account
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
* @property-read int|null $activities_count * @property-read int|null $activities_count

View File

@ -118,6 +118,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property \App\Models\User $user * @property \App\Models\User $user
* @property \App\Models\Client $client * @property \App\Models\Client $client
* @property \App\Models\Vendor|null $vendor * @property \App\Models\Vendor|null $vendor
* @property-read \App\Models\Location|null $location
* @property-read mixed $pivot * @property-read mixed $pivot
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities * @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\CompanyLedger> $company_ledger

View File

@ -121,12 +121,14 @@ use App\Utils\Number;
* @property-read int|null $payments_count * @property-read int|null $payments_count
* @property-read mixed $pivot * @property-read mixed $pivot
* @property-read \App\Models\Project|null $project * @property-read \App\Models\Project|null $project
* @property-read \App\Models\Quote|null $quote
* @property-read \App\Models\RecurringInvoice|null $recurring_invoice * @property-read \App\Models\RecurringInvoice|null $recurring_invoice
* @property-read \App\Models\Subscription|null $subscription * @property-read \App\Models\Subscription|null $subscription
* @property-read \App\Models\Task|null $task * @property-read \App\Models\Task|null $task
* @property-read int|null $tasks_count * @property-read int|null $tasks_count
* @property-read \App\Models\User $user * @property-read \App\Models\User $user
* @property-read \App\Models\Vendor|null $vendor * @property-read \App\Models\Vendor|null $vendor
* @property-read \App\Models\Location|null $location
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\TransactionEvent> $transaction_events * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\TransactionEvent> $transaction_events
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities * @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\CompanyLedger> $company_ledger

View File

@ -89,6 +89,9 @@ use App\Events\PurchaseOrder\PurchaseOrderWasEmailed;
* @property int|null $updated_at * @property int|null $updated_at
* @property int|null $expense_id * @property int|null $expense_id
* @property int|null $currency_id * @property int|null $currency_id
* @property int|null $location_id
* @property int|null $invoice_id
* @property object|null $tax_data
* @property-read int|null $activities_count * @property-read int|null $activities_count
* @property \App\Models\User|null $assigned_user * @property \App\Models\User|null $assigned_user
* @property \App\Models\Client|null $client * @property \App\Models\Client|null $client

View File

@ -96,6 +96,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property string|null $reminder3_sent * @property string|null $reminder3_sent
* @property string|null $reminder_last_sent * @property string|null $reminder_last_sent
* @property float $paid_to_date * @property float $paid_to_date
* @property object|null $tax_data
* @property int|null $subscription_id * @property int|null $subscription_id
* @property \App\Models\User|null $assigned_user * @property \App\Models\User|null $assigned_user
* @property \App\Models\Client $client * @property \App\Models\Client $client
@ -111,6 +112,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property-read \App\Models\Project|null $project * @property-read \App\Models\Project|null $project
* @property-read \App\Models\User $user * @property-read \App\Models\User $user
* @property-read \App\Models\Vendor|null $vendor * @property-read \App\Models\Vendor|null $vendor
* @property-read \App\Models\Location|null $location
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Activity> $activities
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Document> $documents
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Backup> $history * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Backup> $history

View File

@ -109,6 +109,7 @@ use App\Models\Presenters\RecurringInvoicePresenter;
* @property-read \App\Models\Subscription|null $subscription * @property-read \App\Models\Subscription|null $subscription
* @property-read \App\Models\User $user * @property-read \App\Models\User $user
* @property-read \App\Models\Vendor|null $vendor * @property-read \App\Models\Vendor|null $vendor
* @property-read \App\Models\Location|null $location
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude($columns) * @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude($columns)
* @method static \Database\Factories\RecurringInvoiceFactory factory($count = null, $state = []) * @method static \Database\Factories\RecurringInvoiceFactory factory($count = null, $state = [])
* @method static \Illuminate\Database\Eloquent\Builder|RecurringInvoice filter(\App\Filters\QueryFilters $filters) * @method static \Illuminate\Database\Eloquent\Builder|RecurringInvoice filter(\App\Filters\QueryFilters $filters)

View File

@ -74,6 +74,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\VendorContact> $primary_contact * @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\VendorContact> $primary_contact
* @property-read int|null $primary_contact_count * @property-read int|null $primary_contact_count
* @property-read \App\Models\User $user * @property-read \App\Models\User $user
* @property-read \Illuminate\Database\Eloquent\Collection<int, \App\Models\Location> $locations
* @property-read int|null $locations_count
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude($columns) * @method static \Illuminate\Database\Eloquent\Builder|BaseModel exclude($columns)
* @method static \Database\Factories\VendorFactory factory($count = null, $state = []) * @method static \Database\Factories\VendorFactory factory($count = null, $state = [])
* @method static \Illuminate\Database\Eloquent\Builder|Vendor filter(\App\Filters\QueryFilters $filters) * @method static \Illuminate\Database\Eloquent\Builder|Vendor filter(\App\Filters\QueryFilters $filters)

View File

@ -125,7 +125,7 @@ class TaxPeriodReport extends BaseExport
->map(function ($group) { ->map(function ($group) {
return $group->first(); return $group->first();
})->each(function ($pp){ })->each(function ($pp){
nlog($pp->paymentable->id. " - Paid Updater"); // nlog($pp->paymentable->id. " - Paid Updater");
(new InvoiceTransactionEventEntryCash())->run($pp->paymentable, \Carbon\Carbon::parse($pp->created_at)->startOfMonth()->format('Y-m-d'), \Carbon\Carbon::parse($pp->created_at)->endOfMonth()->format('Y-m-d')); (new InvoiceTransactionEventEntryCash())->run($pp->paymentable, \Carbon\Carbon::parse($pp->created_at)->startOfMonth()->format('Y-m-d'), \Carbon\Carbon::parse($pp->created_at)->endOfMonth()->format('Y-m-d'));
}); });

View File

@ -144,7 +144,7 @@ class InvoiceOutstandingTasksService
EmailStatement::THIS_YEAR => [now()->startOfDay()->firstOfYear()->format('Y-m-d'), now()->startOfDay()->lastOfYear()->format('Y-m-d')], EmailStatement::THIS_YEAR => [now()->startOfDay()->firstOfYear()->format('Y-m-d'), now()->startOfDay()->lastOfYear()->format('Y-m-d')],
EmailStatement::LAST_YEAR => [now()->startOfDay()->subYearNoOverflow()->firstOfYear()->format('Y-m-d'), now()->startOfDay()->subYearNoOverflow()->lastOfYear()->format('Y-m-d')], EmailStatement::LAST_YEAR => [now()->startOfDay()->subYearNoOverflow()->firstOfYear()->format('Y-m-d'), now()->startOfDay()->subYearNoOverflow()->lastOfYear()->format('Y-m-d')],
EmailStatement::ALL_TIME => [ EmailStatement::ALL_TIME => [
Task::query() Task::query() //@phpstan-ignore-line
->where('company_id', $this->scheduler->company_id) ->where('company_id', $this->scheduler->company_id)
->where('is_deleted', 0) ->where('is_deleted', 0)
->selectRaw('MIN(tasks.calculated_start_date) as start_date') ->selectRaw('MIN(tasks.calculated_start_date) as start_date')