Compare commits

...

7 Commits

27 changed files with 435 additions and 22 deletions

View File

@@ -0,0 +1,43 @@
<?php
namespace App\Enums;
enum BusinessTypeEnum: int
{
case MEDICAL = 1;
case LEGAL = 2;
case ENGINEERING = 3;
case EDUCATION = 4;
case CONSULTING = 5;
case BEAUTY = 6;
case TECHNICAL_SERVICES = 7;
case FINANCIAL = 8;
case REAL_ESTATE = 9;
case RESTAURANT = 10;
case SHOP = 11;
case TRANSPORTATION = 12;
case ART = 13;
case SPORT = 14;
case OTHER = 15;
public function label(): string
{
return match ($this) {
self::MEDICAL => 'medical',
self::LEGAL => 'legal',
self::ENGINEERING => 'engineering',
self::EDUCATION => 'education',
self::CONSULTING => 'consulting',
self::BEAUTY => 'beauty',
self::TECHNICAL_SERVICES => 'technical_services',
self::FINANCIAL => 'financial',
self::REAL_ESTATE => 'real_estate',
self::RESTAURANT => 'restaurant',
self::SHOP => 'shop',
self::TRANSPORTATION => 'transportation',
self::ART => 'art',
self::SPORT => 'sport',
self::OTHER => 'other',
};
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace App\Enums;
enum PaymentStatusEnum:int
{
case Unpaid = 0;
case Cancelled = 1;
case Expired = 2;
case Paid = 3;
case Refunded = 4;
public function label(): string
{
return match ($this) {
self::Unpaid => 'unpaid',
self::Cancelled => 'cancelled',
self::Expired => 'expired',
self::Paid => 'paid',
self::Refunded => 'refunded',
};
}
}

View File

@@ -2,13 +2,13 @@
namespace App\Models; namespace App\Models;
use Database\Factories\GatewayCategoryFactory; use Database\Factories\BusinessTypeFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
class GatewayCategory extends Model class BusinessType extends Model
{ {
/** @use HasFactory<GatewayCategoryFactory> */ /** @use HasFactory<BusinessTypeFactory> */
use HasFactory; use HasFactory;
protected $guarded = ['id']; protected $guarded = ['id'];

View File

@@ -0,0 +1,12 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class FibTransaction extends Model
{
/** @use HasFactory<\Database\Factories\FibTransactionFactory> */
use HasFactory;
}

View File

@@ -0,0 +1,12 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class FibTransactionStatus extends Model
{
/** @use HasFactory<\Database\Factories\FibTransactionStatusFactory> */
use HasFactory;
}

View File

@@ -2,13 +2,13 @@
namespace App\Models; namespace App\Models;
use Database\Factories\GatewayFactory; use Database\Factories\TransactionFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
class Gateway extends Model class Transaction extends Model
{ {
/** @use HasFactory<GatewayFactory> */ /** @use HasFactory<TransactionFactory> */
use HasFactory; use HasFactory;
protected $guarded = ['id']; protected $guarded = ['id'];

View File

@@ -0,0 +1,15 @@
<?php
namespace App\Models;
use Database\Factories\UserGatewayFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class UserGateway extends Model
{
/** @use HasFactory<UserGatewayFactory> */
use HasFactory;
protected $guarded = ['id'];
}

View File

@@ -0,0 +1,18 @@
<?php
namespace App\User\Controllers;
use App\Http\Controllers\Controller;
use App\Models\City;
use App\Traits\ApiResponse;
use Illuminate\Http\JsonResponse;
class CityController extends Controller
{
use ApiResponse;
public function list(): JsonResponse
{
return response()->json(City::all(['id', 'name']));
}
}

View File

@@ -0,0 +1,17 @@
<?php
namespace App\User\Controllers;
use App\Http\Controllers\Controller;
use App\Models\Province;
use App\Traits\ApiResponse;
use Illuminate\Http\JsonResponse;
class ProvinceController extends Controller
{
use ApiResponse;
public function list(): JsonResponse
{
return response()->json(Province::all(['id', 'name']));
}
}

View File

@@ -2,13 +2,13 @@
namespace Database\Factories; namespace Database\Factories;
use App\Models\GatewayCategory; use App\Models\BusinessType;
use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Database\Eloquent\Factories\Factory;
/** /**
* @extends Factory<GatewayCategory> * @extends Factory<BusinessType>
*/ */
class GatewayCategoryFactory extends Factory class BusinessTypeFactory extends Factory
{ {
/** /**
* Define the model's default state. * Define the model's default state.

View File

@@ -0,0 +1,24 @@
<?php
namespace Database\Factories;
use App\Models\FibTransaction;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<FibTransaction>
*/
class FibTransactionFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace Database\Factories;
use App\Models\FibTransactionStatus;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<FibTransactionStatus>
*/
class FibTransactionStatusFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}

View File

@@ -2,13 +2,13 @@
namespace Database\Factories; namespace Database\Factories;
use App\Models\Gateway; use App\Models\Transaction;
use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Database\Eloquent\Factories\Factory;
/** /**
* @extends Factory<Gateway> * @extends Factory<Transaction>
*/ */
class GatewayFactory extends Factory class TransactionFactory extends Factory
{ {
/** /**
* Define the model's default state. * Define the model's default state.

View File

@@ -0,0 +1,24 @@
<?php
namespace Database\Factories;
use App\Models\UserGateway;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<UserGateway>
*/
class UserGatewayFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}

View File

@@ -11,7 +11,7 @@ return new class extends Migration
*/ */
public function up(): void public function up(): void
{ {
Schema::create('gateway_categories', function (Blueprint $table) { Schema::create('business_types', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('name'); $table->string('name');
$table->timestamps(); $table->timestamps();
@@ -23,6 +23,6 @@ return new class extends Migration
*/ */
public function down(): void public function down(): void
{ {
Schema::dropIfExists('gateway_categories'); Schema::dropIfExists('business_types');
} }
}; };

View File

@@ -11,7 +11,7 @@ return new class extends Migration
*/ */
public function up(): void public function up(): void
{ {
Schema::create('gateways', function (Blueprint $table) { Schema::create('user_gateways', function (Blueprint $table) {
$table->id(); $table->id();
$table->foreignId('user_id')->constrained('users'); $table->foreignId('user_id')->constrained('users');
$table->string('username'); $table->string('username');
@@ -22,8 +22,8 @@ return new class extends Migration
$table->string('account_holder'); $table->string('account_holder');
$table->string('logo')->nullable(); $table->string('logo')->nullable();
$table->string('iban'); $table->string('iban');
$table->foreignId('category_id')->constrained('gateway_categories'); $table->foreignId('business_type_id')->constrained('business_types');
$table->string('category_name'); $table->string('business_type_name');
$table->timestamps(); $table->timestamps();
}); });
} }
@@ -33,6 +33,6 @@ return new class extends Migration
*/ */
public function down(): void public function down(): void
{ {
Schema::dropIfExists('gateways'); Schema::dropIfExists('user_gateways');
} }
}; };

View File

@@ -23,7 +23,7 @@ return new class extends Migration
$table->foreignId('status_id')->constrained('payment_statuses'); $table->foreignId('status_id')->constrained('payment_statuses');
$table->string('status_name'); $table->string('status_name');
$table->ipAddress('ip'); $table->ipAddress('ip');
$table->foreignId('gateway_id')->constrained('gateways'); $table->foreignId('user_gateway_id')->constrained('user_gateways');
$table->timestamps(); $table->timestamps();
}); });
} }

View File

@@ -0,0 +1,37 @@
<?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('transactions', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained('users');
$table->string('amount');
$table->string('currency');
$table->string('callback_url');
$table->string('description');
$table->dateTime('expires_in');
$table->foreignId('payment_id')->constrained('payments');
$table->string('payment_track_id');
$table->foreignId('gateway_id')->constrained('gateways');
$table->integer('status');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('transactions');
}
};

View File

@@ -0,0 +1,28 @@
<?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('fib_transaction_statuses', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('fib_transaction_statuses');
}
};

View File

@@ -0,0 +1,45 @@
<?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('fib_transactions', function (Blueprint $table) {
$table->id();
$table->foreignId('transaction_id')->constrained('transactions');
$table->text('qrcode');
$table->string('readable_code');
$table->string('personalAppLink');
$table->string('businessAppLink');
$table->string('corporateAppLink');
$table->string('paymentId');
$table->string('paymentMethod');
$table->timestamp('validUntil');
$table->foreignId('status_id')->constrained('fib_transaction_statuses');
$table->string('status_name');
$table->timestamp('paidAt');
$table->string('paidAmount');
$table->string('paidCurrency');
$table->string('decliningReason');
$table->timestamp('declinedAt');
$table->string('paidByName');
$table->string('paidByIban');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('fib_transactions');
}
};

View File

@@ -0,0 +1,34 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class BusinessTypeSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
DB::table('business_types')->insert([
['id' => 1, 'name' => 'medical', 'created_at' => now(), 'updated_at' => now()],
['id' => 2, 'name' => 'legal', 'created_at' => now(), 'updated_at' => now()],
['id' => 3, 'name' => 'engineering', 'created_at' => now(), 'updated_at' => now()],
['id' => 4, 'name' => 'education', 'created_at' => now(), 'updated_at' => now()],
['id' => 5, 'name' => 'consulting', 'created_at' => now(), 'updated_at' => now()],
['id' => 6, 'name' => 'beauty', 'created_at' => now(), 'updated_at' => now()],
['id' => 7, 'name' => 'technical_services', 'created_at' => now(), 'updated_at' => now()],
['id' => 8, 'name' => 'financial', 'created_at' => now(), 'updated_at' => now()],
['id' => 9, 'name' => 'real_estate', 'created_at' => now(), 'updated_at' => now()],
['id' => 10, 'name' => 'restaurant', 'created_at' => now(), 'updated_at' => now()],
['id' => 11, 'name' => 'shop', 'created_at' => now(), 'updated_at' => now()],
['id' => 12, 'name' => 'transportation', 'created_at' => now(), 'updated_at' => now()],
['id' => 13, 'name' => 'art', 'created_at' => now(), 'updated_at' => now()],
['id' => 14, 'name' => 'sport', 'created_at' => now(), 'updated_at' => now()],
['id' => 15, 'name' => 'other', 'created_at' => now(), 'updated_at' => now()],
]);
}
}

View File

@@ -5,7 +5,7 @@ namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class GatewayCategorySeeder extends Seeder class FibTransactionSeeder extends Seeder
{ {
/** /**
* Run the database seeds. * Run the database seeds.

View File

@@ -0,0 +1,17 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class FibTransactionStatusSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
//
}
}

View File

@@ -4,6 +4,7 @@ namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class PaymentStatusSeeder extends Seeder class PaymentStatusSeeder extends Seeder
{ {
@@ -12,6 +13,12 @@ class PaymentStatusSeeder extends Seeder
*/ */
public function run(): void public function run(): void
{ {
// DB::table('payment_statuses')->insert([
['id' => 0, 'name' => 'unpaid', 'created_at' => now(), 'updated_at' => now(),],
['id' => 1, 'name' => 'cancelled', 'created_at' => now(), 'updated_at' => now(),],
['id' => 2, 'name' => 'expired', 'created_at' => now(), 'updated_at' => now(),],
['id' => 3, 'name' => 'paid', 'created_at' => now(), 'updated_at' => now(),],
['id' => 4, 'name' => 'refunded', 'created_at' => now(), 'updated_at' => now(),],
]);
} }
} }

View File

@@ -5,7 +5,7 @@ namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
class GatewaySeeder extends Seeder class TransactionSeeder extends Seeder
{ {
/** /**
* Run the database seeds. * Run the database seeds.

View File

@@ -0,0 +1,17 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class UserGatewaySeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
//
}
}

View File

@@ -5,7 +5,9 @@ use App\Admin\Controllers\PermissionManagementController;
use App\Admin\Controllers\RoleManagementController; use App\Admin\Controllers\RoleManagementController;
use App\Admin\Controllers\UserManagementController; use App\Admin\Controllers\UserManagementController;
use App\User\Controllers\AuthController; use App\User\Controllers\AuthController;
use App\User\Controllers\CityController;
use App\User\Controllers\ProfileController; use App\User\Controllers\ProfileController;
use App\User\Controllers\ProvinceController;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
Route::prefix('auth') Route::prefix('auth')
@@ -26,3 +28,17 @@ Route::prefix('profile')
Route::post('edit', 'edit')->name('edit'); Route::post('edit', 'edit')->name('edit');
Route::post('change_password', 'changePassword')->name('changePassword'); Route::post('change_password', 'changePassword')->name('changePassword');
}); });
Route::prefix('province')
->name('province.')
->controller(ProvinceController::class)
->group(function () {
Route::get('list', 'list')->name('list');
});
Route::prefix('city')
->name('city.')
->controller(CityController::class)
->group(function () {
Route::get('list', 'list')->name('list');
});