This commit is contained in:
2025-10-22 20:08:22 +05:00
commit 736e3bef18
2573 changed files with 120385 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
<?php
namespace App\Modules\Branch;
use App\Modules\Makeable;
use App\Modules\ModuleContract;
class BranchModule 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 [];
}
}

View File

@@ -0,0 +1,38 @@
<?php
namespace App\Modules\Branch\Controllers;
use App\Http\Controllers\Controller;
use App\Modules\Branch\Models\Branch;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class BranchController extends Controller
{
/**
* LIST branches
*
* Bank şahamçalary. http://online.tbbank.gov.tm/work-place/resources/branches
*/
public function index(Request $request): JsonResponse
{
$request->validate([
'groupBy' => ['nullable', 'string', 'in:region'],
]);
$branches = Branch::query()
->where('active', true)
->get()
->map(fn ($branch) => [
'id' => $branch->id,
'name' => $branch->name,
'region' => $branch->region,
]);
if ($request->filled('groupBy')) {
$branches = $branches->groupBy('region');
}
return response()->json($branches);
}
}

View File

@@ -0,0 +1,50 @@
<?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('branches', function (Blueprint $table) {
$table->id();
$table->string('unique_code')->nullable()->unique();
$table->json('name');
$table->json('address')->nullable();
$table->string('region', 2)->index();
$table->foreignId('province_id')->nullable()->constrained('provinces')->onDelete('restrict');
$table->json('phone_numbers')->nullable();
$table->string('billing_username')->nullable();
$table->string('billing_password')->nullable();
$table->string('billing_swift_username')->nullable();
$table->string('billing_swift_password')->nullable();
$table->string('billing_visa_master_username')->nullable();
$table->string('billing_visa_master_password')->nullable();
$table->string('billing_sber_username')->nullable();
$table->string('billing_sber_password')->nullable();
$table->boolean('active')->default(true);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('branches');
}
};

View File

@@ -0,0 +1,29 @@
<?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('branch_user', function (Blueprint $table) {
$table->id();
$table->foreignId('branch_id')->constrained()->cascadeOnDelete();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('branch_user');
}
};

View File

@@ -0,0 +1,11 @@
<?php
namespace App\Modules\Branch\Interfaces;
/**
* @property int $id
* @property int $branch_id
*
* @phpstan-require-extends \Illuminate\Database\Eloquent\Model
*/
interface BelongsToBranch {}

View File

@@ -0,0 +1,80 @@
<?php
namespace App\Modules\Branch\Models;
use App\Models\User;
use App\Modules\Province\Models\Province;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Spatie\Translatable\HasTranslations;
/**
* @property int $id
* @property string $unique_code
* @property array<string, string> $name
* @property array<string, string>|null $address
* @property string $region
* @property int|null $province_id
* @property array<string, string>|null $phone_numbers
* @property string|null $billing_username
* @property string|null $billing_password
* @property string|null $billing_swift_username
* @property string|null $billing_swift_password
* @property string|null $billing_visa_master_username
* @property string|null $billing_visa_master_password
* @property string|null $billing_sber_username
* @property string|null $billing_sber_password
* @property bool $active
* @property \Illuminate\Support\Carbon $created_at
* @property \Illuminate\Support\Carbon $updated_at
*/
class Branch extends Model
{
use HasTranslations;
/**
* Table name
*
* @var string
*/
protected $table = 'branches';
/**
* Translatable fields
*
* @var array<int, string>
*/
public $translatable = [
'name',
'address',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'active' => 'boolean',
'phone_numbers' => 'array',
];
/**
* Province relationship
*
* @return BelongsTo<Province, $this>
*/
public function province(): BelongsTo
{
return $this->belongsTo(Province::class);
}
/**
* Branches associated with user
*/
public function users(): BelongsToMany
{
return $this->belongsToMany(User::class);
}
}

View File

@@ -0,0 +1,5 @@
<?php
namespace App\Modules\Branch\Repositories;
class BranchRepository {}

View File

@@ -0,0 +1,6 @@
<?php
return [
'branch' => 'Şahamça',
'branches' => 'Şahamçalar',
];