mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 02:36:28 +00:00 
			
		
		
		
	Replace facade
This commit is contained in:
		| @@ -29,6 +29,7 @@ use FireflyIII\Models\Transaction; | ||||
| use FireflyIII\Models\TransactionJournal; | ||||
| use Illuminate\Console\Command; | ||||
| use Illuminate\Database\QueryException; | ||||
| use Illuminate\Support\Facades\DB; | ||||
| 
 | ||||
| class RemovesEmptyJournals extends Command | ||||
| { | ||||
| @@ -56,7 +57,7 @@ class RemovesEmptyJournals extends Command | ||||
|     { | ||||
|         $set   = Transaction::whereNull('deleted_at') | ||||
|             ->groupBy('transactions.transaction_journal_id') | ||||
|             ->get([\DB::raw('COUNT(transactions.transaction_journal_id) as the_count'), 'transaction_journal_id']) // @phpstan-ignore-line
 | ||||
|             ->get([DB::raw('COUNT(transactions.transaction_journal_id) as the_count'), 'transaction_journal_id']) // @phpstan-ignore-line
 | ||||
|         ; | ||||
|         $total = 0; | ||||
| 
 | ||||
|   | ||||
| @@ -29,6 +29,7 @@ use FireflyIII\Exceptions\FireflyException; | ||||
| use FireflyIII\Models\Preference; | ||||
| use Illuminate\Console\Command; | ||||
| use Illuminate\Contracts\Encryption\DecryptException; | ||||
| use Illuminate\Support\Facades\DB; | ||||
| 
 | ||||
| class RemovesDatabaseDecryption extends Command | ||||
| { | ||||
| @@ -101,7 +102,7 @@ class RemovesDatabaseDecryption extends Command | ||||
| 
 | ||||
|     private function decryptField(string $table, string $field): void | ||||
|     { | ||||
|         $rows = \DB::table($table)->get(['id', $field]); | ||||
|         $rows = DB::table($table)->get(['id', $field]); | ||||
| 
 | ||||
|         /** @var \stdClass $row */ | ||||
|         foreach ($rows as $row) { | ||||
| @@ -135,7 +136,7 @@ class RemovesDatabaseDecryption extends Command | ||||
|         } | ||||
| 
 | ||||
|         if ($value !== $original) { | ||||
|             \DB::table($table)->where('id', $id)->update([$field => $value]); | ||||
|             DB::table($table)->where('id', $id)->update([$field => $value]); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|   | ||||
| @@ -26,6 +26,7 @@ namespace FireflyIII\Console\Commands\Upgrade; | ||||
| 
 | ||||
| use FireflyIII\Console\Commands\ShowsFriendlyMessages; | ||||
| use Illuminate\Console\Command; | ||||
| use Illuminate\Support\Facades\DB; | ||||
| 
 | ||||
| class RepairsPostgresSequences extends Command | ||||
| { | ||||
| @@ -40,7 +41,7 @@ class RepairsPostgresSequences extends Command | ||||
|      */ | ||||
|     public function handle(): int | ||||
|     { | ||||
|         if ('pgsql' !== \DB::connection()->getName()) { | ||||
|         if ('pgsql' !== DB::connection()->getName()) { | ||||
|             return 0; | ||||
|         } | ||||
|         $this->friendlyLine('Going to verify PostgreSQL table sequences.'); | ||||
| @@ -49,8 +50,8 @@ class RepairsPostgresSequences extends Command | ||||
|         foreach ($tablesToCheck as $tableToCheck) { | ||||
|             $this->friendlyLine(sprintf('Checking the next id sequence for table "%s".', $tableToCheck)); | ||||
| 
 | ||||
|             $highestId = \DB::table($tableToCheck)->select(\DB::raw('MAX(id)'))->first(); | ||||
|             $nextId    = \DB::table($tableToCheck)->select(\DB::raw(sprintf('nextval(\'%s_id_seq\')', $tableToCheck)))->first(); | ||||
|             $highestId = DB::table($tableToCheck)->select(DB::raw('MAX(id)'))->first(); | ||||
|             $nextId    = DB::table($tableToCheck)->select(DB::raw(sprintf('nextval(\'%s_id_seq\')', $tableToCheck)))->first(); | ||||
|             if (null === $nextId) { | ||||
|                 $this->friendlyInfo(sprintf('nextval is NULL for table "%s", go to next table.', $tableToCheck)); | ||||
| 
 | ||||
| @@ -58,9 +59,9 @@ class RepairsPostgresSequences extends Command | ||||
|             } | ||||
| 
 | ||||
|             if ($nextId->nextval < $highestId->max) { // @phpstan-ignore-line
 | ||||
|                 \DB::select(sprintf('SELECT setval(\'%s_id_seq\', %d)', $tableToCheck, $highestId->max)); | ||||
|                 $highestId = \DB::table($tableToCheck)->select(\DB::raw('MAX(id)'))->first(); | ||||
|                 $nextId    = \DB::table($tableToCheck)->select(\DB::raw(sprintf('nextval(\'%s_id_seq\')', $tableToCheck)))->first(); | ||||
|                 DB::select(sprintf('SELECT setval(\'%s_id_seq\', %d)', $tableToCheck, $highestId->max)); | ||||
|                 $highestId = DB::table($tableToCheck)->select(DB::raw('MAX(id)'))->first(); | ||||
|                 $nextId    = DB::table($tableToCheck)->select(DB::raw(sprintf('nextval(\'%s_id_seq\')', $tableToCheck)))->first(); | ||||
|                 if ($nextId->nextval > $highestId->max) { // @phpstan-ignore-line
 | ||||
|                     $this->friendlyInfo(sprintf('Table "%s" autoincrement corrected.', $tableToCheck)); | ||||
|                 } | ||||
|   | ||||
| @@ -31,6 +31,7 @@ use FireflyIII\Models\Transaction; | ||||
| use FireflyIII\Models\TransactionJournal; | ||||
| use Illuminate\Console\Command; | ||||
| use Illuminate\Support\Collection; | ||||
| use Illuminate\Support\Facades\DB; | ||||
| 
 | ||||
| class UpgradesJournalMetaData extends Command | ||||
| { | ||||
| @@ -86,8 +87,8 @@ class UpgradesJournalMetaData extends Command | ||||
|         $this->migrateCategories(); | ||||
| 
 | ||||
|         // empty tables
 | ||||
|         \DB::table('budget_transaction')->delete(); | ||||
|         \DB::table('category_transaction')->delete(); | ||||
|         DB::table('budget_transaction')->delete(); | ||||
|         DB::table('category_transaction')->delete(); | ||||
|     } | ||||
| 
 | ||||
|     private function migrateBudgets(): void | ||||
| @@ -108,12 +109,12 @@ class UpgradesJournalMetaData extends Command | ||||
| 
 | ||||
|     private function getIdsForBudgets(): array | ||||
|     { | ||||
|         $transactions = \DB::table('budget_transaction')->distinct()->pluck('transaction_id')->toArray(); | ||||
|         $transactions = DB::table('budget_transaction')->distinct()->pluck('transaction_id')->toArray(); | ||||
|         $array        = []; | ||||
|         $chunks       = array_chunk($transactions, 500); | ||||
| 
 | ||||
|         foreach ($chunks as $chunk) { | ||||
|             $set   = \DB::table('transactions')->whereIn('transactions.id', $chunk)->pluck('transaction_journal_id')->toArray(); | ||||
|             $set   = DB::table('transactions')->whereIn('transactions.id', $chunk)->pluck('transaction_journal_id')->toArray(); | ||||
|             $array = array_merge($array, $set); | ||||
|         } | ||||
| 
 | ||||
| @@ -171,12 +172,12 @@ class UpgradesJournalMetaData extends Command | ||||
| 
 | ||||
|     private function getIdsForCategories(): array | ||||
|     { | ||||
|         $transactions = \DB::table('category_transaction')->distinct()->pluck('transaction_id')->toArray(); | ||||
|         $transactions = DB::table('category_transaction')->distinct()->pluck('transaction_id')->toArray(); | ||||
|         $array        = []; | ||||
|         $chunks       = array_chunk($transactions, 500); | ||||
| 
 | ||||
|         foreach ($chunks as $chunk) { | ||||
|             $set   = \DB::table('transactions') | ||||
|             $set   = DB::table('transactions') | ||||
|                 ->whereIn('transactions.id', $chunk) | ||||
|                 ->pluck('transaction_journal_id')->toArray() | ||||
|             ; | ||||
|   | ||||
| @@ -35,6 +35,7 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface; | ||||
| use FireflyIII\Services\Internal\Destroy\JournalDestroyService; | ||||
| use Illuminate\Console\Command; | ||||
| use Illuminate\Support\Collection; | ||||
| use Illuminate\Support\Facades\DB; | ||||
| 
 | ||||
| class UpgradesToGroups extends Command | ||||
| { | ||||
| @@ -364,7 +365,7 @@ class UpgradesToGroups extends Command | ||||
| 
 | ||||
|     private function giveGroup(array $array): void | ||||
|     { | ||||
|         $groupId = \DB::table('transaction_groups')->insertGetId( | ||||
|         $groupId = DB::table('transaction_groups')->insertGetId( | ||||
|             [ | ||||
|                 'created_at' => date('Y-m-d H:i:s'), | ||||
|                 'updated_at' => date('Y-m-d H:i:s'), | ||||
| @@ -372,7 +373,7 @@ class UpgradesToGroups extends Command | ||||
|                 'user_id'    => $array['user_id'], | ||||
|             ] | ||||
|         ); | ||||
|         \DB::table('transaction_journals')->where('id', $array['id'])->update(['transaction_group_id' => $groupId]); | ||||
|         DB::table('transaction_journals')->where('id', $array['id'])->update(['transaction_group_id' => $groupId]); | ||||
|         ++$this->count; | ||||
|     } | ||||
| 
 | ||||
|   | ||||
| @@ -41,6 +41,7 @@ use Illuminate\Http\RedirectResponse; | ||||
| use Illuminate\Http\Request; | ||||
| use Illuminate\Http\Response; | ||||
| use Illuminate\Routing\Redirector; | ||||
| use Illuminate\Support\Facades\DB; | ||||
| use Illuminate\Support\Facades\Log; | ||||
| use Illuminate\Validation\ValidationException; | ||||
| 
 | ||||
| @@ -223,7 +224,7 @@ class LoginController extends Controller | ||||
|     { | ||||
|         Log::channel('audit')->info('Show login form (1.1).'); | ||||
| 
 | ||||
|         $count             = \DB::table('users')->count(); | ||||
|         $count             = DB::table('users')->whereNull('deleted_at')->count(); | ||||
|         $guard             = config('auth.defaults.guard'); | ||||
|         $title             = (string) trans('firefly.login_page_title'); | ||||
| 
 | ||||
|   | ||||
| @@ -42,6 +42,7 @@ use Illuminate\Http\RedirectResponse; | ||||
| use Illuminate\Http\Request; | ||||
| use Illuminate\Routing\Redirector; | ||||
| use Illuminate\Support\Facades\Artisan; | ||||
| use Illuminate\Support\Facades\DB; | ||||
| use Illuminate\Support\Facades\Log; | ||||
| use Illuminate\Support\Facades\Route; | ||||
| use Illuminate\View\View; | ||||
| @@ -268,8 +269,8 @@ class DebugController extends Controller | ||||
|     { | ||||
|         $maxFileSize   = Steam::phpBytes((string) ini_get('upload_max_filesize')); | ||||
|         $maxPostSize   = Steam::phpBytes((string) ini_get('post_max_size')); | ||||
|         $drivers       = \DB::availableDrivers(); | ||||
|         $currentDriver = \DB::getDriverName(); | ||||
|         $drivers       = DB::availableDrivers(); | ||||
|         $currentDriver = DB::getDriverName(); | ||||
| 
 | ||||
|         return [ | ||||
|             'db_version'      => app('fireflyconfig')->get('db_version', 1)->data, | ||||
|   | ||||
| @@ -42,6 +42,7 @@ use Illuminate\Http\RedirectResponse; | ||||
| use Illuminate\Http\Request; | ||||
| use Illuminate\Routing\Redirector; | ||||
| use Illuminate\Support\Collection; | ||||
| use Illuminate\Support\Facades\DB; | ||||
| use Illuminate\View\View; | ||||
| use Laravel\Passport\ClientRepository; | ||||
| 
 | ||||
| @@ -139,7 +140,7 @@ class ProfileController extends Controller | ||||
|         /** @var User $user */ | ||||
|         $user           = auth()->user(); | ||||
|         $isInternalAuth = $this->internalAuth; | ||||
|         $count          = \DB::table('oauth_clients')->where('personal_access_client', true)->whereNull('user_id')->count(); | ||||
|         $count          = DB::table('oauth_clients')->where('personal_access_client', true)->whereNull('user_id')->count(); | ||||
|         $subTitle       = $user->email; | ||||
|         $userId         = $user->id; | ||||
|         $enabled2FA     = null !== $user->mfa_secret; | ||||
|   | ||||
| @@ -28,6 +28,7 @@ use FireflyIII\Exceptions\FireflyException; | ||||
| use FireflyIII\Support\System\OAuthKeys; | ||||
| use Illuminate\Database\QueryException; | ||||
| use Illuminate\Http\Request; | ||||
| use Illuminate\Support\Facades\DB; | ||||
| use Illuminate\Support\Facades\Log; | ||||
| 
 | ||||
| /** | ||||
| @@ -83,7 +84,7 @@ class Installer | ||||
|         // Log::debug('Now in routine hasNoTables()');
 | ||||
| 
 | ||||
|         try { | ||||
|             \DB::table('users')->count(); | ||||
|             DB::table('users')->whereNull('deleted_at')->count(); | ||||
|         } catch (QueryException $e) { | ||||
|             $message = $e->getMessage(); | ||||
|             Log::error(sprintf('Error message trying to access users-table: %s', $message)); | ||||
|   | ||||
| @@ -42,6 +42,7 @@ use FireflyIII\Support\Repositories\UserGroup\UserGroupTrait; | ||||
| use Illuminate\Database\Query\JoinClause; | ||||
| use Illuminate\Pagination\LengthAwarePaginator; | ||||
| use Illuminate\Support\Collection; | ||||
| use Illuminate\Support\Facades\DB; | ||||
| use Illuminate\Support\Facades\Log; | ||||
| 
 | ||||
| /** | ||||
| @@ -556,7 +557,7 @@ class BillRepository implements BillRepositoryInterface | ||||
|         return $this->user->bills() | ||||
|             ->where('active', true) | ||||
|             ->orderBy('bills.name', 'ASC') | ||||
|             ->get(['bills.*', \DB::raw('((bills.amount_min + bills.amount_max) / 2) AS expectedAmount')]) // @phpstan-ignore-line
 | ||||
|             ->get(['bills.*', DB::raw('((bills.amount_min + bills.amount_max) / 2) AS expectedAmount')]) // @phpstan-ignore-line
 | ||||
|         ; | ||||
|     } | ||||
| 
 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user