Refactor ActivityLogModule and clean up seeders
- Adjusted indentation in ActivityLogModule methods for consistency. - Simplified ActivityLogRepository class by removing unnecessary lines. - Updated FillJsonData seeder to streamline the run method. - Modified various Migrator classes to change JSON data paths for testing and added sequence reset statements for better database integrity.
This commit is contained in:
@@ -27,7 +27,7 @@ class ActivityLogModule implements ModuleContract
|
|||||||
*/
|
*/
|
||||||
public function disable(): void
|
public function disable(): void
|
||||||
{
|
{
|
||||||
$this->enabled = false;
|
$this->enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,7 +35,7 @@ class ActivityLogModule implements ModuleContract
|
|||||||
*/
|
*/
|
||||||
public function enable(): void
|
public function enable(): void
|
||||||
{
|
{
|
||||||
$this->enabled = true;
|
$this->enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,9 +2,4 @@
|
|||||||
|
|
||||||
namespace App\Modules\ActivityLog\Repositories;
|
namespace App\Modules\ActivityLog\Repositories;
|
||||||
|
|
||||||
use App\Modules\ActivityLog\Models\ActivityLog;
|
class ActivityLogRepository {}
|
||||||
|
|
||||||
class ActivityLogRepository
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -9,10 +9,7 @@ class FillJsonData extends Seeder
|
|||||||
/**
|
/**
|
||||||
* Run the database seeds.
|
* Run the database seeds.
|
||||||
*/
|
*/
|
||||||
public function run(): void
|
public function run(): void {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function seedUsers(): void
|
protected function seedUsers(): void
|
||||||
{
|
{
|
||||||
@@ -73,4 +70,14 @@ class FillJsonData extends Seeder
|
|||||||
{
|
{
|
||||||
(new Migrators\ActionEventsMigrator)->migrate();
|
(new Migrators\ActionEventsMigrator)->migrate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function seedBranchUser(): void
|
||||||
|
{
|
||||||
|
(new Migrators\BranchUserMigrator)->migrate();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function seedCurrencyRates(): void
|
||||||
|
{
|
||||||
|
(new Migrators\CurrencyRatesMigrator)->migrate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,5 +22,8 @@ class ActionEventsMigrator
|
|||||||
|
|
||||||
DB::table('action_events')->insert((array) $item);
|
DB::table('action_events')->insert((array) $item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DB::statement("SELECT setval('action_events_id_seq', (SELECT MAX(id) from action_events));");
|
||||||
|
DB::statement("SELECT nextval('action_events_id_seq');");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
29
database/seeders/Migrators/BranchUserMigrator.php
Normal file
29
database/seeders/Migrators/BranchUserMigrator.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders\Migrators;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use JsonMachine\Items;
|
||||||
|
|
||||||
|
class BranchUserMigrator
|
||||||
|
{
|
||||||
|
public function migrate(): void
|
||||||
|
{
|
||||||
|
DB::table('branch_user')->truncate();
|
||||||
|
|
||||||
|
$path = database_path('data/tested/branch_user.json');
|
||||||
|
|
||||||
|
$items = Items::fromFile($path);
|
||||||
|
|
||||||
|
foreach ($items as $id => $item) {
|
||||||
|
if (! $item) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::table('branch_user')->insert((array) $item);
|
||||||
|
|
||||||
|
DB::statement("SELECT setval('branch_user_id_seq', (SELECT MAX(id) from branch_user));");
|
||||||
|
DB::statement("SELECT nextval('branch_user_id_seq');");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ class BranchesMigrator
|
|||||||
{
|
{
|
||||||
DB::table('branches')->truncate();
|
DB::table('branches')->truncate();
|
||||||
|
|
||||||
$path = database_path('data/nurmuhammetsdb/branches.json');
|
$path = database_path('data/tested/branches.json');
|
||||||
|
|
||||||
$rawData = File::json($path);
|
$rawData = File::json($path);
|
||||||
|
|
||||||
@@ -19,5 +19,8 @@ class BranchesMigrator
|
|||||||
DB::table('branches')
|
DB::table('branches')
|
||||||
->insert($data);
|
->insert($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DB::statement("SELECT setval('branches_id_seq', (SELECT MAX(id) from branches));");
|
||||||
|
DB::statement("SELECT nextval('branches_id_seq');");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class CardOrdersMigrator
|
|||||||
{
|
{
|
||||||
DB::table('card_orders')->truncate();
|
DB::table('card_orders')->truncate();
|
||||||
|
|
||||||
$path = database_path('data/nurmuhammetsdb/card_orders.json');
|
$path = database_path('data/tested/card_orders.json');
|
||||||
|
|
||||||
$rawData = File::json($path);
|
$rawData = File::json($path);
|
||||||
|
|
||||||
@@ -19,5 +19,8 @@ class CardOrdersMigrator
|
|||||||
DB::table('card_orders')
|
DB::table('card_orders')
|
||||||
->insert($data);
|
->insert($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DB::statement("SELECT setval('card_orders_id_seq', (SELECT MAX(id) from card_orders));");
|
||||||
|
DB::statement("SELECT nextval('card_orders_id_seq');");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class CardPinOrdersMigrator
|
|||||||
{
|
{
|
||||||
DB::table('card_pin_orders')->truncate();
|
DB::table('card_pin_orders')->truncate();
|
||||||
|
|
||||||
$path = database_path('data/nurmuhammetsdb/card_pins.json');
|
$path = database_path('data/tested/card_pins.json');
|
||||||
|
|
||||||
$rawData = File::json($path);
|
$rawData = File::json($path);
|
||||||
|
|
||||||
@@ -25,5 +25,8 @@ class CardPinOrdersMigrator
|
|||||||
DB::table('card_pin_orders')
|
DB::table('card_pin_orders')
|
||||||
->insert($data);
|
->insert($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DB::statement("SELECT setval('card_pin_orders_id_seq', (SELECT MAX(id) from card_pin_orders));");
|
||||||
|
DB::statement("SELECT nextval('card_pin_orders_id_seq');");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class CardStatesMigrator
|
|||||||
{
|
{
|
||||||
DB::table('card_states')->truncate();
|
DB::table('card_states')->truncate();
|
||||||
|
|
||||||
$path = database_path('data/nurmuhammetsdb/card_states.json');
|
$path = database_path('data/tested/card_states.json');
|
||||||
|
|
||||||
$rawData = File::json($path);
|
$rawData = File::json($path);
|
||||||
|
|
||||||
@@ -19,5 +19,8 @@ class CardStatesMigrator
|
|||||||
DB::table('card_states')
|
DB::table('card_states')
|
||||||
->insert($data);
|
->insert($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DB::statement("SELECT setval('card_states_id_seq', (SELECT MAX(id) from card_states));");
|
||||||
|
DB::statement("SELECT nextval('card_states_id_seq');");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class CardTypesMigrator
|
|||||||
{
|
{
|
||||||
DB::table('card_types')->truncate();
|
DB::table('card_types')->truncate();
|
||||||
|
|
||||||
$path = database_path('data/nurmuhammetsdb/card_types.json');
|
$path = database_path('data/tested/card_types.json');
|
||||||
|
|
||||||
$rawData = File::json($path);
|
$rawData = File::json($path);
|
||||||
|
|
||||||
@@ -19,5 +19,8 @@ class CardTypesMigrator
|
|||||||
DB::table('card_types')
|
DB::table('card_types')
|
||||||
->insert($data);
|
->insert($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DB::statement("SELECT setval('card_types_id_seq', (SELECT MAX(id) from card_types));");
|
||||||
|
DB::statement("SELECT nextval('card_types_id_seq');");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
29
database/seeders/Migrators/CurrencyRatesMigrator.php
Normal file
29
database/seeders/Migrators/CurrencyRatesMigrator.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders\Migrators;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use JsonMachine\Items;
|
||||||
|
|
||||||
|
class CurrencyRatesMigrator
|
||||||
|
{
|
||||||
|
public function migrate(): void
|
||||||
|
{
|
||||||
|
DB::table('currency_rates')->truncate();
|
||||||
|
|
||||||
|
$path = database_path('data/tested/currency_rates.json');
|
||||||
|
|
||||||
|
$items = Items::fromFile($path);
|
||||||
|
|
||||||
|
foreach ($items as $id => $item) {
|
||||||
|
if (! $item) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::table('currency_rates')->insert((array) $item);
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::statement("SELECT setval('currency_rates_id_seq', (SELECT MAX(id) from currency_rates));");
|
||||||
|
DB::statement("SELECT nextval('currency_rates_id_seq');");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ class LoanOrderRequiredDocsMigrator
|
|||||||
{
|
{
|
||||||
DB::table('loan_order_required_docs')->truncate();
|
DB::table('loan_order_required_docs')->truncate();
|
||||||
|
|
||||||
$path = database_path('data/nurmuhammetsdb/loan_order_required_docs.json');
|
$path = database_path('data/tested/loan_order_required_docs.json');
|
||||||
|
|
||||||
$rawData = File::json($path);
|
$rawData = File::json($path);
|
||||||
|
|
||||||
@@ -19,5 +19,8 @@ class LoanOrderRequiredDocsMigrator
|
|||||||
DB::table('loan_order_required_docs')
|
DB::table('loan_order_required_docs')
|
||||||
->insert($data);
|
->insert($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DB::statement("SELECT setval('loan_order_required_docs_id_seq', (SELECT MAX(id) from loan_order_required_docs));");
|
||||||
|
DB::statement("SELECT nextval('loan_order_required_docs_id_seq');");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
namespace Database\Seeders\Migrators;
|
namespace Database\Seeders\Migrators;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\File;
|
|
||||||
use JsonMachine\Items;
|
use JsonMachine\Items;
|
||||||
|
|
||||||
class LoanOrdersMigrator
|
class LoanOrdersMigrator
|
||||||
@@ -12,7 +11,7 @@ class LoanOrdersMigrator
|
|||||||
{
|
{
|
||||||
DB::table('loan_orders')->truncate();
|
DB::table('loan_orders')->truncate();
|
||||||
|
|
||||||
$path = database_path('data/nurmuhammetsdb/loan_orders.json');
|
$path = database_path('data/tested/loan_orders.json');
|
||||||
|
|
||||||
$items = Items::fromFile($path);
|
$items = Items::fromFile($path);
|
||||||
|
|
||||||
@@ -23,5 +22,8 @@ class LoanOrdersMigrator
|
|||||||
|
|
||||||
DB::table('loan_orders')->insert((array) $item);
|
DB::table('loan_orders')->insert((array) $item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DB::statement("SELECT setval('loan_orders_id_seq', (SELECT MAX(id) from loan_orders));");
|
||||||
|
DB::statement("SELECT nextval('loan_orders_id_seq');");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class LoanTypesMigrator
|
|||||||
{
|
{
|
||||||
DB::table('loan_types')->truncate();
|
DB::table('loan_types')->truncate();
|
||||||
|
|
||||||
$path = database_path('data/nurmuhammetsdb/loan_types.json');
|
$path = database_path('data/tested/loan_types.json');
|
||||||
|
|
||||||
$rawData = File::json($path);
|
$rawData = File::json($path);
|
||||||
|
|
||||||
@@ -19,5 +19,8 @@ class LoanTypesMigrator
|
|||||||
DB::table('loan_types')
|
DB::table('loan_types')
|
||||||
->insert($data);
|
->insert($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DB::statement("SELECT setval('loan_types_id_seq', (SELECT MAX(id) from loan_types));");
|
||||||
|
DB::statement("SELECT nextval('loan_types_id_seq');");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
29
database/seeders/Migrators/MediaMigrator.php
Normal file
29
database/seeders/Migrators/MediaMigrator.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders\Migrators;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use JsonMachine\Items;
|
||||||
|
|
||||||
|
class MediaMigrator
|
||||||
|
{
|
||||||
|
public function migrate(): void
|
||||||
|
{
|
||||||
|
DB::table('media')->truncate();
|
||||||
|
|
||||||
|
$path = database_path('data/tested/media.json');
|
||||||
|
|
||||||
|
$items = Items::fromFile($path);
|
||||||
|
|
||||||
|
foreach ($items as $id => $item) {
|
||||||
|
if (! $item) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::table('media')->insert((array) $item);
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::statement("SELECT setval('media_id_seq', (SELECT MAX(id) from media));");
|
||||||
|
DB::statement("SELECT nextval('media_id_seq');");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,5 +19,8 @@ class ProvincesMigrator
|
|||||||
DB::table('provinces')
|
DB::table('provinces')
|
||||||
->insert($data);
|
->insert($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DB::statement("SELECT setval('provinces_id_seq', (SELECT MAX(id) from provinces));");
|
||||||
|
DB::statement("SELECT nextval('provinces_id_seq');");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ class UsersMigrator
|
|||||||
'active' => $user['active'],
|
'active' => $user['active'],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DB::statement("SELECT setval('users_id_seq', (SELECT MAX(id) from users));");
|
||||||
|
DB::statement("SELECT nextval('users_id_seq');");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function extractFirstName(string $name): string
|
protected function extractFirstName(string $name): string
|
||||||
|
|||||||
@@ -60,5 +60,8 @@ class VisaMasterPaymentOrdersMigrator
|
|||||||
'deleted_at' => $item->deleted_at,
|
'deleted_at' => $item->deleted_at,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DB::statement("SELECT setval('visa_master_payment_orders_id_seq', (SELECT MAX(id) from visa_master_payment_orders));");
|
||||||
|
DB::statement("SELECT nextval('visa_master_payment_orders_id_seq');");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Database\Seeders\Migrators\ActionEventsMigrator;
|
use Database\Seeders\Migrators\MediaMigrator;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::redirect('/', filament_path());
|
Route::redirect('/', filament_path());
|
||||||
|
|
||||||
Route::get('test', function () {
|
Route::get('test', function () {
|
||||||
(new ActionEventsMigrator())->migrate();
|
|
||||||
|
(new MediaMigrator)->migrate();
|
||||||
|
|
||||||
return 'done';
|
return 'done';
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user