Compare commits
5 Commits
a9c7ec6b80
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a5bc322170 | ||
|
|
749208ac97 | ||
|
|
1870583441 | ||
|
|
76c05ebe7c | ||
|
|
515731003c |
69
app/Http/Controllers/MigrationController.php
Normal file
69
app/Http/Controllers/MigrationController.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Database\Seeders\Migrators\ActionEventsMigrator;
|
||||
use Database\Seeders\Migrators\BranchUserMigrator;
|
||||
use Database\Seeders\Migrators\CurrencyRatesMigrator;
|
||||
use Database\Seeders\Migrators\LoanOrderRequiredDocsMigrator;
|
||||
use Database\Seeders\Migrators\LoanOrdersMigrator;
|
||||
use Database\Seeders\Migrators\LoanTypesMigrator;
|
||||
use Database\Seeders\Migrators\MediaMigrator;
|
||||
use Database\Seeders\Migrators\ProvincesMigrator;
|
||||
use Database\Seeders\Migrators\BranchesMigrator;
|
||||
use Database\Seeders\Migrators\UsersMigrator;
|
||||
use Database\Seeders\Migrators\CardStatesMigrator;
|
||||
use Database\Seeders\Migrators\CardTypesMigrator;
|
||||
use Database\Seeders\Migrators\VisaMasterPaymentOrdersMigrator;
|
||||
use Database\Seeders\Migrators\VerificationsMigrator;
|
||||
use Database\Seeders\Migrators\PersonalAccessTokensMigrator;
|
||||
use Database\Seeders\Migrators\CardOrdersMigrator;
|
||||
use Database\Seeders\Migrators\VisaMasterSettingsMigrator;
|
||||
use Database\Seeders\Migrators\CardPinOrdersMigrator;
|
||||
use Database\Seeders\Migrators\ModelHasRolesMigrator;
|
||||
use Database\Seeders\Migrators\OnlinePaymentsMigrator;
|
||||
|
||||
class MigrationController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return $this->test();
|
||||
|
||||
$migrators = [
|
||||
new ActionEventsMigrator(),
|
||||
new UsersMigrator(),
|
||||
new ProvincesMigrator(),
|
||||
new BranchesMigrator(),
|
||||
new BranchUserMigrator(),
|
||||
new CardStatesMigrator(),
|
||||
new CardTypesMigrator(),
|
||||
new VerificationsMigrator(),
|
||||
new CurrencyRatesMigrator(),
|
||||
new LoanOrderRequiredDocsMigrator(),
|
||||
new PersonalAccessTokensMigrator(),
|
||||
new LoanTypesMigrator(),
|
||||
new CardOrdersMigrator(),
|
||||
new CardPinOrdersMigrator(),
|
||||
new LoanOrdersMigrator(),
|
||||
new ModelHasRolesMigrator(),
|
||||
new VisaMasterPaymentOrdersMigrator(),
|
||||
new OnlinePaymentsMigrator(),
|
||||
|
||||
new MediaMigrator(),
|
||||
];
|
||||
|
||||
foreach ($migrators as $migrator) {
|
||||
$migrator->migrate();
|
||||
}
|
||||
|
||||
return 'done';
|
||||
}
|
||||
|
||||
public function test()
|
||||
{
|
||||
(new OnlinePaymentsMigrator())->migrate();
|
||||
|
||||
return 'done';
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Facades\Date;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
@@ -28,6 +29,7 @@ class User extends Authenticatable implements FilamentUser, HasAvatar
|
||||
|
||||
use Notifiable;
|
||||
use UserAdjustments;
|
||||
use HasApiTokens;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
|
||||
64
app/Modules/ActivityLog/ActivityLogModule.php
Normal file
64
app/Modules/ActivityLog/ActivityLogModule.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\ActivityLog;
|
||||
|
||||
use App\Modules\Makeable;
|
||||
use App\Modules\ModuleContract;
|
||||
|
||||
class ActivityLogModule implements ModuleContract
|
||||
{
|
||||
use Makeable;
|
||||
|
||||
/**
|
||||
* Module is enabled
|
||||
*/
|
||||
protected bool $enabled = true;
|
||||
|
||||
/**
|
||||
* Check if is module enabled
|
||||
*/
|
||||
public function isEnabled(): bool
|
||||
{
|
||||
return $this->enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable module
|
||||
*/
|
||||
public function disable(): void
|
||||
{
|
||||
$this->enabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable module
|
||||
*/
|
||||
public function enable(): void
|
||||
{
|
||||
$this->enabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if module has a filament resource
|
||||
*/
|
||||
public function hasFilamentResource(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get module composer requirements
|
||||
*/
|
||||
public function getComposerRequirements(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get module composer suggestions
|
||||
*/
|
||||
public function getComposerSuggestions(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\ActivityLog\Repositories;
|
||||
|
||||
class ActivityLogRepository {}
|
||||
@@ -7,6 +7,7 @@ use Illuminate\Foundation\Configuration\Middleware;
|
||||
return Application::configure(basePath: dirname(__DIR__))
|
||||
->withRouting(
|
||||
web: __DIR__.'/../routes/web.php',
|
||||
api: __DIR__.'/../routes/api.php',
|
||||
commands: __DIR__.'/../routes/console.php',
|
||||
health: '/up',
|
||||
)
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
"halaxa/json-machine": "^1.2",
|
||||
"joaopaulolndev/filament-edit-profile": "^2.0",
|
||||
"laravel/framework": "^12.0",
|
||||
"laravel/sanctum": "^4.0",
|
||||
"laravel/tinker": "^2.10.1",
|
||||
"laravel/ui": "^4.6",
|
||||
"mpdf/mpdf": "^8.2",
|
||||
|
||||
65
composer.lock
generated
65
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "3fe345d22ddaf5b75cd17aaecee2b718",
|
||||
"content-hash": "018635a80495002683ac3d2f58dd6eaf",
|
||||
"packages": [
|
||||
{
|
||||
"name": "abdulmajeed-jamaan/filament-translatable-tabs",
|
||||
@@ -3355,6 +3355,69 @@
|
||||
},
|
||||
"time": "2025-11-21T20:52:52+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/sanctum",
|
||||
"version": "v4.2.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/sanctum.git",
|
||||
"reference": "f5fb373be39a246c74a060f2cf2ae2c2145b3664"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/sanctum/zipball/f5fb373be39a246c74a060f2cf2ae2c2145b3664",
|
||||
"reference": "f5fb373be39a246c74a060f2cf2ae2c2145b3664",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"illuminate/console": "^11.0|^12.0",
|
||||
"illuminate/contracts": "^11.0|^12.0",
|
||||
"illuminate/database": "^11.0|^12.0",
|
||||
"illuminate/support": "^11.0|^12.0",
|
||||
"php": "^8.2",
|
||||
"symfony/console": "^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "^1.6",
|
||||
"orchestra/testbench": "^9.15|^10.8",
|
||||
"phpstan/phpstan": "^1.10"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Laravel\\Sanctum\\SanctumServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Laravel\\Sanctum\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylor@laravel.com"
|
||||
}
|
||||
],
|
||||
"description": "Laravel Sanctum provides a featherweight authentication system for SPAs and simple APIs.",
|
||||
"keywords": [
|
||||
"auth",
|
||||
"laravel",
|
||||
"sanctum"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/laravel/sanctum/issues",
|
||||
"source": "https://github.com/laravel/sanctum"
|
||||
},
|
||||
"time": "2025-11-21T13:59:03+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/serializable-closure",
|
||||
"version": "v2.0.7",
|
||||
|
||||
84
config/sanctum.php
Normal file
84
config/sanctum.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Stateful Domains
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Requests from the following domains / hosts will receive stateful API
|
||||
| authentication cookies. Typically, these should include your local
|
||||
| and production domains which access your API via a frontend SPA.
|
||||
|
|
||||
*/
|
||||
|
||||
'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
|
||||
'%s%s',
|
||||
'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
|
||||
Sanctum::currentApplicationUrlWithPort(),
|
||||
// Sanctum::currentRequestHost(),
|
||||
))),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Sanctum Guards
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This array contains the authentication guards that will be checked when
|
||||
| Sanctum is trying to authenticate a request. If none of these guards
|
||||
| are able to authenticate the request, Sanctum will use the bearer
|
||||
| token that's present on an incoming request for authentication.
|
||||
|
|
||||
*/
|
||||
|
||||
'guard' => ['web'],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Expiration Minutes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value controls the number of minutes until an issued token will be
|
||||
| considered expired. This will override any values set in the token's
|
||||
| "expires_at" attribute, but first-party sessions are not affected.
|
||||
|
|
||||
*/
|
||||
|
||||
'expiration' => null,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Token Prefix
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Sanctum can prefix new tokens in order to take advantage of numerous
|
||||
| security scanning initiatives maintained by open source platforms
|
||||
| that notify developers if they commit tokens into repositories.
|
||||
|
|
||||
| See: https://docs.github.com/en/code-security/secret-scanning/about-secret-scanning
|
||||
|
|
||||
*/
|
||||
|
||||
'token_prefix' => env('SANCTUM_TOKEN_PREFIX', ''),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Sanctum Middleware
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When authenticating your first-party SPA with Sanctum you may need to
|
||||
| customize some of the middleware Sanctum uses while processing the
|
||||
| request. You may change the middleware listed below as required.
|
||||
|
|
||||
*/
|
||||
|
||||
'middleware' => [
|
||||
'authenticate_session' => Laravel\Sanctum\Http\Middleware\AuthenticateSession::class,
|
||||
'encrypt_cookies' => Illuminate\Cookie\Middleware\EncryptCookies::class,
|
||||
'validate_csrf_token' => Illuminate\Foundation\Http\Middleware\ValidateCsrfToken::class,
|
||||
],
|
||||
|
||||
];
|
||||
@@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateActivityLogTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->create(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('log_name')->nullable();
|
||||
$table->text('description');
|
||||
$table->nullableMorphs('subject', 'subject');
|
||||
$table->nullableMorphs('causer', 'causer');
|
||||
$table->json('properties')->nullable();
|
||||
$table->timestamps();
|
||||
$table->index('log_name');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->dropIfExists(config('activitylog.table_name'));
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddEventColumnToActivityLogTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->string('event')->nullable()->after('subject_type');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->dropColumn('event');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddBatchUuidColumnToActivityLogTable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->uuid('batch_uuid')->nullable()->after('properties');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
|
||||
$table->dropColumn('batch_uuid');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('action_events', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('batch_id')->nullable();
|
||||
$table->unsignedBigInteger('user_id')->nullable()->index();
|
||||
|
||||
$table->string('name')->index();
|
||||
|
||||
$table->string('actionable_type')->nullable()->index();
|
||||
$table->unsignedBigInteger('actionable_id')->nullable()->index();
|
||||
|
||||
$table->string('target_type')->nullable()->index();
|
||||
$table->unsignedBigInteger('target_id')->nullable()->index();
|
||||
|
||||
$table->string('model_type')->nullable()->index();
|
||||
$table->unsignedBigInteger('model_id')->nullable()->index();
|
||||
|
||||
$table->text('fields')->nullable();
|
||||
$table->string('status')->index()->default('finished');
|
||||
$table->text('exception')->nullable();
|
||||
$table->json('original')->nullable();
|
||||
$table->json('changes')->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('action_events');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('personal_access_tokens', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->morphs('tokenable');
|
||||
$table->text('name');
|
||||
$table->string('token', 64)->unique();
|
||||
$table->text('abilities')->nullable();
|
||||
$table->timestamp('last_used_at')->nullable();
|
||||
$table->timestamp('expires_at')->nullable()->index();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('personal_access_tokens');
|
||||
}
|
||||
};
|
||||
@@ -13,9 +13,7 @@ class DatabaseSeeder extends Seeder
|
||||
public function run(): void
|
||||
{
|
||||
$this->call([
|
||||
FillJsonData::class,
|
||||
// UsersTableSeeder::class,
|
||||
// ShieldSeeder::class,
|
||||
ShieldSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ class FillJsonData extends Seeder
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
public function run(): void
|
||||
{
|
||||
$this->seedVisaMasterPaymentOrders();
|
||||
|
||||
}
|
||||
|
||||
protected function seedUsers(): void
|
||||
@@ -68,4 +68,19 @@ class FillJsonData extends Seeder
|
||||
{
|
||||
(new Migrators\VisaMasterPaymentOrdersMigrator)->migrate();
|
||||
}
|
||||
|
||||
protected function seedActionEvents(): void
|
||||
{
|
||||
(new Migrators\ActionEventsMigrator)->migrate();
|
||||
}
|
||||
|
||||
protected function seedBranchUser(): void
|
||||
{
|
||||
(new Migrators\BranchUserMigrator)->migrate();
|
||||
}
|
||||
|
||||
protected function seedCurrencyRates(): void
|
||||
{
|
||||
(new Migrators\CurrencyRatesMigrator)->migrate();
|
||||
}
|
||||
}
|
||||
|
||||
29
database/seeders/Migrators/ActionEventsMigrator.php
Normal file
29
database/seeders/Migrators/ActionEventsMigrator.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders\Migrators;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use JsonMachine\Items;
|
||||
|
||||
class ActionEventsMigrator
|
||||
{
|
||||
public function migrate(): void
|
||||
{
|
||||
DB::table('action_events')->truncate();
|
||||
|
||||
$path = database_path('data/tested/action_events.json');
|
||||
|
||||
$items = Items::fromFile($path);
|
||||
|
||||
foreach ($items as $id => $item) {
|
||||
if (! $item) {
|
||||
continue;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
$path = database_path('data/nurmuhammetsdb/branches.json');
|
||||
$path = database_path('data/tested/branches.json');
|
||||
|
||||
$rawData = File::json($path);
|
||||
|
||||
@@ -19,5 +19,8 @@ class BranchesMigrator
|
||||
DB::table('branches')
|
||||
->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();
|
||||
|
||||
$path = database_path('data/nurmuhammetsdb/card_orders.json');
|
||||
$path = database_path('data/tested/card_orders.json');
|
||||
|
||||
$rawData = File::json($path);
|
||||
|
||||
@@ -19,5 +19,8 @@ class CardOrdersMigrator
|
||||
DB::table('card_orders')
|
||||
->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();
|
||||
|
||||
$path = database_path('data/nurmuhammetsdb/card_pins.json');
|
||||
$path = database_path('data/tested/card_pins.json');
|
||||
|
||||
$rawData = File::json($path);
|
||||
|
||||
@@ -25,5 +25,8 @@ class CardPinOrdersMigrator
|
||||
DB::table('card_pin_orders')
|
||||
->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();
|
||||
|
||||
$path = database_path('data/nurmuhammetsdb/card_states.json');
|
||||
$path = database_path('data/tested/card_states.json');
|
||||
|
||||
$rawData = File::json($path);
|
||||
|
||||
@@ -19,5 +19,8 @@ class CardStatesMigrator
|
||||
DB::table('card_states')
|
||||
->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();
|
||||
|
||||
$path = database_path('data/nurmuhammetsdb/card_types.json');
|
||||
$path = database_path('data/tested/card_types.json');
|
||||
|
||||
$rawData = File::json($path);
|
||||
|
||||
@@ -19,5 +19,8 @@ class CardTypesMigrator
|
||||
DB::table('card_types')
|
||||
->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();
|
||||
|
||||
$path = database_path('data/nurmuhammetsdb/loan_order_required_docs.json');
|
||||
$path = database_path('data/tested/loan_order_required_docs.json');
|
||||
|
||||
$rawData = File::json($path);
|
||||
|
||||
@@ -19,5 +19,8 @@ class LoanOrderRequiredDocsMigrator
|
||||
DB::table('loan_order_required_docs')
|
||||
->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,18 +3,15 @@
|
||||
namespace Database\Seeders\Migrators;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use JsonMachine\Items;
|
||||
|
||||
class LoanOrdersMigrator
|
||||
{
|
||||
public function migrate(): void
|
||||
{
|
||||
// Running on seeder file, may not work.
|
||||
|
||||
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);
|
||||
|
||||
@@ -25,5 +22,8 @@ class LoanOrdersMigrator
|
||||
|
||||
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();
|
||||
|
||||
$path = database_path('data/nurmuhammetsdb/loan_types.json');
|
||||
$path = database_path('data/tested/loan_types.json');
|
||||
|
||||
$rawData = File::json($path);
|
||||
|
||||
@@ -19,5 +19,8 @@ class LoanTypesMigrator
|
||||
DB::table('loan_types')
|
||||
->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');");
|
||||
}
|
||||
}
|
||||
26
database/seeders/Migrators/ModelHasRolesMigrator.php
Normal file
26
database/seeders/Migrators/ModelHasRolesMigrator.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders\Migrators;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class ModelHasRolesMigrator
|
||||
{
|
||||
public function migrate(): void
|
||||
{
|
||||
DB::table('model_has_roles')->truncate();
|
||||
|
||||
$path = database_path('data/tested/model_has_roles.json');
|
||||
|
||||
$rawData = File::json($path);
|
||||
|
||||
foreach ($rawData as $data) {
|
||||
DB::table('model_has_roles')
|
||||
->insert($data);
|
||||
}
|
||||
|
||||
DB::statement("SELECT setval('model_has_roles_id_seq', (SELECT MAX(id) from model_has_roles));");
|
||||
DB::statement("SELECT nextval('model_has_roles_id_seq');");
|
||||
}
|
||||
}
|
||||
43
database/seeders/Migrators/OnlinePaymentsMigrator.php
Normal file
43
database/seeders/Migrators/OnlinePaymentsMigrator.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders\Migrators;
|
||||
|
||||
use App\Modules\CardOrder\Models\CardOrder;
|
||||
use App\Modules\CardPinOrder\Models\CardPinOrder;
|
||||
use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class OnlinePaymentsMigrator
|
||||
{
|
||||
public function migrate(): void
|
||||
{
|
||||
DB::table('online_payments')->truncate();
|
||||
|
||||
$path = database_path('data/tested/online_payment_histories.json');
|
||||
|
||||
$rawData = File::json($path);
|
||||
|
||||
foreach ($rawData as $data) {
|
||||
if ($data['online_paymantable_type']) {
|
||||
if ($data['online_paymantable_type'] == 'App\Models\Order\Card\Requisite\CardRequisite') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$data['online_paymantable_type'] = match ($data['online_paymantable_type']) {
|
||||
'App\Models\Order\Card\CardOrder' => CardOrder::class,
|
||||
'App\Models\Order\Card\CardPin\CardPin' => CardPinOrder::class,
|
||||
// 'App\Modules\SberPaymentOrder\Models\SberPaymentOrder' => SberPaymentOrder::class,
|
||||
'App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder' => VisaMasterPaymentOrder::class,
|
||||
'\App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder' => VisaMasterPaymentOrder::class,
|
||||
};
|
||||
}
|
||||
|
||||
DB::table('online_payments')
|
||||
->insert($data);
|
||||
}
|
||||
|
||||
DB::statement("SELECT setval('online_payments_id_seq', (SELECT MAX(id) from online_payments));");
|
||||
DB::statement("SELECT nextval('online_payments_id_seq');");
|
||||
}
|
||||
}
|
||||
26
database/seeders/Migrators/PersonalAccessTokensMigrator.php
Normal file
26
database/seeders/Migrators/PersonalAccessTokensMigrator.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders\Migrators;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class PersonalAccessTokensMigrator
|
||||
{
|
||||
public function migrate(): void
|
||||
{
|
||||
DB::table('personal_access_tokens')->truncate();
|
||||
|
||||
$path = database_path('data/tested/personal_access_tokens.json');
|
||||
|
||||
$rawData = File::json($path);
|
||||
|
||||
foreach ($rawData as $data) {
|
||||
DB::table('personal_access_tokens')
|
||||
->insert($data);
|
||||
}
|
||||
|
||||
DB::statement("SELECT setval('personal_access_tokens_id_seq', (SELECT MAX(id) from personal_access_tokens));");
|
||||
DB::statement("SELECT nextval('personal_access_tokens_id_seq');");
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ class ProvincesMigrator
|
||||
{
|
||||
DB::table('provinces')->truncate();
|
||||
|
||||
$path = database_path('data/nurmuhammetsdb/provinces.json');
|
||||
$path = database_path('data/tested/provinces.json');
|
||||
|
||||
$rawData = File::json($path);
|
||||
|
||||
@@ -19,5 +19,8 @@ class ProvincesMigrator
|
||||
DB::table('provinces')
|
||||
->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'],
|
||||
]);
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
26
database/seeders/Migrators/VerificationsMigrator.php
Normal file
26
database/seeders/Migrators/VerificationsMigrator.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders\Migrators;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class VerificationsMigrator
|
||||
{
|
||||
public function migrate(): void
|
||||
{
|
||||
DB::table('verifications')->truncate();
|
||||
|
||||
$path = database_path('data/tested/verifications.json');
|
||||
|
||||
$rawData = File::json($path);
|
||||
|
||||
foreach ($rawData as $data) {
|
||||
DB::table('verifications')
|
||||
->insert($data);
|
||||
}
|
||||
|
||||
DB::statement("SELECT setval('verifications_id_seq', (SELECT MAX(id) from verifications));");
|
||||
DB::statement("SELECT nextval('verifications_id_seq');");
|
||||
}
|
||||
}
|
||||
@@ -60,5 +60,8 @@ class VisaMasterPaymentOrdersMigrator
|
||||
'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');");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class ShieldSeeder extends Seeder
|
||||
{
|
||||
app()[PermissionRegistrar::class]->forgetCachedPermissions();
|
||||
|
||||
$rolesWithPermissions = '[{"name":"super_admin","guard_name":"web","permissions":["ViewAny:Role","View:Role","Create:Role","Update:Role","Delete:Role","Restore:Role","ForceDelete:Role","ForceDeleteAny:Role","RestoreAny:Role","Replicate:Role","Reorder:Role"]}]';
|
||||
$rolesWithPermissions = '[{"id":2,"name":"super_admin","guard_name":"web","permissions":["ViewAny:Role","View:Role","Create:Role","Update:Role","Delete:Role","Restore:Role","ForceDelete:Role","ForceDeleteAny:Role","RestoreAny:Role","Replicate:Role","Reorder:Role"]}]';
|
||||
$directPermissions = '[]';
|
||||
|
||||
static::makeRolesWithPermissions($rolesWithPermissions);
|
||||
@@ -32,26 +32,32 @@ class ShieldSeeder extends Seeder
|
||||
|
||||
$additionalRoles = collect([
|
||||
[
|
||||
'id' => 3,
|
||||
'name' => 'admin',
|
||||
'guard_name' => 'web',
|
||||
],
|
||||
[
|
||||
'id' => 4,
|
||||
'name' => 'operator',
|
||||
'guard_name' => 'web',
|
||||
],
|
||||
[
|
||||
'id' => 10,
|
||||
'name' => 'operator_card',
|
||||
'guard_name' => 'web',
|
||||
],
|
||||
[
|
||||
'id' => 11,
|
||||
'name' => 'operator_loan',
|
||||
'guard_name' => 'web',
|
||||
],
|
||||
[
|
||||
'id' => 12,
|
||||
'name' => 'client',
|
||||
'guard_name' => 'web',
|
||||
],
|
||||
[
|
||||
'id' => 6,
|
||||
'name' => 'currency_maintainer',
|
||||
'guard_name' => 'web',
|
||||
],
|
||||
@@ -74,6 +80,7 @@ class ShieldSeeder extends Seeder
|
||||
|
||||
foreach ($rolePlusPermissions as $rolePlusPermission) {
|
||||
$role = $roleModel::firstOrCreate([
|
||||
'id' => $rolePlusPermission['id'],
|
||||
'name' => $rolePlusPermission['name'],
|
||||
'guard_name' => $rolePlusPermission['guard_name'],
|
||||
]);
|
||||
|
||||
8
routes/api.php
Normal file
8
routes/api.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('/user', function (Request $request) {
|
||||
return $request->user();
|
||||
})->middleware('auth:sanctum');
|
||||
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\MigrationController;
|
||||
use Database\Seeders\Migrators\MediaMigrator;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::redirect('/', filament_path());
|
||||
|
||||
Route::get('test', function () {
|
||||
return 'done';
|
||||
});
|
||||
Route::get('test', [MigrationController::class, 'index']);
|
||||
// Route::middleware(['auth'])->group(function () {
|
||||
// Route::get('password-change', [PasswordChangeController::class, 'index'])->name('password-change');
|
||||
// Route::post('password-change', [PasswordChangeController::class, 'update'])->name('password-change.update');
|
||||
|
||||
Reference in New Issue
Block a user