install
This commit is contained in:
275
.ai/guidelines/db-architecture.blade.php
Normal file
275
.ai/guidelines/db-architecture.blade.php
Normal file
@@ -0,0 +1,275 @@
|
|||||||
|
### DB architecture guidelines
|
||||||
|
|
||||||
|
#### Overview
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
#### Core Concepts
|
||||||
|
|
||||||
|
- ....
|
||||||
|
|
||||||
|
#### User table
|
||||||
|
- # Model App\Models\User
|
||||||
|
- # Migrations database/migrations/0001_01_01_000000_create_users_table.php
|
||||||
|
- # Seeder database/seeders/UsersTableSeeder.php
|
||||||
|
...
|
||||||
|
|
||||||
|
##### Structure
|
||||||
|
- id
|
||||||
|
- username
|
||||||
|
- first_name
|
||||||
|
- last_name
|
||||||
|
- phone
|
||||||
|
- phone_verified_at
|
||||||
|
- locale
|
||||||
|
- password_must_be_changed
|
||||||
|
- options
|
||||||
|
- email_verified_at
|
||||||
|
- remember_token
|
||||||
|
- created_at
|
||||||
|
- updated_at
|
||||||
|
|
||||||
|
##### Indexes
|
||||||
|
- username (unique)
|
||||||
|
- phone (unique)
|
||||||
|
- email (unique)
|
||||||
|
- email_verified_at
|
||||||
|
- remember_token
|
||||||
|
|
||||||
|
##### Relations
|
||||||
|
- roles (Role model)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### Branch table
|
||||||
|
- # Model App\Modules\Branch\Models\Branch
|
||||||
|
- # Migrations app/Modules/Branch/Database/Migrations/2025_10_09_190439_create_branches_table.php
|
||||||
|
- # Seeder Not found
|
||||||
|
|
||||||
|
##### Structure
|
||||||
|
- id
|
||||||
|
- unique_code
|
||||||
|
- name (json)
|
||||||
|
- address (json)
|
||||||
|
- region (string)[in: ag, mr, ah, ak, dz, bn, lb]
|
||||||
|
- province_id
|
||||||
|
- phone_numbers (json)
|
||||||
|
- billing_username
|
||||||
|
- billing_password
|
||||||
|
- billing_swift_username
|
||||||
|
- billing_swift_password
|
||||||
|
- billing_visa_master_username
|
||||||
|
- billing_visa_master_password
|
||||||
|
- billing_sber_username
|
||||||
|
- billing_sber_password
|
||||||
|
- active
|
||||||
|
- created_at
|
||||||
|
- updated_at
|
||||||
|
|
||||||
|
##### Indexes
|
||||||
|
- unique_code (unique)
|
||||||
|
- region
|
||||||
|
|
||||||
|
##### Relations
|
||||||
|
- province (Province model)
|
||||||
|
- users (User model)
|
||||||
|
|
||||||
|
#### Province table
|
||||||
|
- # Model App\Modules\Province\Models\Province
|
||||||
|
- # Migrations app/Modules/Province/Database/Migrations/2025_10_09_185951_create_provinces_table.php
|
||||||
|
- # Seeder Not found
|
||||||
|
|
||||||
|
##### Structure
|
||||||
|
- id
|
||||||
|
- region
|
||||||
|
- name (json)
|
||||||
|
- active
|
||||||
|
- created_at
|
||||||
|
- updated_at
|
||||||
|
|
||||||
|
##### Indexes
|
||||||
|
- None
|
||||||
|
|
||||||
|
##### Relations
|
||||||
|
- None
|
||||||
|
|
||||||
|
#### LoanOrderRequiredDocs table
|
||||||
|
- # Model App\Modules\LoanOrder\Models\LoanOrderRequiredDocs
|
||||||
|
- # Migrations app/Modules/LoanOrder/Database/Migrations/2025_10_09_211513_create_loan_order_required_docs_table.php
|
||||||
|
- # Seeder Not found
|
||||||
|
|
||||||
|
##### Structure
|
||||||
|
- id
|
||||||
|
- name (text)
|
||||||
|
- value (text)
|
||||||
|
- created_at
|
||||||
|
- updated_at
|
||||||
|
|
||||||
|
##### Indexes
|
||||||
|
- None
|
||||||
|
|
||||||
|
##### Relations
|
||||||
|
- loanOrders (LoanOrder model)
|
||||||
|
|
||||||
|
#### LoanType table
|
||||||
|
- # Model App\Modules\LoanOrder\Models\LoanType
|
||||||
|
- # Migrations app/Modules/LoanOrder/Database/Migrations/2025_10_09_183412_create_loan_types_table.php
|
||||||
|
- # Seeder Not found
|
||||||
|
|
||||||
|
##### Structure
|
||||||
|
- id
|
||||||
|
- name (json)
|
||||||
|
- tax
|
||||||
|
- maturity
|
||||||
|
- notes
|
||||||
|
- active
|
||||||
|
- created_at
|
||||||
|
- updated_at
|
||||||
|
|
||||||
|
##### Indexes
|
||||||
|
- None
|
||||||
|
|
||||||
|
##### Relations
|
||||||
|
- None
|
||||||
|
|
||||||
|
#### LoanOrder table
|
||||||
|
- # Model App\Modules\LoanOrder\Models\LoanOrder
|
||||||
|
- # Migrations app/Modules/LoanOrder/Database/Migrations/2025_10_09_220443_create_loan_orders_table.php
|
||||||
|
- # Seeder Not found
|
||||||
|
|
||||||
|
##### Structure
|
||||||
|
- id
|
||||||
|
- unique_id
|
||||||
|
- source
|
||||||
|
- user_id
|
||||||
|
- loan_type
|
||||||
|
- region
|
||||||
|
- branch_id
|
||||||
|
- customer_name
|
||||||
|
- customer_surname
|
||||||
|
- customer_patronic_name
|
||||||
|
- passport_address
|
||||||
|
- real_address
|
||||||
|
- passport_serie
|
||||||
|
- passport_id
|
||||||
|
- passport_given_at
|
||||||
|
- passport_given_by
|
||||||
|
- born_place
|
||||||
|
- born_at
|
||||||
|
- email
|
||||||
|
- phone
|
||||||
|
- phone_additional
|
||||||
|
- phone_home
|
||||||
|
- work_region
|
||||||
|
- work_province_id
|
||||||
|
- work_company
|
||||||
|
- work_company_accountant_number
|
||||||
|
- work_started_at
|
||||||
|
- work_salary
|
||||||
|
- work_position
|
||||||
|
- education
|
||||||
|
- marriage_status
|
||||||
|
- passport_one (text)
|
||||||
|
- passport_two (text)
|
||||||
|
- passport_three (text)
|
||||||
|
- passport_four (text)
|
||||||
|
- loan_amount
|
||||||
|
- card_number
|
||||||
|
- card_name
|
||||||
|
- card_month
|
||||||
|
- card_year
|
||||||
|
- guarantor_name
|
||||||
|
- guarantor_surname
|
||||||
|
- guarantor_patronic_name
|
||||||
|
- guarantor_passport_serie
|
||||||
|
- guarantor_passport_id
|
||||||
|
- guarantor_card_number
|
||||||
|
- guarantor_card_name
|
||||||
|
- guarantor_card_month
|
||||||
|
- guarantor_card_year
|
||||||
|
- guarantor_note
|
||||||
|
- guarantor_2_name
|
||||||
|
- guarantor_2_surname
|
||||||
|
- guarantor_2_patronic_name
|
||||||
|
- guarantor_2_passport_serie
|
||||||
|
- guarantor_2_passport_id
|
||||||
|
- guarantor_2_card_number
|
||||||
|
- guarantor_2_card_name
|
||||||
|
- guarantor_2_card_month
|
||||||
|
- guarantor_2_card_year
|
||||||
|
- guarantor_2_note
|
||||||
|
- loan_card_number
|
||||||
|
- loan_card_name
|
||||||
|
- loan_card_month
|
||||||
|
- loan_card_year
|
||||||
|
- loan_order_required_doc_id
|
||||||
|
- status
|
||||||
|
- satisfiable
|
||||||
|
- notes (text)
|
||||||
|
- created_at
|
||||||
|
- updated_at
|
||||||
|
- deleted_at
|
||||||
|
|
||||||
|
##### Indexes
|
||||||
|
- unique_id (unique)
|
||||||
|
- source
|
||||||
|
- customer_name
|
||||||
|
- customer_surname
|
||||||
|
- passport_serie
|
||||||
|
- passport_id
|
||||||
|
- phone
|
||||||
|
- work_region
|
||||||
|
- loan_amount
|
||||||
|
|
||||||
|
##### Relations
|
||||||
|
- loanType (LoanType model)
|
||||||
|
- branch (Branch model)
|
||||||
|
- workProvince (Province model)
|
||||||
|
- user (User model)
|
||||||
|
- requiredDocs (LoanOrderRequiredDocs model)
|
||||||
|
|
||||||
|
#### OtpVerification table
|
||||||
|
- # Model App\Modules\OtpVerification\Models\OtpVerification
|
||||||
|
- # Migrations app/Modules/OtpVerification/Database/Migrations/2025_09_22_164249_create_otp_verifications_table.php
|
||||||
|
- # Seeder Not found
|
||||||
|
|
||||||
|
##### Structure
|
||||||
|
- id
|
||||||
|
- username
|
||||||
|
- code
|
||||||
|
- created_at
|
||||||
|
- updated_at
|
||||||
|
|
||||||
|
##### Indexes
|
||||||
|
- None
|
||||||
|
|
||||||
|
##### Relations
|
||||||
|
- None
|
||||||
|
|
||||||
|
#### AuthEvent table
|
||||||
|
- # Model App\Modules\BaseAuth\Models\AuthEvent
|
||||||
|
- # Migrations app/Modules/BaseAuth/Database/Migrations/2025_10_07_181725_create_auth_events_table.php
|
||||||
|
- # Seeder Not found
|
||||||
|
|
||||||
|
##### Structure
|
||||||
|
- id
|
||||||
|
- name
|
||||||
|
- request_method
|
||||||
|
- ip
|
||||||
|
- user_agent
|
||||||
|
- target_url
|
||||||
|
- options (json)
|
||||||
|
- created_at
|
||||||
|
- updated_at
|
||||||
|
|
||||||
|
##### Indexes
|
||||||
|
- name
|
||||||
|
- request_method
|
||||||
|
- ip
|
||||||
|
- user_agent
|
||||||
|
- target_url
|
||||||
|
|
||||||
|
##### Relations
|
||||||
|
- None
|
||||||
|
|
||||||
|
|
||||||
246
.ai/guidelines/modular-architecture.blade.php
Normal file
246
.ai/guidelines/modular-architecture.blade.php
Normal file
@@ -0,0 +1,246 @@
|
|||||||
|
### Modular Architecture Guidelines
|
||||||
|
|
||||||
|
#### Overview
|
||||||
|
|
||||||
|
This application uses a custom modular architecture to organize features into distinct, self-contained units called "Modules". Each module encapsulates a specific piece of functionality, including its own models, migrations, seeders, controllers, and more. The system is designed to automatically discover and register components from enabled modules.
|
||||||
|
|
||||||
|
The core of this system is the `App\Modules\ModuleRepository`, which is responsible for finding, loading, and managing all the modules in the application. A set of helper functions is provided for easy interaction with the module repository.
|
||||||
|
|
||||||
|
#### Core Concepts
|
||||||
|
|
||||||
|
- **Module**: A directory within `app/Modules` that represents a distinct feature.
|
||||||
|
- **`ModuleRepository`**: A singleton service (`App\Modules\ModuleRepository`) that manages all modules. Accessed via the `modular()` helper.
|
||||||
|
- **`ModuleServiceProvider`**: A service provider (`App\Modules\ModuleServiceProvider`) that automatically discovers and registers resources (routes, migrations, views, etc.) from all enabled modules.
|
||||||
|
- **`ModuleContract`**: An interface (`App\Modules\ModuleContract`) that every module's main class must implement. It defines the basic contract for a module.
|
||||||
|
- **`BaseModule`**: A wrapper class (`App\Modules\BaseModule`) that holds information about a module, such as its path, name, and an instance of its `ModuleContract`.
|
||||||
|
- **Helpers**: Global functions defined in `app/Helpers/helpers.php` to simplify interaction with the modular system.
|
||||||
|
- **Core Module**: A special module located in `app/Modules/Core` that provides Artisan commands for creating new modules and their components.
|
||||||
|
|
||||||
|
#### Module Structure
|
||||||
|
|
||||||
|
Every module is a directory located in `app/Modules/`. For a module named `Example`, the structure would be `app/Modules/Example/`.
|
||||||
|
|
||||||
|
##### Required Structure
|
||||||
|
|
||||||
|
- `app/Modules/Example/ExampleModule.php`: This is the main class for the module. It **must** implement `App\Modules\ModuleContract`.
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\Example;
|
||||||
|
|
||||||
|
use App\Modules\ModuleContract;
|
||||||
|
|
||||||
|
class ExampleModule implements ModuleContract
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Check if module is enabled
|
||||||
|
*/
|
||||||
|
public function isEnabled(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable module
|
||||||
|
*/
|
||||||
|
public function disable(): void
|
||||||
|
{
|
||||||
|
// Logic to disable the module
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable module
|
||||||
|
*/
|
||||||
|
public function enable(): void
|
||||||
|
{
|
||||||
|
// Logic to enable the module
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if module has a filament resource
|
||||||
|
*/
|
||||||
|
public function hasFilamentResource(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get module composer requirements
|
||||||
|
*
|
||||||
|
* @return array<int, \App\Modules\Core\ModulePackage>
|
||||||
|
*/
|
||||||
|
public function getComposerRequirements(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get module composer suggestions
|
||||||
|
*
|
||||||
|
* @return array<int, \App\Modules\Core\ModulePackage>
|
||||||
|
*/
|
||||||
|
public function getComposerSuggestions(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Automatic Discovery
|
||||||
|
|
||||||
|
The `ModuleServiceProvider` automatically discovers and registers the following directories and files for all **enabled** modules. The paths shown are for an `Example` module. If module name is `MyModule`, kebab naming will be used for routes, helpers, and config files will be `app/Modules/MyModule/Configs/my-module-config.php`, `app/Modules/MyModule/Routes/my-module-routes.php`, `app/Modules/MyModule/my-module-helpers.php`.
|
||||||
|
|
||||||
|
- **Configurations**: `app/Modules/Example/Configs/example-config.php`
|
||||||
|
- **Migrations**: `app/Modules/Example/Database/Migrations/`
|
||||||
|
- **Seeders**: `app/Modules/Example/Database/Seeders/`
|
||||||
|
- **Routes**: `app/Modules/Example/Routes/example-routes.php`
|
||||||
|
- **Views**: `app/Modules/Example/Resources/Views/`
|
||||||
|
- **Translations**: `app/Modules/Example/Resources/lang/`
|
||||||
|
- **Helper Files**: `app/Modules/Example/example-helpers.php`
|
||||||
|
|
||||||
|
##### Composer Dependencies
|
||||||
|
|
||||||
|
Modules can declare Composer package dependencies. This is useful for making a module's requirements explicit. There are two types of dependencies you can define: requirements and suggestions.
|
||||||
|
|
||||||
|
- **Requirements**: Packages that are essential for the module to function correctly.
|
||||||
|
- **Suggestions**: Packages that are recommended but not strictly necessary.
|
||||||
|
|
||||||
|
These dependencies are defined in the module's main class by implementing the `getComposerRequirements()` and `getComposerSuggestions()` methods from the `ModuleContract` interface. These methods should return an array of `ModulePackage` objects.
|
||||||
|
|
||||||
|
**Note:** Declaring a dependency does not automatically install it. This feature is for informational purposes, helping developers understand the module's dependencies.
|
||||||
|
|
||||||
|
Here is an example of how to declare a required package and a suggested module dependency:
|
||||||
|
|
||||||
|
```php
|
||||||
|
// app/Modules/Example/ExampleModule.php
|
||||||
|
|
||||||
|
use App\Modules\Core\ModulePackage;
|
||||||
|
use App\Modules\Core\ModulePackageType;
|
||||||
|
|
||||||
|
// ...
|
||||||
|
|
||||||
|
public function getComposerRequirements(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
new ModulePackage(
|
||||||
|
type: ModulePackageType::PACKAGE,
|
||||||
|
name: 'spatie/laravel-translatable',
|
||||||
|
message: 'This package is used for translatable models.',
|
||||||
|
version: '^8.0'
|
||||||
|
)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getComposerSuggestions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
new ModulePackage(
|
||||||
|
type: ModulePackageType::MODULE,
|
||||||
|
name: 'OtherModule',
|
||||||
|
message: 'This module provides additional related functionality.'
|
||||||
|
)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Conventional Structure
|
||||||
|
|
||||||
|
Following the conventional structure is essential for the automatic discovery mechanism to work.
|
||||||
|
|
||||||
|
```
|
||||||
|
app/Modules/Example/
|
||||||
|
├── Configs/
|
||||||
|
│ └── example-config.php
|
||||||
|
├── Database/
|
||||||
|
│ ├── Migrations/
|
||||||
|
│ │ └── 2025_09_22_000000_create_example_table.php
|
||||||
|
│ └── Seeders/
|
||||||
|
│ └── ExampleSeeder.php
|
||||||
|
├── Http/
|
||||||
|
│ ├── Controllers/
|
||||||
|
│ └── Requests/
|
||||||
|
├── Models/
|
||||||
|
│ └── Example.php
|
||||||
|
├── Repositories/
|
||||||
|
├── Resources/
|
||||||
|
│ ├── Lang/
|
||||||
|
│ └── Views/
|
||||||
|
├── Routes/
|
||||||
|
│ └── example-routes.php
|
||||||
|
├── example-helpers.php
|
||||||
|
└── ExampleModule.php
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Creating a New Module
|
||||||
|
|
||||||
|
The `Core` module provides an Artisan command to simplify the creation of new modules.
|
||||||
|
|
||||||
|
1. **Run the `make:module` command**:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
php artisan make:module NewFeature
|
||||||
|
```
|
||||||
|
|
||||||
|
This command will scaffold a new module in `app/Modules/NewFeature` with the necessary directory structure and default files, including the `NewFeatureModule.php` class, a model, controller, repository, and migration.
|
||||||
|
|
||||||
|
You can use the `--plain` option to create a module with only the main module class and an empty directory.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
php artisan make:module NewFeature --plain
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Add Components**: Add any additional migrations, seeders, models, controllers, etc., to your module following the structure outlined above.
|
||||||
|
|
||||||
|
3. **Enable the Module**: Ensure the `isEnabled()` method in your module class returns `true`.
|
||||||
|
|
||||||
|
```php
|
||||||
|
// app/Modules/NewFeature/NewFeatureModule.php
|
||||||
|
public function isEnabled(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, in your module's config file:
|
||||||
|
|
||||||
|
```php
|
||||||
|
// app/Modules/NewFeature/Configs/new-feature-config.php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'enabled' => env('NEW_FEATURE_MODULE_ENABLED', true),
|
||||||
|
];
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Usage via Helpers
|
||||||
|
|
||||||
|
Use the global helper functions to interact with modules throughout the application.
|
||||||
|
|
||||||
|
- **Get the Module Repository**:
|
||||||
|
```php
|
||||||
|
$repository = modular();
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Get All Enabled Modules**:
|
||||||
|
```php
|
||||||
|
$enabledModules = modules(); // Returns a Collection of BaseModule objects
|
||||||
|
|
||||||
|
foreach ($enabledModules as $module) {
|
||||||
|
echo $module->name;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Get a Specific Module Instance**:
|
||||||
|
```php
|
||||||
|
$invoiceModule = module('Invoice'); // Returns instance of InvoiceModule
|
||||||
|
|
||||||
|
if ($invoiceModule->isEnabled()) {
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Get the Modules Path**:
|
||||||
|
```php
|
||||||
|
$path = modules_path('Invoice/Database'); // app/Modules/Invoice/Database
|
||||||
|
```
|
||||||
48
.cursor-rules.yaml
Normal file
48
.cursor-rules.yaml
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
# This file defines conventions for the modular system in the Laravel application.
|
||||||
|
# By following these rules, we can ensure consistency and maintainability across the codebase.
|
||||||
|
|
||||||
|
# GENERAL OVERVIEW
|
||||||
|
# The application uses a modular architecture to organize features into distinct, reusable units.
|
||||||
|
# Modules are located in the `app/Modules` directory. Each subdirectory in this directory is considered a module.
|
||||||
|
# The core logic for module discovery and registration is handled by `App\Modules\ModuleRepository` and `App\Providers\ModuleServiceProvider`.
|
||||||
|
|
||||||
|
# KEY FILES
|
||||||
|
# - `app/Providers/ModuleServiceProvider.php`: Registers and boots all active modules. This is where module resources (configs, migrations, routes, views, etc.) are loaded.
|
||||||
|
# - `app/Modules/ModuleRepository.php`: Discovers modules from the filesystem.
|
||||||
|
# - `app/Modules/ModuleContract.php`: The interface that each module's main class must implement.
|
||||||
|
# - `app/Modules/BaseModule.php`: A base class for module data.
|
||||||
|
# - `app/Modules/module-helpers.php`: Global helper functions for interacting with the modular system.
|
||||||
|
|
||||||
|
# CONVENTIONS
|
||||||
|
|
||||||
|
rules:
|
||||||
|
- name: "Modular Architecture"
|
||||||
|
description: |
|
||||||
|
The application is divided into modules, located in `app/Modules`. Each module is a self-contained unit with its own resources.
|
||||||
|
When adding new high-level functionality, consider creating a new module for it.
|
||||||
|
|
||||||
|
- name: "Creating a New Module"
|
||||||
|
description: |
|
||||||
|
To create a new module named "MyModule", follow these steps:
|
||||||
|
1. Create a new directory `app/Modules/MyModule`.
|
||||||
|
2. Create the main module class `app/Modules/MyModule/MyModuleModule.php`. This class must implement `\App\Modules\ModuleContract`.
|
||||||
|
3. Implement the `isEnabled()` method in `MyModuleModule.php` to control if the module is active.
|
||||||
|
4. Add resources to your module following the structure defined in `ModuleServiceProvider`:
|
||||||
|
- Configs: `app/Modules/MyModule/Configs/my-module-config.php`
|
||||||
|
- Migrations: `app/Modules/MyModule/Database/Migrations/`
|
||||||
|
- Views: `app/Modules/MyModule/Resources/Views/`
|
||||||
|
- Routes: `app/Modules/MyModule/Routes/my-module-routes.php`
|
||||||
|
- Helpers: `app/Modules/MyModule/my-module-helpers.php`
|
||||||
|
- Translations: `app/Modules/MyModule/Resources/lang/`
|
||||||
|
|
||||||
|
- name: "Enabling/Disabling Modules"
|
||||||
|
description: |
|
||||||
|
A module can be enabled or disabled via its `isEnabled()` method in the main module class (e.g., `MyModuleModule.php`).
|
||||||
|
The `ModuleServiceProvider` only boots enabled modules.
|
||||||
|
|
||||||
|
- name: "Interacting with Modules"
|
||||||
|
description: |
|
||||||
|
Use the helper functions defined in `app/Modules/module-helpers.php` to work with modules:
|
||||||
|
- `modules()`: Get a collection of all enabled modules.
|
||||||
|
- `module('MyModule')`: Get an instance of a specific module's main class.
|
||||||
|
- `modules_path()`: Get the absolute path to the modules directory.
|
||||||
11
.cursor/mcp.json
Normal file
11
.cursor/mcp.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"laravel-boost": {
|
||||||
|
"command": "php",
|
||||||
|
"args": [
|
||||||
|
"artisan",
|
||||||
|
"boost:mcp"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
921
.cursor/rules/laravel-boost.mdc
Normal file
921
.cursor/rules/laravel-boost.mdc
Normal file
@@ -0,0 +1,921 @@
|
|||||||
|
---
|
||||||
|
alwaysApply: true
|
||||||
|
---
|
||||||
|
<laravel-boost-guidelines>
|
||||||
|
=== foundation rules ===
|
||||||
|
|
||||||
|
# Laravel Boost Guidelines
|
||||||
|
|
||||||
|
The Laravel Boost guidelines are specifically curated by Laravel maintainers for this application. These guidelines should be followed closely to enhance the user's satisfaction building Laravel applications.
|
||||||
|
|
||||||
|
## Foundational Context
|
||||||
|
This application is a Laravel application and its main Laravel ecosystems package & versions are below. You are an expert with them all. Ensure you abide by these specific packages & versions.
|
||||||
|
|
||||||
|
- php - 8.3.12
|
||||||
|
- filament/filament (FILAMENT) - v4
|
||||||
|
- laravel/framework (LARAVEL) - v12
|
||||||
|
- laravel/prompts (PROMPTS) - v0
|
||||||
|
- livewire/livewire (LIVEWIRE) - v3
|
||||||
|
- larastan/larastan (LARASTAN) - v3
|
||||||
|
- laravel/mcp (MCP) - v0
|
||||||
|
- laravel/pint (PINT) - v1
|
||||||
|
- laravel/sail (SAIL) - v1
|
||||||
|
- phpunit/phpunit (PHPUNIT) - v11
|
||||||
|
|
||||||
|
|
||||||
|
## Conventions
|
||||||
|
- You must follow all existing code conventions used in this application. When creating or editing a file, check sibling files for the correct structure, approach, naming.
|
||||||
|
- Use descriptive names for variables and methods. For example, `isRegisteredForDiscounts`, not `discount()`.
|
||||||
|
- Check for existing components to reuse before writing a new one.
|
||||||
|
|
||||||
|
## Verification Scripts
|
||||||
|
- Do not create verification scripts or tinker when tests cover that functionality and prove it works. Unit and feature tests are more important.
|
||||||
|
|
||||||
|
## Application Structure & Architecture
|
||||||
|
- Stick to existing directory structure - don't create new base folders without approval.
|
||||||
|
- Do not change the application's dependencies without approval.
|
||||||
|
|
||||||
|
## Frontend Bundling
|
||||||
|
- If the user doesn't see a frontend change reflected in the UI, it could mean they need to run `npm run build`, `npm run dev`, or `composer run dev`. Ask them.
|
||||||
|
|
||||||
|
## Replies
|
||||||
|
- Be concise in your explanations - focus on what's important rather than explaining obvious details.
|
||||||
|
|
||||||
|
## Documentation Files
|
||||||
|
- You must only create documentation files if explicitly requested by the user.
|
||||||
|
|
||||||
|
|
||||||
|
=== boost rules ===
|
||||||
|
|
||||||
|
## Laravel Boost
|
||||||
|
- Laravel Boost is an MCP server that comes with powerful tools designed specifically for this application. Use them.
|
||||||
|
|
||||||
|
## Artisan
|
||||||
|
- Use the `list-artisan-commands` tool when you need to call an Artisan command to double check the available parameters.
|
||||||
|
|
||||||
|
## URLs
|
||||||
|
- Whenever you share a project URL with the user you should use the `get-absolute-url` tool to ensure you're using the correct scheme, domain / IP, and port.
|
||||||
|
|
||||||
|
## Tinker / Debugging
|
||||||
|
- You should use the `tinker` tool when you need to execute PHP to debug code or query Eloquent models directly.
|
||||||
|
- Use the `database-query` tool when you only need to read from the database.
|
||||||
|
|
||||||
|
## Reading Browser Logs With the `browser-logs` Tool
|
||||||
|
- You can read browser logs, errors, and exceptions using the `browser-logs` tool from Boost.
|
||||||
|
- Only recent browser logs will be useful - ignore old logs.
|
||||||
|
|
||||||
|
## Searching Documentation (Critically Important)
|
||||||
|
- Boost comes with a powerful `search-docs` tool you should use before any other approaches. This tool automatically passes a list of installed packages and their versions to the remote Boost API, so it returns only version-specific documentation specific for the user's circumstance. You should pass an array of packages to filter on if you know you need docs for particular packages.
|
||||||
|
- The 'search-docs' tool is perfect for all Laravel related packages, including Laravel, Inertia, Livewire, Filament, Tailwind, Pest, Nova, Nightwatch, etc.
|
||||||
|
- You must use this tool to search for Laravel-ecosystem documentation before falling back to other approaches.
|
||||||
|
- Search the documentation before making code changes to ensure we are taking the correct approach.
|
||||||
|
- Use multiple, broad, simple, topic based queries to start. For example: `['rate limiting', 'routing rate limiting', 'routing']`.
|
||||||
|
- Do not add package names to queries - package information is already shared. For example, use `test resource table`, not `filament 4 test resource table`.
|
||||||
|
|
||||||
|
### Available Search Syntax
|
||||||
|
- You can and should pass multiple queries at once. The most relevant results will be returned first.
|
||||||
|
|
||||||
|
1. Simple Word Searches with auto-stemming - query=authentication - finds 'authenticate' and 'auth'
|
||||||
|
2. Multiple Words (AND Logic) - query=rate limit - finds knowledge containing both "rate" AND "limit"
|
||||||
|
3. Quoted Phrases (Exact Position) - query="infinite scroll" - Words must be adjacent and in that order
|
||||||
|
4. Mixed Queries - query=middleware "rate limit" - "middleware" AND exact phrase "rate limit"
|
||||||
|
5. Multiple Queries - queries=["authentication", "middleware"] - ANY of these terms
|
||||||
|
|
||||||
|
|
||||||
|
=== php rules ===
|
||||||
|
|
||||||
|
## PHP
|
||||||
|
|
||||||
|
- Always use curly braces for control structures, even if it has one line.
|
||||||
|
|
||||||
|
### Constructors
|
||||||
|
- Use PHP 8 constructor property promotion in `__construct()`.
|
||||||
|
- <code-snippet>public function __construct(public GitHub $github) { }</code-snippet>
|
||||||
|
- Do not allow empty `__construct()` methods with zero parameters.
|
||||||
|
|
||||||
|
### Type Declarations
|
||||||
|
- Always use explicit return type declarations for methods and functions.
|
||||||
|
- Use appropriate PHP type hints for method parameters.
|
||||||
|
|
||||||
|
<code-snippet name="Explicit Return Types and Method Params" lang="php">
|
||||||
|
protected function isAccessible(User $user, ?string $path = null): bool
|
||||||
|
{
|
||||||
|
...
|
||||||
|
}
|
||||||
|
</code-snippet>
|
||||||
|
|
||||||
|
## Comments
|
||||||
|
- Prefer PHPDoc blocks over comments. Never use comments within the code itself unless there is something _very_ complex going on.
|
||||||
|
|
||||||
|
## PHPDoc Blocks
|
||||||
|
- Add useful array shape type definitions for arrays when appropriate.
|
||||||
|
|
||||||
|
## Enums
|
||||||
|
- Typically, keys in an Enum should be TitleCase. For example: `FavoritePerson`, `BestLake`, `Monthly`.
|
||||||
|
|
||||||
|
|
||||||
|
=== filament/core rules ===
|
||||||
|
|
||||||
|
## Filament
|
||||||
|
- Filament is used by this application, check how and where to follow existing application conventions.
|
||||||
|
- Filament is a Server-Driven UI (SDUI) framework for Laravel. It allows developers to define user interfaces in PHP using structured configuration objects. It is built on top of Livewire, Alpine.js, and Tailwind CSS.
|
||||||
|
- You can use the `search-docs` tool to get information from the official Filament documentation when needed. This is very useful for Artisan command arguments, specific code examples, testing functionality, relationship management, and ensuring you're following idiomatic practices.
|
||||||
|
- Utilize static `make()` methods for consistent component initialization.
|
||||||
|
|
||||||
|
### Artisan
|
||||||
|
- You must use the Filament specific Artisan commands to create new files or components for Filament. You can find these with the `list-artisan-commands` tool, or with `php artisan` and the `--help` option.
|
||||||
|
- Inspect the required options, always pass `--no-interaction`, and valid arguments for other options when applicable.
|
||||||
|
|
||||||
|
### Filament's Core Features
|
||||||
|
- Actions: Handle doing something within the application, often with a button or link. Actions encapsulate the UI, the interactive modal window, and the logic that should be executed when the modal window is submitted. They can be used anywhere in the UI and are commonly used to perform one-time actions like deleting a record, sending an email, or updating data in the database based on modal form input.
|
||||||
|
- Forms: Dynamic forms rendered within other features, such as resources, action modals, table filters, and more.
|
||||||
|
- Infolists: Read-only lists of data.
|
||||||
|
- Notifications: Flash notifications displayed to users within the application.
|
||||||
|
- Panels: The top-level container in Filament that can include all other features like pages, resources, forms, tables, notifications, actions, infolists, and widgets.
|
||||||
|
- Resources: Static classes that are used to build CRUD interfaces for Eloquent models. Typically live in `app/Filament/Resources`.
|
||||||
|
- Schemas: Represent components that define the structure and behavior of the UI, such as forms, tables, or lists.
|
||||||
|
- Tables: Interactive tables with filtering, sorting, pagination, and more.
|
||||||
|
- Widgets: Small component included within dashboards, often used for displaying data in charts, tables, or as a stat.
|
||||||
|
|
||||||
|
### Relationships
|
||||||
|
- Determine if you can use the `relationship()` method on form components when you need `options` for a select, checkbox, repeater, or when building a `Fieldset`:
|
||||||
|
|
||||||
|
<code-snippet name="Relationship example for Form Select" lang="php">
|
||||||
|
Forms\Components\Select::make('user_id')
|
||||||
|
->label('Author')
|
||||||
|
->relationship('author')
|
||||||
|
->required(),
|
||||||
|
</code-snippet>
|
||||||
|
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
- It's important to test Filament functionality for user satisfaction.
|
||||||
|
- Ensure that you are authenticated to access the application within the test.
|
||||||
|
- Filament uses Livewire, so start assertions with `livewire()` or `Livewire::test()`.
|
||||||
|
|
||||||
|
### Example Tests
|
||||||
|
|
||||||
|
<code-snippet name="Filament Table Test" lang="php">
|
||||||
|
livewire(ListUsers::class)
|
||||||
|
->assertCanSeeTableRecords($users)
|
||||||
|
->searchTable($users->first()->name)
|
||||||
|
->assertCanSeeTableRecords($users->take(1))
|
||||||
|
->assertCanNotSeeTableRecords($users->skip(1))
|
||||||
|
->searchTable($users->last()->email)
|
||||||
|
->assertCanSeeTableRecords($users->take(-1))
|
||||||
|
->assertCanNotSeeTableRecords($users->take($users->count() - 1));
|
||||||
|
</code-snippet>
|
||||||
|
|
||||||
|
<code-snippet name="Filament Create Resource Test" lang="php">
|
||||||
|
livewire(CreateUser::class)
|
||||||
|
->fillForm([
|
||||||
|
'name' => 'Howdy',
|
||||||
|
'email' => 'howdy@example.com',
|
||||||
|
])
|
||||||
|
->call('create')
|
||||||
|
->assertNotified()
|
||||||
|
->assertRedirect();
|
||||||
|
|
||||||
|
assertDatabaseHas(User::class, [
|
||||||
|
'name' => 'Howdy',
|
||||||
|
'email' => 'howdy@example.com',
|
||||||
|
]);
|
||||||
|
</code-snippet>
|
||||||
|
|
||||||
|
<code-snippet name="Testing Multiple Panels (setup())" lang="php">
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
|
||||||
|
Filament::setCurrentPanel('app');
|
||||||
|
</code-snippet>
|
||||||
|
|
||||||
|
<code-snippet name="Calling an Action in a Test" lang="php">
|
||||||
|
livewire(EditInvoice::class, [
|
||||||
|
'invoice' => $invoice,
|
||||||
|
])->callAction('send');
|
||||||
|
|
||||||
|
expect($invoice->refresh())->isSent()->toBeTrue();
|
||||||
|
</code-snippet>
|
||||||
|
|
||||||
|
|
||||||
|
=== filament/v4 rules ===
|
||||||
|
|
||||||
|
## Filament 4
|
||||||
|
|
||||||
|
### Important Version 4 Changes
|
||||||
|
- File visibility is now `private` by default.
|
||||||
|
- The `deferFilters` method from Filament v3 is now the default behavior in Filament v4, so users must click a button before the filters are applied to the table. To disable this behavior, you can use the `deferFilters(false)` method.
|
||||||
|
- The `Grid`, `Section`, and `Fieldset` layout components no longer span all columns by default.
|
||||||
|
- The `all` pagination page method is not available for tables by default.
|
||||||
|
- All action classes extend `Filament\Actions\Action`. No action classes exist in `Filament\Tables\Actions`.
|
||||||
|
- The `Form` & `Infolist` layout components have been moved to `Filament\Schemas\Components`, for example `Grid`, `Section`, `Fieldset`, `Tabs`, `Wizard`, etc.
|
||||||
|
- A new `Repeater` component for Forms has been added.
|
||||||
|
- Icons now use the `Filament\Support\Icons\Heroicon` Enum by default. Other options are available and documented.
|
||||||
|
|
||||||
|
### Organize Component Classes Structure
|
||||||
|
- Schema components: `Schemas/Components/`
|
||||||
|
- Table columns: `Tables/Columns/`
|
||||||
|
- Table filters: `Tables/Filters/`
|
||||||
|
- Actions: `Actions/`
|
||||||
|
|
||||||
|
|
||||||
|
=== laravel/core rules ===
|
||||||
|
|
||||||
|
## Do Things the Laravel Way
|
||||||
|
|
||||||
|
- Use `php artisan make:` commands to create new files (i.e. migrations, controllers, models, etc.). You can list available Artisan commands using the `list-artisan-commands` tool.
|
||||||
|
- If you're creating a generic PHP class, use `artisan make:class`.
|
||||||
|
- Pass `--no-interaction` to all Artisan commands to ensure they work without user input. You should also pass the correct `--options` to ensure correct behavior.
|
||||||
|
|
||||||
|
### Database
|
||||||
|
- Always use proper Eloquent relationship methods with return type hints. Prefer relationship methods over raw queries or manual joins.
|
||||||
|
- Use Eloquent models and relationships before suggesting raw database queries
|
||||||
|
- Avoid `DB::`; prefer `Model::query()`. Generate code that leverages Laravel's ORM capabilities rather than bypassing them.
|
||||||
|
- Generate code that prevents N+1 query problems by using eager loading.
|
||||||
|
- Use Laravel's query builder for very complex database operations.
|
||||||
|
|
||||||
|
### Model Creation
|
||||||
|
- When creating new models, create useful factories and seeders for them too. Ask the user if they need any other things, using `list-artisan-commands` to check the available options to `php artisan make:model`.
|
||||||
|
|
||||||
|
### APIs & Eloquent Resources
|
||||||
|
- For APIs, default to using Eloquent API Resources and API versioning unless existing API routes do not, then you should follow existing application convention.
|
||||||
|
|
||||||
|
### Controllers & Validation
|
||||||
|
- Always create Form Request classes for validation rather than inline validation in controllers. Include both validation rules and custom error messages.
|
||||||
|
- Check sibling Form Requests to see if the application uses array or string based validation rules.
|
||||||
|
|
||||||
|
### Queues
|
||||||
|
- Use queued jobs for time-consuming operations with the `ShouldQueue` interface.
|
||||||
|
|
||||||
|
### Authentication & Authorization
|
||||||
|
- Use Laravel's built-in authentication and authorization features (gates, policies, Sanctum, etc.).
|
||||||
|
|
||||||
|
### URL Generation
|
||||||
|
- When generating links to other pages, prefer named routes and the `route()` function.
|
||||||
|
|
||||||
|
### Configuration
|
||||||
|
- Use environment variables only in configuration files - never use the `env()` function directly outside of config files. Always use `config('app.name')`, not `env('APP_NAME')`.
|
||||||
|
|
||||||
|
### Testing
|
||||||
|
- When creating models for tests, use the factories for the models. Check if the factory has custom states that can be used before manually setting up the model.
|
||||||
|
- Faker: Use methods such as `$this->faker->word()` or `fake()->randomDigit()`. Follow existing conventions whether to use `$this->faker` or `fake()`.
|
||||||
|
- When creating tests, make use of `php artisan make:test [options] <name>` to create a feature test, and pass `--unit` to create a unit test. Most tests should be feature tests.
|
||||||
|
|
||||||
|
### Vite Error
|
||||||
|
- If you receive an "Illuminate\Foundation\ViteException: Unable to locate file in Vite manifest" error, you can run `npm run build` or ask the user to run `npm run dev` or `composer run dev`.
|
||||||
|
|
||||||
|
|
||||||
|
=== laravel/v12 rules ===
|
||||||
|
|
||||||
|
## Laravel 12
|
||||||
|
|
||||||
|
- Use the `search-docs` tool to get version specific documentation.
|
||||||
|
- Since Laravel 11, Laravel has a new streamlined file structure which this project uses.
|
||||||
|
|
||||||
|
### Laravel 12 Structure
|
||||||
|
- No middleware files in `app/Http/Middleware/`.
|
||||||
|
- `bootstrap/app.php` is the file to register middleware, exceptions, and routing files.
|
||||||
|
- `bootstrap/providers.php` contains application specific service providers.
|
||||||
|
- **No app\Console\Kernel.php** - use `bootstrap/app.php` or `routes/console.php` for console configuration.
|
||||||
|
- **Commands auto-register** - files in `app/Console/Commands/` are automatically available and do not require manual registration.
|
||||||
|
|
||||||
|
### Database
|
||||||
|
- When modifying a column, the migration must include all of the attributes that were previously defined on the column. Otherwise, they will be dropped and lost.
|
||||||
|
- Laravel 11 allows limiting eagerly loaded records natively, without external packages: `$query->latest()->limit(10);`.
|
||||||
|
|
||||||
|
### Models
|
||||||
|
- Casts can and likely should be set in a `casts()` method on a model rather than the `$casts` property. Follow existing conventions from other models.
|
||||||
|
|
||||||
|
|
||||||
|
=== livewire/core rules ===
|
||||||
|
|
||||||
|
## Livewire Core
|
||||||
|
- Use the `search-docs` tool to find exact version specific documentation for how to write Livewire & Livewire tests.
|
||||||
|
- Use the `php artisan make:livewire [Posts\CreatePost]` artisan command to create new components
|
||||||
|
- State should live on the server, with the UI reflecting it.
|
||||||
|
- All Livewire requests hit the Laravel backend, they're like regular HTTP requests. Always validate form data, and run authorization checks in Livewire actions.
|
||||||
|
|
||||||
|
## Livewire Best Practices
|
||||||
|
- Livewire components require a single root element.
|
||||||
|
- Use `wire:loading` and `wire:dirty` for delightful loading states.
|
||||||
|
- Add `wire:key` in loops:
|
||||||
|
|
||||||
|
```blade
|
||||||
|
@foreach ($items as $item)
|
||||||
|
<div wire:key="item-{{ $item->id }}">
|
||||||
|
{{ $item->name }}
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
```
|
||||||
|
|
||||||
|
- Prefer lifecycle hooks like `mount()`, `updatedFoo()` for initialization and reactive side effects:
|
||||||
|
|
||||||
|
<code-snippet name="Lifecycle hook examples" lang="php">
|
||||||
|
public function mount(User $user) { $this->user = $user; }
|
||||||
|
public function updatedSearch() { $this->resetPage(); }
|
||||||
|
</code-snippet>
|
||||||
|
|
||||||
|
|
||||||
|
## Testing Livewire
|
||||||
|
|
||||||
|
<code-snippet name="Example Livewire component test" lang="php">
|
||||||
|
Livewire::test(Counter::class)
|
||||||
|
->assertSet('count', 0)
|
||||||
|
->call('increment')
|
||||||
|
->assertSet('count', 1)
|
||||||
|
->assertSee(1)
|
||||||
|
->assertStatus(200);
|
||||||
|
</code-snippet>
|
||||||
|
|
||||||
|
|
||||||
|
<code-snippet name="Testing a Livewire component exists within a page" lang="php">
|
||||||
|
$this->get('/posts/create')
|
||||||
|
->assertSeeLivewire(CreatePost::class);
|
||||||
|
</code-snippet>
|
||||||
|
|
||||||
|
|
||||||
|
=== livewire/v3 rules ===
|
||||||
|
|
||||||
|
## Livewire 3
|
||||||
|
|
||||||
|
### Key Changes From Livewire 2
|
||||||
|
- These things changed in Livewire 2, but may not have been updated in this application. Verify this application's setup to ensure you conform with application conventions.
|
||||||
|
- Use `wire:model.live` for real-time updates, `wire:model` is now deferred by default.
|
||||||
|
- Components now use the `App\Livewire` namespace (not `App\Http\Livewire`).
|
||||||
|
- Use `$this->dispatch()` to dispatch events (not `emit` or `dispatchBrowserEvent`).
|
||||||
|
- Use the `components.layouts.app` view as the typical layout path (not `layouts.app`).
|
||||||
|
|
||||||
|
### New Directives
|
||||||
|
- `wire:show`, `wire:transition`, `wire:cloak`, `wire:offline`, `wire:target` are available for use. Use the documentation to find usage examples.
|
||||||
|
|
||||||
|
### Alpine
|
||||||
|
- Alpine is now included with Livewire, don't manually include Alpine.js.
|
||||||
|
- Plugins included with Alpine: persist, intersect, collapse, and focus.
|
||||||
|
|
||||||
|
### Lifecycle Hooks
|
||||||
|
- You can listen for `livewire:init` to hook into Livewire initialization, and `fail.status === 419` for the page expiring:
|
||||||
|
|
||||||
|
<code-snippet name="livewire:load example" lang="js">
|
||||||
|
document.addEventListener('livewire:init', function () {
|
||||||
|
Livewire.hook('request', ({ fail }) => {
|
||||||
|
if (fail && fail.status === 419) {
|
||||||
|
alert('Your session expired');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Livewire.hook('message.failed', (message, component) => {
|
||||||
|
console.error(message);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</code-snippet>
|
||||||
|
|
||||||
|
|
||||||
|
=== pint/core rules ===
|
||||||
|
|
||||||
|
## Laravel Pint Code Formatter
|
||||||
|
|
||||||
|
- You must run `vendor/bin/pint --dirty` before finalizing changes to ensure your code matches the project's expected style.
|
||||||
|
- Do not run `vendor/bin/pint --test`, simply run `vendor/bin/pint` to fix any formatting issues.
|
||||||
|
|
||||||
|
|
||||||
|
=== phpunit/core rules ===
|
||||||
|
|
||||||
|
## PHPUnit Core
|
||||||
|
|
||||||
|
- This application uses PHPUnit for testing. All tests must be written as PHPUnit classes. Use `php artisan make:test --phpunit <name>` to create a new test.
|
||||||
|
- If you see a test using "Pest", convert it to PHPUnit.
|
||||||
|
- Every time a test has been updated, run that singular test.
|
||||||
|
- When the tests relating to your feature are passing, ask the user if they would like to also run the entire test suite to make sure everything is still passing.
|
||||||
|
- Tests should test all of the happy paths, failure paths, and weird paths.
|
||||||
|
- You must not remove any tests or test files from the tests directory without approval. These are not temporary or helper files, these are core to the application.
|
||||||
|
|
||||||
|
### Running Tests
|
||||||
|
- Run the minimal number of tests, using an appropriate filter, before finalizing.
|
||||||
|
- To run all tests: `php artisan test`.
|
||||||
|
- To run all tests in a file: `php artisan test tests/Feature/ExampleTest.php`.
|
||||||
|
- To filter on a particular test name: `php artisan test --filter=testName` (recommended after making a change to a related file).
|
||||||
|
|
||||||
|
|
||||||
|
=== .ai/modular-architecture rules ===
|
||||||
|
|
||||||
|
### Modular Architecture Guidelines
|
||||||
|
|
||||||
|
#### Overview
|
||||||
|
|
||||||
|
This application uses a custom modular architecture to organize features into distinct, self-contained units called "Modules". Each module encapsulates a specific piece of functionality, including its own models, migrations, seeders, controllers, and more. The system is designed to automatically discover and register components from enabled modules.
|
||||||
|
|
||||||
|
The core of this system is the `App\Modules\ModuleRepository`, which is responsible for finding, loading, and managing all the modules in the application. A set of helper functions is provided for easy interaction with the module repository.
|
||||||
|
|
||||||
|
#### Core Concepts
|
||||||
|
|
||||||
|
- **Module**: A directory within `app/Modules` that represents a distinct feature.
|
||||||
|
- **`ModuleRepository`**: A singleton service (`App\Modules\ModuleRepository`) that manages all modules. Accessed via the `modular()` helper.
|
||||||
|
- **`ModuleServiceProvider`**: A service provider (`App\Modules\ModuleServiceProvider`) that automatically discovers and registers resources (routes, migrations, views, etc.) from all enabled modules.
|
||||||
|
- **`ModuleContract`**: An interface (`App\Modules\ModuleContract`) that every module's main class must implement. It defines the basic contract for a module.
|
||||||
|
- **`BaseModule`**: A wrapper class (`App\Modules\BaseModule`) that holds information about a module, such as its path, name, and an instance of its `ModuleContract`.
|
||||||
|
- **Helpers**: Global functions defined in `app/Helpers/helpers.php` to simplify interaction with the modular system.
|
||||||
|
- **Core Module**: A special module located in `app/Modules/Core` that provides Artisan commands for creating new modules and their components.
|
||||||
|
|
||||||
|
#### Module Structure
|
||||||
|
|
||||||
|
Every module is a directory located in `app/Modules/`. For a module named `Example`, the structure would be `app/Modules/Example/`.
|
||||||
|
|
||||||
|
##### Required Structure
|
||||||
|
|
||||||
|
- `app/Modules/Example/ExampleModule.php`: This is the main class for the module. It **must** implement `App\Modules\ModuleContract`.
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\Example;
|
||||||
|
|
||||||
|
use App\Modules\ModuleContract;
|
||||||
|
|
||||||
|
class ExampleModule implements ModuleContract
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Check if module is enabled
|
||||||
|
*/
|
||||||
|
public function isEnabled(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable module
|
||||||
|
*/
|
||||||
|
public function disable(): void
|
||||||
|
{
|
||||||
|
// Logic to disable the module
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable module
|
||||||
|
*/
|
||||||
|
public function enable(): void
|
||||||
|
{
|
||||||
|
// Logic to enable the module
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if module has a filament resource
|
||||||
|
*/
|
||||||
|
public function hasFilamentResource(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get module composer requirements
|
||||||
|
*
|
||||||
|
* @return array<int, \App\Modules\Core\ModulePackage>
|
||||||
|
*/
|
||||||
|
public function getComposerRequirements(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get module composer suggestions
|
||||||
|
*
|
||||||
|
* @return array<int, \App\Modules\Core\ModulePackage>
|
||||||
|
*/
|
||||||
|
public function getComposerSuggestions(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Automatic Discovery
|
||||||
|
|
||||||
|
The `ModuleServiceProvider` automatically discovers and registers the following directories and files for all **enabled** modules. The paths shown are for an `Example` module. If module name is `MyModule`, kebab naming will be used for routes, helpers, and config files will be `app/Modules/MyModule/Configs/my-module-config.php`, `app/Modules/MyModule/Routes/my-module-routes.php`, `app/Modules/MyModule/my-module-helpers.php`.
|
||||||
|
|
||||||
|
- **Configurations**: `app/Modules/Example/Configs/example-config.php`
|
||||||
|
- **Migrations**: `app/Modules/Example/Database/Migrations/`
|
||||||
|
- **Seeders**: `app/Modules/Example/Database/Seeders/`
|
||||||
|
- **Routes**: `app/Modules/Example/Routes/example-routes.php`
|
||||||
|
- **Views**: `app/Modules/Example/Resources/Views/`
|
||||||
|
- **Translations**: `app/Modules/Example/Resources/lang/`
|
||||||
|
- **Helper Files**: `app/Modules/Example/example-helpers.php`
|
||||||
|
|
||||||
|
##### Composer Dependencies
|
||||||
|
|
||||||
|
Modules can declare Composer package dependencies. This is useful for making a module's requirements explicit. There are two types of dependencies you can define: requirements and suggestions.
|
||||||
|
|
||||||
|
- **Requirements**: Packages that are essential for the module to function correctly.
|
||||||
|
- **Suggestions**: Packages that are recommended but not strictly necessary.
|
||||||
|
|
||||||
|
These dependencies are defined in the module's main class by implementing the `getComposerRequirements()` and `getComposerSuggestions()` methods from the `ModuleContract` interface. These methods should return an array of `ModulePackage` objects.
|
||||||
|
|
||||||
|
**Note:** Declaring a dependency does not automatically install it. This feature is for informational purposes, helping developers understand the module's dependencies.
|
||||||
|
|
||||||
|
Here is an example of how to declare a required package and a suggested module dependency:
|
||||||
|
|
||||||
|
```php
|
||||||
|
// app/Modules/Example/ExampleModule.php
|
||||||
|
|
||||||
|
use App\Modules\Core\ModulePackage;
|
||||||
|
use App\Modules\Core\ModulePackageType;
|
||||||
|
|
||||||
|
// ...
|
||||||
|
|
||||||
|
public function getComposerRequirements(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
new ModulePackage(
|
||||||
|
type: ModulePackageType::PACKAGE,
|
||||||
|
name: 'spatie/laravel-translatable',
|
||||||
|
message: 'This package is used for translatable models.',
|
||||||
|
version: '^8.0'
|
||||||
|
)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getComposerSuggestions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
new ModulePackage(
|
||||||
|
type: ModulePackageType::MODULE,
|
||||||
|
name: 'OtherModule',
|
||||||
|
message: 'This module provides additional related functionality.'
|
||||||
|
)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Conventional Structure
|
||||||
|
|
||||||
|
Following the conventional structure is essential for the automatic discovery mechanism to work.
|
||||||
|
|
||||||
|
```
|
||||||
|
app/Modules/Example/
|
||||||
|
├── Configs/
|
||||||
|
│ └── example-config.php
|
||||||
|
├── Database/
|
||||||
|
│ ├── Migrations/
|
||||||
|
│ │ └── 2025_09_22_000000_create_example_table.php
|
||||||
|
│ └── Seeders/
|
||||||
|
│ └── ExampleSeeder.php
|
||||||
|
├── Http/
|
||||||
|
│ ├── Controllers/
|
||||||
|
│ └── Requests/
|
||||||
|
├── Models/
|
||||||
|
│ └── Example.php
|
||||||
|
├── Repositories/
|
||||||
|
├── Resources/
|
||||||
|
│ ├── Lang/
|
||||||
|
│ └── Views/
|
||||||
|
├── Routes/
|
||||||
|
│ └── example-routes.php
|
||||||
|
├── example-helpers.php
|
||||||
|
└── ExampleModule.php
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Creating a New Module
|
||||||
|
|
||||||
|
The `Core` module provides an Artisan command to simplify the creation of new modules.
|
||||||
|
|
||||||
|
1. **Run the `make:module` command**:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
php artisan make:module NewFeature
|
||||||
|
```
|
||||||
|
|
||||||
|
This command will scaffold a new module in `app/Modules/NewFeature` with the necessary directory structure and default files, including the `NewFeatureModule.php` class, a model, controller, repository, and migration.
|
||||||
|
|
||||||
|
You can use the `--plain` option to create a module with only the main module class and an empty directory.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
php artisan make:module NewFeature --plain
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Add Components**: Add any additional migrations, seeders, models, controllers, etc., to your module following the structure outlined above.
|
||||||
|
|
||||||
|
3. **Enable the Module**: Ensure the `isEnabled()` method in your module class returns `true`.
|
||||||
|
|
||||||
|
```php
|
||||||
|
// app/Modules/NewFeature/NewFeatureModule.php
|
||||||
|
public function isEnabled(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, in your module's config file:
|
||||||
|
|
||||||
|
```php
|
||||||
|
// app/Modules/NewFeature/Configs/new-feature-config.php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'enabled' => env('NEW_FEATURE_MODULE_ENABLED', true),
|
||||||
|
];
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Usage via Helpers
|
||||||
|
|
||||||
|
Use the global helper functions to interact with modules throughout the application.
|
||||||
|
|
||||||
|
- **Get the Module Repository**:
|
||||||
|
```php
|
||||||
|
$repository = modular();
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Get All Enabled Modules**:
|
||||||
|
```php
|
||||||
|
$enabledModules = modules(); // Returns a Collection of BaseModule objects
|
||||||
|
|
||||||
|
foreach ($enabledModules as $module) {
|
||||||
|
echo $module->name;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Get a Specific Module Instance**:
|
||||||
|
```php
|
||||||
|
$invoiceModule = module('Invoice'); // Returns instance of InvoiceModule
|
||||||
|
|
||||||
|
if ($invoiceModule->isEnabled()) {
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Get the Modules Path**:
|
||||||
|
```php
|
||||||
|
$path = modules_path('Invoice/Database'); // app/Modules/Invoice/Database
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
=== .ai/db-architecture rules ===
|
||||||
|
|
||||||
|
### DB architecture guidelines
|
||||||
|
|
||||||
|
#### Overview
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
#### Core Concepts
|
||||||
|
|
||||||
|
- ....
|
||||||
|
|
||||||
|
#### User table
|
||||||
|
- # Model App\Models\User
|
||||||
|
- # Migrations database/migrations/0001_01_01_000000_create_users_table.php
|
||||||
|
- # Seeder database/seeders/UsersTableSeeder.php
|
||||||
|
...
|
||||||
|
|
||||||
|
##### Structure
|
||||||
|
- id
|
||||||
|
- username
|
||||||
|
- first_name
|
||||||
|
- last_name
|
||||||
|
- phone
|
||||||
|
- phone_verified_at
|
||||||
|
- locale
|
||||||
|
- password_must_be_changed
|
||||||
|
- options
|
||||||
|
- email_verified_at
|
||||||
|
- remember_token
|
||||||
|
- created_at
|
||||||
|
- updated_at
|
||||||
|
|
||||||
|
##### Indexes
|
||||||
|
- username (unique)
|
||||||
|
- phone (unique)
|
||||||
|
- email (unique)
|
||||||
|
- email_verified_at
|
||||||
|
- remember_token
|
||||||
|
|
||||||
|
##### Relations
|
||||||
|
- roles (Role model)
|
||||||
|
|
||||||
|
#### Branch table
|
||||||
|
- # Model App\Modules\Branch\Models\Branch
|
||||||
|
- # Migrations app/Modules/Branch/Database/Migrations/2025_10_09_190439_create_branches_table.php
|
||||||
|
- # Seeder Not found
|
||||||
|
|
||||||
|
##### Structure
|
||||||
|
- id
|
||||||
|
- unique_code
|
||||||
|
- name (json)
|
||||||
|
- address (json)
|
||||||
|
- region (string)[in: ag, mr, ah, ak, dz, bn, lb]
|
||||||
|
- province_id
|
||||||
|
- phone_numbers (json)
|
||||||
|
- billing_username
|
||||||
|
- billing_password
|
||||||
|
- billing_swift_username
|
||||||
|
- billing_swift_password
|
||||||
|
- billing_visa_master_username
|
||||||
|
- billing_visa_master_password
|
||||||
|
- billing_sber_username
|
||||||
|
- billing_sber_password
|
||||||
|
- active
|
||||||
|
- created_at
|
||||||
|
- updated_at
|
||||||
|
|
||||||
|
##### Indexes
|
||||||
|
- unique_code (unique)
|
||||||
|
- region
|
||||||
|
|
||||||
|
##### Relations
|
||||||
|
- province (Province model)
|
||||||
|
- users (User model)
|
||||||
|
|
||||||
|
#### Province table
|
||||||
|
- # Model App\Modules\Province\Models\Province
|
||||||
|
- # Migrations app/Modules/Province/Database/Migrations/2025_10_09_185951_create_provinces_table.php
|
||||||
|
- # Seeder Not found
|
||||||
|
|
||||||
|
##### Structure
|
||||||
|
- id
|
||||||
|
- region
|
||||||
|
- name (json)
|
||||||
|
- active
|
||||||
|
- created_at
|
||||||
|
- updated_at
|
||||||
|
|
||||||
|
##### Indexes
|
||||||
|
- None
|
||||||
|
|
||||||
|
##### Relations
|
||||||
|
- None
|
||||||
|
|
||||||
|
#### LoanOrderRequiredDocs table
|
||||||
|
- # Model App\Modules\LoanOrder\Models\LoanOrderRequiredDocs
|
||||||
|
- # Migrations app/Modules/LoanOrder/Database/Migrations/2025_10_09_211513_create_loan_order_required_docs_table.php
|
||||||
|
- # Seeder Not found
|
||||||
|
|
||||||
|
##### Structure
|
||||||
|
- id
|
||||||
|
- name (text)
|
||||||
|
- value (text)
|
||||||
|
- created_at
|
||||||
|
- updated_at
|
||||||
|
|
||||||
|
##### Indexes
|
||||||
|
- None
|
||||||
|
|
||||||
|
##### Relations
|
||||||
|
- loanOrders (LoanOrder model)
|
||||||
|
|
||||||
|
#### LoanType table
|
||||||
|
- # Model App\Modules\LoanOrder\Models\LoanType
|
||||||
|
- # Migrations app/Modules/LoanOrder/Database/Migrations/2025_10_09_183412_create_loan_types_table.php
|
||||||
|
- # Seeder Not found
|
||||||
|
|
||||||
|
##### Structure
|
||||||
|
- id
|
||||||
|
- name (json)
|
||||||
|
- tax
|
||||||
|
- maturity
|
||||||
|
- notes
|
||||||
|
- active
|
||||||
|
- created_at
|
||||||
|
- updated_at
|
||||||
|
|
||||||
|
##### Indexes
|
||||||
|
- None
|
||||||
|
|
||||||
|
##### Relations
|
||||||
|
- None
|
||||||
|
|
||||||
|
#### LoanOrder table
|
||||||
|
- # Model App\Modules\LoanOrder\Models\LoanOrder
|
||||||
|
- # Migrations app/Modules/LoanOrder/Database/Migrations/2025_10_09_220443_create_loan_orders_table.php
|
||||||
|
- # Seeder Not found
|
||||||
|
|
||||||
|
##### Structure
|
||||||
|
- id
|
||||||
|
- unique_id
|
||||||
|
- source
|
||||||
|
- user_id
|
||||||
|
- loan_type
|
||||||
|
- region
|
||||||
|
- branch_id
|
||||||
|
- customer_name
|
||||||
|
- customer_surname
|
||||||
|
- customer_patronic_name
|
||||||
|
- passport_address
|
||||||
|
- real_address
|
||||||
|
- passport_serie
|
||||||
|
- passport_id
|
||||||
|
- passport_given_at
|
||||||
|
- passport_given_by
|
||||||
|
- born_place
|
||||||
|
- born_at
|
||||||
|
- email
|
||||||
|
- phone
|
||||||
|
- phone_additional
|
||||||
|
- phone_home
|
||||||
|
- work_region
|
||||||
|
- work_province_id
|
||||||
|
- work_company
|
||||||
|
- work_company_accountant_number
|
||||||
|
- work_started_at
|
||||||
|
- work_salary
|
||||||
|
- work_position
|
||||||
|
- education
|
||||||
|
- marriage_status
|
||||||
|
- passport_one (text)
|
||||||
|
- passport_two (text)
|
||||||
|
- passport_three (text)
|
||||||
|
- passport_four (text)
|
||||||
|
- loan_amount
|
||||||
|
- card_number
|
||||||
|
- card_name
|
||||||
|
- card_month
|
||||||
|
- card_year
|
||||||
|
- guarantor_name
|
||||||
|
- guarantor_surname
|
||||||
|
- guarantor_patronic_name
|
||||||
|
- guarantor_passport_serie
|
||||||
|
- guarantor_passport_id
|
||||||
|
- guarantor_card_number
|
||||||
|
- guarantor_card_name
|
||||||
|
- guarantor_card_month
|
||||||
|
- guarantor_card_year
|
||||||
|
- guarantor_note
|
||||||
|
- guarantor_2_name
|
||||||
|
- guarantor_2_surname
|
||||||
|
- guarantor_2_patronic_name
|
||||||
|
- guarantor_2_passport_serie
|
||||||
|
- guarantor_2_passport_id
|
||||||
|
- guarantor_2_card_number
|
||||||
|
- guarantor_2_card_name
|
||||||
|
- guarantor_2_card_month
|
||||||
|
- guarantor_2_card_year
|
||||||
|
- guarantor_2_note
|
||||||
|
- loan_card_number
|
||||||
|
- loan_card_name
|
||||||
|
- loan_card_month
|
||||||
|
- loan_card_year
|
||||||
|
- loan_order_required_doc_id
|
||||||
|
- status
|
||||||
|
- satisfiable
|
||||||
|
- notes (text)
|
||||||
|
- created_at
|
||||||
|
- updated_at
|
||||||
|
- deleted_at
|
||||||
|
|
||||||
|
##### Indexes
|
||||||
|
- unique_id (unique)
|
||||||
|
- source
|
||||||
|
- customer_name
|
||||||
|
- customer_surname
|
||||||
|
- passport_serie
|
||||||
|
- passport_id
|
||||||
|
- phone
|
||||||
|
- work_region
|
||||||
|
- loan_amount
|
||||||
|
|
||||||
|
##### Relations
|
||||||
|
- loanType (LoanType model)
|
||||||
|
- branch (Branch model)
|
||||||
|
- workProvince (Province model)
|
||||||
|
- user (User model)
|
||||||
|
- requiredDocs (LoanOrderRequiredDocs model)
|
||||||
|
|
||||||
|
#### OtpVerification table
|
||||||
|
- # Model App\Modules\OtpVerification\Models\OtpVerification
|
||||||
|
- # Migrations app/Modules/OtpVerification/Database/Migrations/2025_09_22_164249_create_otp_verifications_table.php
|
||||||
|
- # Seeder Not found
|
||||||
|
|
||||||
|
##### Structure
|
||||||
|
- id
|
||||||
|
- username
|
||||||
|
- code
|
||||||
|
- created_at
|
||||||
|
- updated_at
|
||||||
|
|
||||||
|
##### Indexes
|
||||||
|
- None
|
||||||
|
|
||||||
|
##### Relations
|
||||||
|
- None
|
||||||
|
|
||||||
|
#### AuthEvent table
|
||||||
|
- # Model App\Modules\BaseAuth\Models\AuthEvent
|
||||||
|
- # Migrations app/Modules/BaseAuth/Database/Migrations/2025_10_07_181725_create_auth_events_table.php
|
||||||
|
- # Seeder Not found
|
||||||
|
|
||||||
|
##### Structure
|
||||||
|
- id
|
||||||
|
- name
|
||||||
|
- request_method
|
||||||
|
- ip
|
||||||
|
- user_agent
|
||||||
|
- target_url
|
||||||
|
- options (json)
|
||||||
|
- created_at
|
||||||
|
- updated_at
|
||||||
|
|
||||||
|
##### Indexes
|
||||||
|
- name
|
||||||
|
- request_method
|
||||||
|
- ip
|
||||||
|
- user_agent
|
||||||
|
- target_url
|
||||||
|
|
||||||
|
##### Relations
|
||||||
|
- None
|
||||||
|
</laravel-boost-guidelines>
|
||||||
18
.editorconfig
Normal file
18
.editorconfig
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
indent_size = 4
|
||||||
|
indent_style = space
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[*.{yml,yaml}]
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[compose.yaml]
|
||||||
|
indent_size = 4
|
||||||
67
.env.example
Normal file
67
.env.example
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
APP_NAME=BANK
|
||||||
|
APP_ENV=local
|
||||||
|
APP_KEY=base64:Jf/dxHm9JzW3wotH4PBBIIgK4VZ+L6TdGrjNOlSrlUY=
|
||||||
|
APP_DEBUG=true
|
||||||
|
APP_URL=http://127.0.0.1:8000
|
||||||
|
|
||||||
|
FILAMENT_PATH=work-place
|
||||||
|
|
||||||
|
APP_LOCALE=tk
|
||||||
|
APP_FALLBACK_LOCALE=en
|
||||||
|
APP_FAKER_LOCALE=en_US
|
||||||
|
|
||||||
|
APP_MAINTENANCE_DRIVER=file
|
||||||
|
# APP_MAINTENANCE_STORE=database
|
||||||
|
|
||||||
|
PHP_CLI_SERVER_WORKERS=4
|
||||||
|
|
||||||
|
BCRYPT_ROUNDS=12
|
||||||
|
|
||||||
|
LOG_CHANNEL=stack
|
||||||
|
LOG_STACK=single
|
||||||
|
LOG_DEPRECATIONS_CHANNEL=null
|
||||||
|
LOG_LEVEL=debug
|
||||||
|
|
||||||
|
DB_CONNECTION=mariadb
|
||||||
|
DB_HOST=127.0.0.1
|
||||||
|
DB_PORT=3306
|
||||||
|
DB_DATABASE=backend_tbbank
|
||||||
|
DB_USERNAME=numma
|
||||||
|
DB_PASSWORD=numma
|
||||||
|
|
||||||
|
SESSION_DRIVER=database
|
||||||
|
SESSION_LIFETIME=120
|
||||||
|
SESSION_ENCRYPT=false
|
||||||
|
SESSION_PATH=/
|
||||||
|
SESSION_DOMAIN=null
|
||||||
|
|
||||||
|
BROADCAST_CONNECTION=log
|
||||||
|
FILESYSTEM_DISK=local
|
||||||
|
QUEUE_CONNECTION=database
|
||||||
|
|
||||||
|
CACHE_STORE=database
|
||||||
|
# CACHE_PREFIX=
|
||||||
|
|
||||||
|
MEMCACHED_HOST=127.0.0.1
|
||||||
|
|
||||||
|
REDIS_CLIENT=phpredis
|
||||||
|
REDIS_HOST=127.0.0.1
|
||||||
|
REDIS_PASSWORD=null
|
||||||
|
REDIS_PORT=6379
|
||||||
|
|
||||||
|
MAIL_MAILER=log
|
||||||
|
MAIL_SCHEME=null
|
||||||
|
MAIL_HOST=127.0.0.1
|
||||||
|
MAIL_PORT=2525
|
||||||
|
MAIL_USERNAME=null
|
||||||
|
MAIL_PASSWORD=null
|
||||||
|
MAIL_FROM_ADDRESS="hello@example.com"
|
||||||
|
MAIL_FROM_NAME="${APP_NAME}"
|
||||||
|
|
||||||
|
AWS_ACCESS_KEY_ID=
|
||||||
|
AWS_SECRET_ACCESS_KEY=
|
||||||
|
AWS_DEFAULT_REGION=us-east-1
|
||||||
|
AWS_BUCKET=
|
||||||
|
AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||||
|
|
||||||
|
VITE_APP_NAME="${APP_NAME}"
|
||||||
11
.gitattributes
vendored
Normal file
11
.gitattributes
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
* text=auto eol=lf
|
||||||
|
|
||||||
|
*.blade.php diff=html
|
||||||
|
*.css diff=css
|
||||||
|
*.html diff=html
|
||||||
|
*.md diff=markdown
|
||||||
|
*.php diff=php
|
||||||
|
|
||||||
|
/.github export-ignore
|
||||||
|
CHANGELOG.md export-ignore
|
||||||
|
.styleci.yml export-ignore
|
||||||
24
.gitignore
vendored
Normal file
24
.gitignore
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
*.log
|
||||||
|
.DS_Store
|
||||||
|
.env
|
||||||
|
.env.backup
|
||||||
|
.env.production
|
||||||
|
.phpactor.json
|
||||||
|
.phpunit.result.cache
|
||||||
|
/.fleet
|
||||||
|
/.idea
|
||||||
|
/.nova
|
||||||
|
/.phpunit.cache
|
||||||
|
/.vscode
|
||||||
|
/.zed
|
||||||
|
/auth.json
|
||||||
|
/node_modules
|
||||||
|
/public/build
|
||||||
|
/public/hot
|
||||||
|
/public/storage
|
||||||
|
/storage/*.key
|
||||||
|
/storage/pail
|
||||||
|
/vendor
|
||||||
|
Homestead.json
|
||||||
|
Homestead.yaml
|
||||||
|
Thumbs.db
|
||||||
1
APP_LOGIC.MD
Normal file
1
APP_LOGIC.MD
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# Regions
|
||||||
3
NOTES.MD
Normal file
3
NOTES.MD
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Loan Order
|
||||||
|
|
||||||
|
Only load order migration file is created, everything else is missing.
|
||||||
61
README.md
Normal file
61
README.md
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
<p align="center"><a href="https://laravel.com" target="_blank"><img src="https://raw.githubusercontent.com/laravel/art/master/logo-lockup/5%20SVG/2%20CMYK/1%20Full%20Color/laravel-logolockup-cmyk-red.svg" width="400" alt="Laravel Logo"></a></p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://github.com/laravel/framework/actions"><img src="https://github.com/laravel/framework/workflows/tests/badge.svg" alt="Build Status"></a>
|
||||||
|
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
|
||||||
|
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
|
||||||
|
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
## About Laravel
|
||||||
|
|
||||||
|
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:
|
||||||
|
|
||||||
|
- [Simple, fast routing engine](https://laravel.com/docs/routing).
|
||||||
|
- [Powerful dependency injection container](https://laravel.com/docs/container).
|
||||||
|
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage.
|
||||||
|
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent).
|
||||||
|
- Database agnostic [schema migrations](https://laravel.com/docs/migrations).
|
||||||
|
- [Robust background job processing](https://laravel.com/docs/queues).
|
||||||
|
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting).
|
||||||
|
|
||||||
|
Laravel is accessible, powerful, and provides tools required for large, robust applications.
|
||||||
|
|
||||||
|
## Learning Laravel
|
||||||
|
|
||||||
|
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
|
||||||
|
|
||||||
|
You may also try the [Laravel Bootcamp](https://bootcamp.laravel.com), where you will be guided through building a modern Laravel application from scratch.
|
||||||
|
|
||||||
|
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
|
||||||
|
|
||||||
|
## Laravel Sponsors
|
||||||
|
|
||||||
|
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the [Laravel Partners program](https://partners.laravel.com).
|
||||||
|
|
||||||
|
### Premium Partners
|
||||||
|
|
||||||
|
- **[Vehikl](https://vehikl.com)**
|
||||||
|
- **[Tighten Co.](https://tighten.co)**
|
||||||
|
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)**
|
||||||
|
- **[64 Robots](https://64robots.com)**
|
||||||
|
- **[Curotec](https://www.curotec.com/services/technologies/laravel)**
|
||||||
|
- **[DevSquad](https://devsquad.com/hire-laravel-developers)**
|
||||||
|
- **[Redberry](https://redberry.international/laravel-development)**
|
||||||
|
- **[Active Logic](https://activelogic.com)**
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions).
|
||||||
|
|
||||||
|
## Code of Conduct
|
||||||
|
|
||||||
|
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct).
|
||||||
|
|
||||||
|
## Security Vulnerabilities
|
||||||
|
|
||||||
|
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||||
93
app/Filament/Clusters/Loans/LoanOrders/LoanOrderResource.php
Normal file
93
app/Filament/Clusters/Loans/LoanOrders/LoanOrderResource.php
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Loans\LoanOrders;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\Loans\LoanOrders\Pages\CreateLoanOrder;
|
||||||
|
use App\Filament\Clusters\Loans\LoanOrders\Pages\EditLoanOrder;
|
||||||
|
use App\Filament\Clusters\Loans\LoanOrders\Pages\ListLoanOrders;
|
||||||
|
use App\Filament\Clusters\Loans\LoanOrders\Pages\ViewLoanOrder;
|
||||||
|
use App\Filament\Clusters\Loans\LoanOrders\Schemas\LoanOrderForm;
|
||||||
|
use App\Filament\Clusters\Loans\LoanOrders\Schemas\LoanOrderInfolist;
|
||||||
|
use App\Filament\Clusters\Loans\LoanOrders\Tables\LoanOrdersTable;
|
||||||
|
use App\Filament\Clusters\Loans\LoansCluster;
|
||||||
|
use App\Modules\LoanOrder\Models\LoanOrder;
|
||||||
|
use BackedEnum;
|
||||||
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
use Filament\Support\Icons\Heroicon;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
|
|
||||||
|
class LoanOrderResource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?int $navigationSort = 2;
|
||||||
|
|
||||||
|
protected static ?string $model = LoanOrder::class;
|
||||||
|
|
||||||
|
protected static ?string $cluster = LoansCluster::class;
|
||||||
|
|
||||||
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedDocumentPlus;
|
||||||
|
|
||||||
|
protected static string|BackedEnum|null $activeNavigationIcon = Heroicon::DocumentPlus;
|
||||||
|
|
||||||
|
protected static ?string $recordTitleAttribute = 'unique_id';
|
||||||
|
|
||||||
|
public static function getNavigationLabel(): string
|
||||||
|
{
|
||||||
|
return __('New loan order');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getModelLabel(): string
|
||||||
|
{
|
||||||
|
return __('module.loan-order::loan-order.loan_order');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPluralModelLabel(): string
|
||||||
|
{
|
||||||
|
return __('module.loan-order::loan-order.loan_orders');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function form(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return LoanOrderForm::configure($schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function infolist(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return LoanOrderInfolist::configure($schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return LoanOrdersTable::configure($table);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getRelations(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => ListLoanOrders::route('/'),
|
||||||
|
'create' => CreateLoanOrder::route('/create'),
|
||||||
|
'view' => ViewLoanOrder::route('/{record}'),
|
||||||
|
'edit' => EditLoanOrder::route('/{record}/edit'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Builder<LoanOrder>
|
||||||
|
*/
|
||||||
|
public static function getRecordRouteBindingEloquentQuery(): Builder
|
||||||
|
{
|
||||||
|
return parent::getRecordRouteBindingEloquentQuery()
|
||||||
|
->withoutGlobalScopes([
|
||||||
|
SoftDeletingScope::class,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Loans\LoanOrders\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\Loans\LoanOrders\LoanOrderResource;
|
||||||
|
use Filament\Resources\Pages\CreateRecord;
|
||||||
|
|
||||||
|
class CreateLoanOrder extends CreateRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = LoanOrderResource::class;
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Loans\LoanOrders\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\Loans\LoanOrders\LoanOrderResource;
|
||||||
|
use Filament\Actions\DeleteAction;
|
||||||
|
use Filament\Actions\ForceDeleteAction;
|
||||||
|
use Filament\Actions\RestoreAction;
|
||||||
|
use Filament\Actions\ViewAction;
|
||||||
|
use Filament\Resources\Pages\EditRecord;
|
||||||
|
|
||||||
|
class EditLoanOrder extends EditRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = LoanOrderResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
ViewAction::make(),
|
||||||
|
DeleteAction::make(),
|
||||||
|
ForceDeleteAction::make(),
|
||||||
|
RestoreAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Loans\LoanOrders\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\Loans\LoanOrders\LoanOrderResource;
|
||||||
|
use Filament\Actions\CreateAction;
|
||||||
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
|
class ListLoanOrders extends ListRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = LoanOrderResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
CreateAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Loans\LoanOrders\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\Loans\LoanOrders\LoanOrderResource;
|
||||||
|
use Filament\Actions\EditAction;
|
||||||
|
use Filament\Resources\Pages\ViewRecord;
|
||||||
|
|
||||||
|
class ViewLoanOrder extends ViewRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = LoanOrderResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
EditAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
333
app/Filament/Clusters/Loans/LoanOrders/Schemas/LoanOrderForm.php
Normal file
333
app/Filament/Clusters/Loans/LoanOrders/Schemas/LoanOrderForm.php
Normal file
@@ -0,0 +1,333 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Loans\LoanOrders\Schemas;
|
||||||
|
|
||||||
|
use App\Modules\LoanOrder\Models\LoanOrderRequiredDocs;
|
||||||
|
use App\Modules\LoanOrder\Repositories\LoanOrderRepository;
|
||||||
|
use App\Modules\OrderStatus\Repositories\OrderStatusRepository;
|
||||||
|
use App\Modules\PersonStates\Repositories\EducationRepository;
|
||||||
|
use App\Modules\PersonStates\Repositories\MarriageRepository;
|
||||||
|
use App\Modules\PhoneNumberVerification\Rules\PhoneNumberVerificationRule;
|
||||||
|
use App\Modules\Region\Repositories\RegionRepository;
|
||||||
|
use App\Modules\TurkmenPassport\Repositories\TurkmenPassportRepository;
|
||||||
|
use Filament\Forms\Components\DatePicker;
|
||||||
|
use Filament\Forms\Components\FileUpload;
|
||||||
|
use Filament\Forms\Components\Hidden;
|
||||||
|
use Filament\Forms\Components\RichEditor;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Schemas\Components\Fieldset;
|
||||||
|
use Filament\Schemas\Components\FusedGroup;
|
||||||
|
use Filament\Schemas\Components\Section;
|
||||||
|
use Filament\Schemas\Components\Wizard;
|
||||||
|
use Filament\Schemas\Components\Wizard\Step;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class LoanOrderForm
|
||||||
|
{
|
||||||
|
public static function configure(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema
|
||||||
|
->columns(4)
|
||||||
|
->components([
|
||||||
|
Hidden::make('source')->default('web'),
|
||||||
|
Hidden::make('user_id')->default(Auth::id()),
|
||||||
|
|
||||||
|
Section::make(__('New loan order'))
|
||||||
|
->columnSpan(4)
|
||||||
|
->columns(4)
|
||||||
|
->components([
|
||||||
|
Select::make('status')
|
||||||
|
->label(__('Status'))
|
||||||
|
->options(OrderStatusRepository::statusValues())
|
||||||
|
->default(OrderStatusRepository::defaultStatus())
|
||||||
|
->native(false)
|
||||||
|
->required()
|
||||||
|
->columnSpan(2),
|
||||||
|
|
||||||
|
Select::make('satisfiable')
|
||||||
|
->label(__('Loan history'))
|
||||||
|
->options(LoanOrderRepository::satisfiableValues())
|
||||||
|
->native(false)
|
||||||
|
->columnSpan(2),
|
||||||
|
|
||||||
|
Select::make('loan_order_required_doc_id')
|
||||||
|
->label(__('Required documents'))
|
||||||
|
->relationship('requiredDocs', 'name')
|
||||||
|
->searchable()
|
||||||
|
->native(false)
|
||||||
|
->preload()
|
||||||
|
->live()
|
||||||
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
|
if ($state) {
|
||||||
|
/** @var null|LoanOrderRequiredDocs */
|
||||||
|
$requiredDoc = LoanOrderRequiredDocs::find($state);
|
||||||
|
|
||||||
|
if ($requiredDoc) {
|
||||||
|
$set('notes', $requiredDoc->value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->columnSpanFull(),
|
||||||
|
|
||||||
|
RichEditor::make('notes')
|
||||||
|
->label(__('Bellik'))
|
||||||
|
->columnSpanFull(),
|
||||||
|
]),
|
||||||
|
|
||||||
|
Wizard::make([
|
||||||
|
Step::make(__('Loan & Bank'))
|
||||||
|
->schema([
|
||||||
|
Fieldset::make(__('Loan type and amount'))
|
||||||
|
->schema([
|
||||||
|
Select::make('loan_type')
|
||||||
|
->label(__('Loan type'))
|
||||||
|
->relationship('loanType', 'name')
|
||||||
|
->required(),
|
||||||
|
|
||||||
|
TextInput::make('loan_amount')
|
||||||
|
->label(__('Loan amount'))
|
||||||
|
->numeric()
|
||||||
|
->required()
|
||||||
|
->minValue(1)
|
||||||
|
->maxValue(40000)
|
||||||
|
->suffix('TMT')
|
||||||
|
->belowContent(__('Max is 40 000 TMT')),
|
||||||
|
]),
|
||||||
|
|
||||||
|
Fieldset::make(__('Location'))
|
||||||
|
->schema([
|
||||||
|
Select::make('region')
|
||||||
|
->label(__('Region'))
|
||||||
|
->options(RegionRepository::values())
|
||||||
|
->live()
|
||||||
|
->afterStateUpdated(fn (callable $set) => $set('branch_id', null))
|
||||||
|
->required(),
|
||||||
|
|
||||||
|
Select::make('branch_id')
|
||||||
|
->label(__('Branch'))
|
||||||
|
->relationship('branch', 'name', function ($query, callable $get) {
|
||||||
|
$region = $get('region');
|
||||||
|
if ($region) {
|
||||||
|
$query->where('region', $region);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->required(),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
Step::make(__('Personal information'))
|
||||||
|
->columns(8)
|
||||||
|
->schema([
|
||||||
|
TextInput::make('customer_name')
|
||||||
|
->label(__('Name'))
|
||||||
|
->columnSpan(2)
|
||||||
|
->required()
|
||||||
|
->maxLength(255)
|
||||||
|
->autocomplete(Str::random(10)),
|
||||||
|
|
||||||
|
TextInput::make('customer_surname')
|
||||||
|
->label(__('Surname'))
|
||||||
|
->columnSpan(2)
|
||||||
|
->required()
|
||||||
|
->maxLength(255),
|
||||||
|
|
||||||
|
TextInput::make('customer_patronic_name')
|
||||||
|
->label(__('Patronic name'))
|
||||||
|
->columnSpan(2)
|
||||||
|
->maxLength(255),
|
||||||
|
|
||||||
|
DatePicker::make('born_at')
|
||||||
|
->displayFormat('d.m.Y')
|
||||||
|
->label(__('Birth date'))
|
||||||
|
->native(false)
|
||||||
|
->columnSpan(2)
|
||||||
|
->required()
|
||||||
|
->beforeOrEqual('today'),
|
||||||
|
|
||||||
|
FusedGroup::make([
|
||||||
|
Select::make('passport_serie')
|
||||||
|
->label(__('Passport serie'))
|
||||||
|
->options(TurkmenPassportRepository::values())
|
||||||
|
->native(false)
|
||||||
|
->required()
|
||||||
|
->columnSpan(1),
|
||||||
|
|
||||||
|
TextInput::make('passport_id')
|
||||||
|
->label(__('Passport number'))
|
||||||
|
->required()
|
||||||
|
->columnSpan(1)
|
||||||
|
->mask('999999'),
|
||||||
|
])
|
||||||
|
->columnSpan(3)
|
||||||
|
->label(__('Passport serie and number'))
|
||||||
|
->columns(2),
|
||||||
|
|
||||||
|
DatePicker::make('passport_given_at')
|
||||||
|
->label(__('Passport given date'))
|
||||||
|
->columnSpan(2)
|
||||||
|
->displayFormat('d.m.Y')
|
||||||
|
->native(false)
|
||||||
|
->closeOnDateSelection()
|
||||||
|
->beforeOrEqual('today')
|
||||||
|
->required(),
|
||||||
|
|
||||||
|
TextInput::make('born_place')
|
||||||
|
->columnSpan(3)
|
||||||
|
->label(__('Born place (passport)'))
|
||||||
|
->maxLength(255)
|
||||||
|
->required(),
|
||||||
|
|
||||||
|
TextInput::make('passport_given_by')
|
||||||
|
->label(__('Passport given by'))
|
||||||
|
->columnSpan(4)
|
||||||
|
->maxLength(255)
|
||||||
|
->required(),
|
||||||
|
|
||||||
|
TextInput::make('passport_address')
|
||||||
|
->columnSpan(4)
|
||||||
|
->label(__('Proscription for home'))
|
||||||
|
->maxLength(255)
|
||||||
|
->required(),
|
||||||
|
|
||||||
|
TextInput::make('real_address')
|
||||||
|
->label(__('Current home address'))
|
||||||
|
->columnSpan(4)
|
||||||
|
->maxLength(255)
|
||||||
|
->required(),
|
||||||
|
|
||||||
|
TextInput::make('email')
|
||||||
|
->label(__('Email'))
|
||||||
|
->email()
|
||||||
|
->maxLength(255)
|
||||||
|
->columnSpan(2),
|
||||||
|
|
||||||
|
TextInput::make('phone')
|
||||||
|
->label(__('Phone'))
|
||||||
|
->required()
|
||||||
|
->mask('99 99 99 99')
|
||||||
|
->prefix('+993')
|
||||||
|
->rules([
|
||||||
|
new PhoneNumberVerificationRule,
|
||||||
|
])
|
||||||
|
->columnSpan(2),
|
||||||
|
|
||||||
|
TextInput::make('phone_additional')
|
||||||
|
->label(__('Additional phone'))
|
||||||
|
->mask('99 99 99 99')
|
||||||
|
->prefix('+993')
|
||||||
|
->rules([
|
||||||
|
new PhoneNumberVerificationRule,
|
||||||
|
])
|
||||||
|
->columnSpan(2),
|
||||||
|
|
||||||
|
TextInput::make('phone_home')
|
||||||
|
->label(__('Home phone'))
|
||||||
|
->numeric()
|
||||||
|
->prefix('+993')
|
||||||
|
->columnSpan(2),
|
||||||
|
|
||||||
|
Select::make('education')
|
||||||
|
->columnSpan(2)
|
||||||
|
->label(__('Education'))
|
||||||
|
->options(EducationRepository::values())
|
||||||
|
->native(false)
|
||||||
|
->required(),
|
||||||
|
|
||||||
|
Select::make('marriage_status')
|
||||||
|
->columnSpan(2)
|
||||||
|
->label(__('Marital status'))
|
||||||
|
->options(MarriageRepository::values())
|
||||||
|
->native(false)
|
||||||
|
->required(),
|
||||||
|
]),
|
||||||
|
Step::make(__('Pasport files'))
|
||||||
|
->columns(4)
|
||||||
|
->schema([
|
||||||
|
FileUpload::make('passport_one')
|
||||||
|
->label(__('Passport (page 1)'))
|
||||||
|
->image()
|
||||||
|
->maxSize(4096)
|
||||||
|
->required()
|
||||||
|
->columnSpan(2),
|
||||||
|
|
||||||
|
FileUpload::make('passport_two')
|
||||||
|
->label(__('Passport (page 2-3)'))
|
||||||
|
->image()
|
||||||
|
->maxSize(4096)
|
||||||
|
->required()
|
||||||
|
->columnSpan(2),
|
||||||
|
|
||||||
|
FileUpload::make('passport_three')
|
||||||
|
->label(__('Passport (page 8-9)'))
|
||||||
|
->image()
|
||||||
|
->maxSize(4096)
|
||||||
|
->required()
|
||||||
|
->columnSpan(2),
|
||||||
|
|
||||||
|
FileUpload::make('passport_four')
|
||||||
|
->label(__('Passport (page 32)'))
|
||||||
|
->image()
|
||||||
|
->maxSize(4096)
|
||||||
|
->required()
|
||||||
|
->columnSpan(2),
|
||||||
|
])->columnSpan(4),
|
||||||
|
Step::make(__('Work'))
|
||||||
|
->columns(4)
|
||||||
|
->schema([
|
||||||
|
Select::make('work_region')
|
||||||
|
->label(__('Work region'))
|
||||||
|
->options(RegionRepository::values())
|
||||||
|
->columnSpan(1)
|
||||||
|
->live()
|
||||||
|
->afterStateUpdated(fn (callable $set) => $set('branch_id', null))
|
||||||
|
->required(),
|
||||||
|
|
||||||
|
Select::make('work_province_id')
|
||||||
|
->label(__('Work province'))
|
||||||
|
->relationship('workProvince', 'name', function ($query, callable $get) {
|
||||||
|
$region = $get('work_region');
|
||||||
|
if ($region) {
|
||||||
|
$query->where('region', $region);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->columnSpan(1)
|
||||||
|
->required(),
|
||||||
|
|
||||||
|
TextInput::make('work_company')
|
||||||
|
->label(__('Work company name'))
|
||||||
|
->maxLength(255)
|
||||||
|
->required()
|
||||||
|
->columnSpan(2),
|
||||||
|
|
||||||
|
TextInput::make('work_company_accountant_number')
|
||||||
|
->label(__('HR number'))
|
||||||
|
->prefix('+993')
|
||||||
|
->numeric()
|
||||||
|
->required()
|
||||||
|
->columnSpan(1),
|
||||||
|
|
||||||
|
TextInput::make('work_position')
|
||||||
|
->label(__('Work position'))
|
||||||
|
->required()
|
||||||
|
->maxLength(255)
|
||||||
|
->columnSpan(1),
|
||||||
|
|
||||||
|
TextInput::make('work_salary')
|
||||||
|
->label(__('Salary'))
|
||||||
|
->numeric()
|
||||||
|
->required()
|
||||||
|
->columnSpan(1),
|
||||||
|
|
||||||
|
DatePicker::make('work_started_at')
|
||||||
|
->label(__('Work started at'))
|
||||||
|
->displayFormat('d.m.Y')
|
||||||
|
->beforeOrEqual('today')
|
||||||
|
->required()
|
||||||
|
->columnSpan(1),
|
||||||
|
]),
|
||||||
|
])->columnSpan(4),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,154 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Loans\LoanOrders\Schemas;
|
||||||
|
|
||||||
|
use App\Modules\LoanOrder\Models\LoanOrder;
|
||||||
|
use Filament\Infolists\Components\TextEntry;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
|
||||||
|
class LoanOrderInfolist
|
||||||
|
{
|
||||||
|
public static function configure(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema
|
||||||
|
->components([
|
||||||
|
TextEntry::make('unique_id')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('source')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('user.name')
|
||||||
|
->label('User')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('loan_type')
|
||||||
|
->numeric(),
|
||||||
|
TextEntry::make('region'),
|
||||||
|
TextEntry::make('branch.name')
|
||||||
|
->label('Branch'),
|
||||||
|
TextEntry::make('customer_name'),
|
||||||
|
TextEntry::make('customer_surname'),
|
||||||
|
TextEntry::make('customer_patronic_name')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('passport_address'),
|
||||||
|
TextEntry::make('real_address'),
|
||||||
|
TextEntry::make('passport_serie'),
|
||||||
|
TextEntry::make('passport_id'),
|
||||||
|
TextEntry::make('passport_given_at')
|
||||||
|
->date(),
|
||||||
|
TextEntry::make('passport_given_by'),
|
||||||
|
TextEntry::make('born_place'),
|
||||||
|
TextEntry::make('born_at')
|
||||||
|
->date(),
|
||||||
|
TextEntry::make('email')
|
||||||
|
->label('Email address')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('phone'),
|
||||||
|
TextEntry::make('phone_additional')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('phone_home')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('work_region')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('workProvince.name')
|
||||||
|
->label('Work province')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('work_company')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('work_company_accountant_number')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('work_started_at')
|
||||||
|
->date()
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('work_salary')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('work_position')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('education'),
|
||||||
|
TextEntry::make('marriage_status'),
|
||||||
|
TextEntry::make('passport_one')
|
||||||
|
->columnSpanFull(),
|
||||||
|
TextEntry::make('passport_two')
|
||||||
|
->columnSpanFull(),
|
||||||
|
TextEntry::make('passport_three')
|
||||||
|
->columnSpanFull(),
|
||||||
|
TextEntry::make('passport_four')
|
||||||
|
->columnSpanFull(),
|
||||||
|
TextEntry::make('loan_amount')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('card_number')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('card_name')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('card_month')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('card_year')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('guarantor_name')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('guarantor_surname')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('guarantor_patronic_name')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('guarantor_passport_serie')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('guarantor_passport_id')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('guarantor_card_number')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('guarantor_card_name')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('guarantor_card_month')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('guarantor_card_year')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('guarantor_note')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('guarantor_2_name')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('guarantor_2_surname')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('guarantor_2_patronic_name')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('guarantor_2_passport_serie')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('guarantor_2_passport_id')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('guarantor_2_card_number')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('guarantor_2_card_name')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('guarantor_2_card_month')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('guarantor_2_card_year')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('guarantor_2_note')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('loan_card_number')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('loan_card_name')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('loan_card_month')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('loan_card_year')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('loan_order_required_doc_id')
|
||||||
|
->numeric()
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('status')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('satisfiable')
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('notes')
|
||||||
|
->placeholder('-')
|
||||||
|
->columnSpanFull(),
|
||||||
|
TextEntry::make('created_at')
|
||||||
|
->dateTime()
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('updated_at')
|
||||||
|
->dateTime()
|
||||||
|
->placeholder('-'),
|
||||||
|
TextEntry::make('deleted_at')
|
||||||
|
->dateTime()
|
||||||
|
->visible(fn (LoanOrder $record): bool => $record->trashed()),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Loans\LoanOrders\Tables;
|
||||||
|
|
||||||
|
use Filament\Actions\BulkActionGroup;
|
||||||
|
use Filament\Actions\DeleteBulkAction;
|
||||||
|
use Filament\Actions\EditAction;
|
||||||
|
use Filament\Actions\ForceDeleteBulkAction;
|
||||||
|
use Filament\Actions\RestoreBulkAction;
|
||||||
|
use Filament\Actions\ViewAction;
|
||||||
|
use Filament\Tables\Columns\TextColumn;
|
||||||
|
use Filament\Tables\Filters\TrashedFilter;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
|
||||||
|
class LoanOrdersTable
|
||||||
|
{
|
||||||
|
public static function configure(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->columns([
|
||||||
|
TextColumn::make('id')
|
||||||
|
->label('ID')
|
||||||
|
->sortable(),
|
||||||
|
|
||||||
|
TextColumn::make('loanType.name')
|
||||||
|
->label('Тип кредита')
|
||||||
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
|
|
||||||
|
TextColumn::make('region')
|
||||||
|
->label('Регион')
|
||||||
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
|
|
||||||
|
TextColumn::make('branch.name')
|
||||||
|
->label('Филиал')
|
||||||
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
|
|
||||||
|
TextColumn::make('customer_name')
|
||||||
|
->label('Имя клиента')
|
||||||
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
|
|
||||||
|
TextColumn::make('customer_surname')
|
||||||
|
->label('Фамилия клиента')
|
||||||
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
|
|
||||||
|
TextColumn::make('phone')
|
||||||
|
->label('Телефон')
|
||||||
|
->searchable(),
|
||||||
|
|
||||||
|
TextColumn::make('status')
|
||||||
|
->label('Статус')
|
||||||
|
->sortable()
|
||||||
|
->searchable(),
|
||||||
|
|
||||||
|
TextColumn::make('created_at')
|
||||||
|
->label('Дата создания')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(),
|
||||||
|
|
||||||
|
TextColumn::make('updated_at')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
TextColumn::make('deleted_at')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
])
|
||||||
|
->filters([
|
||||||
|
TrashedFilter::make(),
|
||||||
|
])
|
||||||
|
->recordActions([
|
||||||
|
ViewAction::make(),
|
||||||
|
EditAction::make(),
|
||||||
|
])
|
||||||
|
->toolbarActions([
|
||||||
|
BulkActionGroup::make([
|
||||||
|
DeleteBulkAction::make(),
|
||||||
|
ForceDeleteBulkAction::make(),
|
||||||
|
RestoreBulkAction::make(),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
68
app/Filament/Clusters/Loans/Loans/LoanResource.php
Normal file
68
app/Filament/Clusters/Loans/Loans/LoanResource.php
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Loans\Loans;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\Loans\Loans\Pages\ListLoans;
|
||||||
|
use App\Filament\Clusters\Loans\Loans\Schemas\LoanForm;
|
||||||
|
use App\Filament\Clusters\Loans\Loans\Tables\LoansTable;
|
||||||
|
use App\Filament\Clusters\Loans\LoansCluster;
|
||||||
|
use App\Modules\Loan\Models\Loan;
|
||||||
|
use BackedEnum;
|
||||||
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
use Filament\Support\Icons\Heroicon;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Contracts\Support\Htmlable;
|
||||||
|
|
||||||
|
class LoanResource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?int $navigationSort = 1;
|
||||||
|
|
||||||
|
protected static ?string $model = Loan::class;
|
||||||
|
|
||||||
|
protected static ?string $cluster = LoansCluster::class;
|
||||||
|
|
||||||
|
public static function getNavigationIcon(): string|BackedEnum|Htmlable|null
|
||||||
|
{
|
||||||
|
return Heroicon::OutlinedBanknotes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getNavigationLabel(): string
|
||||||
|
{
|
||||||
|
return __('My loans');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getModelLabel(): string
|
||||||
|
{
|
||||||
|
return __('Karz');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPluralModelLabel(): string
|
||||||
|
{
|
||||||
|
return __('Karzlar');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function form(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return LoanForm::configure($schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return LoansTable::configure($table);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getRelations(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => ListLoans::route('/'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
19
app/Filament/Clusters/Loans/Loans/Pages/ListLoans.php
Normal file
19
app/Filament/Clusters/Loans/Loans/Pages/ListLoans.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Loans\Loans\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\Loans\Loans\LoanResource;
|
||||||
|
use Filament\Actions\CreateAction;
|
||||||
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
|
class ListLoans extends ListRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = LoanResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
CreateAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
30
app/Filament/Clusters/Loans/Loans/Schemas/LoanForm.php
Normal file
30
app/Filament/Clusters/Loans/Loans/Schemas/LoanForm.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Loans\Loans\Schemas;
|
||||||
|
|
||||||
|
use Filament\Forms\Components\Hidden;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
|
||||||
|
class LoanForm
|
||||||
|
{
|
||||||
|
public static function configure(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema
|
||||||
|
->components([
|
||||||
|
Hidden::make('user_id')
|
||||||
|
->default(user()->id),
|
||||||
|
|
||||||
|
Hidden::make('passport_serie')
|
||||||
|
->default(user()->getOption('passport_serie')),
|
||||||
|
|
||||||
|
Hidden::make('passport_id')
|
||||||
|
->default(user()->getOption('passport_id')),
|
||||||
|
|
||||||
|
TextInput::make('account_number')
|
||||||
|
->required()
|
||||||
|
->string()
|
||||||
|
->maxLength(23),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
42
app/Filament/Clusters/Loans/Loans/Tables/LoansTable.php
Normal file
42
app/Filament/Clusters/Loans/Loans/Tables/LoansTable.php
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Loans\Loans\Tables;
|
||||||
|
|
||||||
|
use Filament\Actions\BulkActionGroup;
|
||||||
|
use Filament\Actions\DeleteBulkAction;
|
||||||
|
use Filament\Actions\EditAction;
|
||||||
|
use Filament\Tables\Columns\TextColumn;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
|
||||||
|
class LoansTable
|
||||||
|
{
|
||||||
|
public static function configure(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->columns([
|
||||||
|
TextColumn::make('account_number')
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
|
||||||
|
TextColumn::make('created_at')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
TextColumn::make('updated_at')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
])
|
||||||
|
->filters([
|
||||||
|
//
|
||||||
|
])
|
||||||
|
->recordActions([
|
||||||
|
EditAction::make(),
|
||||||
|
])
|
||||||
|
->toolbarActions([
|
||||||
|
BulkActionGroup::make([
|
||||||
|
DeleteBulkAction::make(),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
21
app/Filament/Clusters/Loans/LoansCluster.php
Normal file
21
app/Filament/Clusters/Loans/LoansCluster.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Loans;
|
||||||
|
|
||||||
|
use BackedEnum;
|
||||||
|
use Filament\Clusters\Cluster;
|
||||||
|
use Filament\Pages\Enums\SubNavigationPosition;
|
||||||
|
use Filament\Support\Icons\Heroicon;
|
||||||
|
|
||||||
|
class LoansCluster extends Cluster
|
||||||
|
{
|
||||||
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedBanknotes;
|
||||||
|
// protected static string|BackedEnum|null $activeNavigationIcon = Heroicon::Banknotes;
|
||||||
|
|
||||||
|
protected static ?SubNavigationPosition $subNavigationPosition = SubNavigationPosition::Top;
|
||||||
|
|
||||||
|
public static function getNavigationLabel(): string
|
||||||
|
{
|
||||||
|
return __('module.loan-order::loan-order.loans');
|
||||||
|
}
|
||||||
|
}
|
||||||
57
app/Filament/Clusters/Settings/Branches/BranchResource.php
Normal file
57
app/Filament/Clusters/Settings/Branches/BranchResource.php
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Settings\Branches;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\Settings\Branches\Pages\ManageBranches;
|
||||||
|
use App\Filament\Clusters\Settings\Branches\Schemas\BranchForm;
|
||||||
|
use App\Filament\Clusters\Settings\Branches\Tables\BranchesTable;
|
||||||
|
use App\Filament\Clusters\Settings\SettingsCluster;
|
||||||
|
use App\Modules\Branch\Models\Branch;
|
||||||
|
use BackedEnum;
|
||||||
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
use Filament\Support\Icons\Heroicon;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
|
||||||
|
class BranchResource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?string $model = Branch::class;
|
||||||
|
|
||||||
|
protected static ?string $cluster = SettingsCluster::class;
|
||||||
|
|
||||||
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedBuildingOffice2;
|
||||||
|
|
||||||
|
protected static ?string $recordTitleAttribute = 'name';
|
||||||
|
|
||||||
|
public static function getNavigationGroup(): ?string
|
||||||
|
{
|
||||||
|
return __('Branches and provinces');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getModelLabel(): string
|
||||||
|
{
|
||||||
|
return __('module.branch::base.branch');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPluralModelLabel(): string
|
||||||
|
{
|
||||||
|
return __('module.branch::base.branches');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function form(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return BranchForm::configure($schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return BranchesTable::configure($table);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => ManageBranches::route('/'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Settings\Branches\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\Settings\Branches\BranchResource;
|
||||||
|
use Filament\Actions\CreateAction;
|
||||||
|
use Filament\Resources\Pages\ManageRecords;
|
||||||
|
|
||||||
|
class ManageBranches extends ManageRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = BranchResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
CreateAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
134
app/Filament/Clusters/Settings/Branches/Schemas/BranchForm.php
Normal file
134
app/Filament/Clusters/Settings/Branches/Schemas/BranchForm.php
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Settings\Branches\Schemas;
|
||||||
|
|
||||||
|
use AbdulmajeedJamaan\FilamentTranslatableTabs\TranslatableTabs;
|
||||||
|
use App\Modules\Province\Models\Province;
|
||||||
|
use Filament\Forms\Components\Repeater;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\Textarea;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Forms\Components\Toggle;
|
||||||
|
use Filament\Schemas\Components\Section;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
|
||||||
|
class BranchForm
|
||||||
|
{
|
||||||
|
public static function configure(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema
|
||||||
|
->components([
|
||||||
|
Section::make(__('General Information'))
|
||||||
|
->columns(2)
|
||||||
|
->schema([
|
||||||
|
TextInput::make('unique_code')
|
||||||
|
->label(__('Unique code'))
|
||||||
|
->maxLength(255)
|
||||||
|
->unique(ignoreRecord: true)
|
||||||
|
->required(),
|
||||||
|
|
||||||
|
Select::make('region')
|
||||||
|
->label(__('Region'))
|
||||||
|
->options(fn () => regions())
|
||||||
|
->required()
|
||||||
|
->native(false)
|
||||||
|
->searchable()
|
||||||
|
->live()
|
||||||
|
->afterStateUpdated(fn ($state, callable $set) => $set('province_id', null)),
|
||||||
|
|
||||||
|
Select::make('province_id')
|
||||||
|
->label(__('Province'))
|
||||||
|
->relationship('province', 'name')
|
||||||
|
->options(function (callable $get) {
|
||||||
|
$region = $get('region');
|
||||||
|
if (! $region) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return Province::query()
|
||||||
|
->where('region', $region)
|
||||||
|
->where('active', true)
|
||||||
|
->pluck('name', 'id')
|
||||||
|
->toArray();
|
||||||
|
})
|
||||||
|
->searchable()
|
||||||
|
->native(false)
|
||||||
|
->disabled(fn (callable $get): bool => ! $get('region'))
|
||||||
|
->columnSpanFull(),
|
||||||
|
|
||||||
|
Toggle::make('active')
|
||||||
|
->label(__('Active'))
|
||||||
|
->default(true)
|
||||||
|
->required(),
|
||||||
|
|
||||||
|
Repeater::make('phone_numbers')
|
||||||
|
->label(__('Phone numbers'))
|
||||||
|
->simple(
|
||||||
|
TextInput::make('phone')
|
||||||
|
->label(__('Phone Number'))
|
||||||
|
->prefix('+993')
|
||||||
|
->numeric()
|
||||||
|
)
|
||||||
|
->addActionLabel(__('Add phone number'))
|
||||||
|
->defaultItems(0)
|
||||||
|
->columnSpanFull(),
|
||||||
|
]),
|
||||||
|
|
||||||
|
TranslatableTabs::make()
|
||||||
|
->schema([
|
||||||
|
TextInput::make('name')
|
||||||
|
->label(__('Name'))
|
||||||
|
->required()
|
||||||
|
->maxLength(255),
|
||||||
|
|
||||||
|
Textarea::make('address')
|
||||||
|
->label(__('Address'))
|
||||||
|
->rows(3),
|
||||||
|
|
||||||
|
]),
|
||||||
|
|
||||||
|
Section::make(__('Billing Credentials'))
|
||||||
|
->collapsed()
|
||||||
|
->collapsible()
|
||||||
|
->columns(2)
|
||||||
|
->columnSpanFull()
|
||||||
|
->schema([
|
||||||
|
TextInput::make('billing_username')
|
||||||
|
->label(__('Billing Username'))
|
||||||
|
->maxLength(255),
|
||||||
|
|
||||||
|
TextInput::make('billing_password')
|
||||||
|
->label(__('Billing Password'))
|
||||||
|
->password()
|
||||||
|
->maxLength(255),
|
||||||
|
|
||||||
|
TextInput::make('billing_swift_username')
|
||||||
|
->label(__('Billing SWIFT Username'))
|
||||||
|
->maxLength(255),
|
||||||
|
|
||||||
|
TextInput::make('billing_swift_password')
|
||||||
|
->label(__('Billing SWIFT Password'))
|
||||||
|
->password()
|
||||||
|
->maxLength(255),
|
||||||
|
|
||||||
|
TextInput::make('billing_visa_master_username')
|
||||||
|
->label(__('Billing Visa/Master Username'))
|
||||||
|
->maxLength(255),
|
||||||
|
|
||||||
|
TextInput::make('billing_visa_master_password')
|
||||||
|
->label(__('Billing Visa/Master Password'))
|
||||||
|
->password()
|
||||||
|
->maxLength(255),
|
||||||
|
|
||||||
|
TextInput::make('billing_sber_username')
|
||||||
|
->label(__('Billing Sber Username'))
|
||||||
|
->maxLength(255),
|
||||||
|
|
||||||
|
TextInput::make('billing_sber_password')
|
||||||
|
->label(__('Billing Sber Password'))
|
||||||
|
->password()
|
||||||
|
->maxLength(255),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Settings\Branches\Tables;
|
||||||
|
|
||||||
|
use App\Modules\Region\Repositories\RegionRepository;
|
||||||
|
use Filament\Actions\BulkActionGroup;
|
||||||
|
use Filament\Actions\DeleteBulkAction;
|
||||||
|
use Filament\Actions\EditAction;
|
||||||
|
use Filament\Tables\Columns\IconColumn;
|
||||||
|
use Filament\Tables\Columns\TextColumn;
|
||||||
|
use Filament\Tables\Filters\SelectFilter;
|
||||||
|
use Filament\Tables\Filters\TernaryFilter;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
|
||||||
|
class BranchesTable
|
||||||
|
{
|
||||||
|
public static function configure(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->columns([
|
||||||
|
TextColumn::make('unique_code')
|
||||||
|
->label(__('Unique code'))
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
|
||||||
|
TextColumn::make('name')
|
||||||
|
->label(__('Name'))
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
|
||||||
|
TextColumn::make('region')
|
||||||
|
->label(__('Region'))
|
||||||
|
->formatStateUsing(fn (string $state): string => RegionRepository::label($state))
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
|
||||||
|
TextColumn::make('province.name')
|
||||||
|
->label(__('Province'))
|
||||||
|
->searchable()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(),
|
||||||
|
|
||||||
|
IconColumn::make('active')
|
||||||
|
->label(__('Active'))
|
||||||
|
->boolean()
|
||||||
|
->sortable(),
|
||||||
|
|
||||||
|
TextColumn::make('created_at')
|
||||||
|
->label(__('Created At'))
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
|
||||||
|
TextColumn::make('updated_at')
|
||||||
|
->label(__('Updated At'))
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
])
|
||||||
|
->filters([
|
||||||
|
SelectFilter::make('region')
|
||||||
|
->label(__('Region'))
|
||||||
|
->options(fn () => regions())
|
||||||
|
->native(false),
|
||||||
|
|
||||||
|
TernaryFilter::make('active')
|
||||||
|
->label(__('Active'))
|
||||||
|
->boolean()
|
||||||
|
->trueLabel(__('Active only'))
|
||||||
|
->falseLabel(__('Inactive only'))
|
||||||
|
->native(false),
|
||||||
|
])
|
||||||
|
->recordActions([
|
||||||
|
EditAction::make(),
|
||||||
|
])
|
||||||
|
->toolbarActions([
|
||||||
|
BulkActionGroup::make([
|
||||||
|
DeleteBulkAction::make(),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Settings\LoanOrderRequiredDocs;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\Settings\LoanOrderRequiredDocs\Pages\ManageLoanOrderRequiredDocs;
|
||||||
|
use App\Filament\Clusters\Settings\LoanOrderRequiredDocs\Schemas\LoanOrderRequiredDocsForm;
|
||||||
|
use App\Filament\Clusters\Settings\LoanOrderRequiredDocs\Tables\LoanOrderRequiredDocsTable;
|
||||||
|
use App\Filament\Clusters\Settings\SettingsCluster;
|
||||||
|
use App\Modules\LoanOrder\Models\LoanOrderRequiredDocs;
|
||||||
|
use BackedEnum;
|
||||||
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
use Filament\Support\Icons\Heroicon;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
|
||||||
|
class LoanOrderRequiredDocsResource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?string $model = LoanOrderRequiredDocs::class;
|
||||||
|
|
||||||
|
protected static ?string $cluster = SettingsCluster::class;
|
||||||
|
|
||||||
|
protected static ?int $navigationSort = 2;
|
||||||
|
|
||||||
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedClipboardDocumentList;
|
||||||
|
|
||||||
|
protected static ?string $recordTitleAttribute = 'name';
|
||||||
|
|
||||||
|
public static function getNavigationGroup(): ?string
|
||||||
|
{
|
||||||
|
return __('module.loan-order::loan-order.loans');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getModelLabel(): string
|
||||||
|
{
|
||||||
|
return __('module.loan-order::loan-order.loan_order_required_docs');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPluralModelLabel(): string
|
||||||
|
{
|
||||||
|
return __('module.loan-order::loan-order.loan_order_required_docs');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function form(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return LoanOrderRequiredDocsForm::configure($schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return LoanOrderRequiredDocsTable::configure($table);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => ManageLoanOrderRequiredDocs::route('/'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Settings\LoanOrderRequiredDocs\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\Settings\LoanOrderRequiredDocs\LoanOrderRequiredDocsResource;
|
||||||
|
use Filament\Actions\CreateAction;
|
||||||
|
use Filament\Resources\Pages\ManageRecords;
|
||||||
|
|
||||||
|
class ManageLoanOrderRequiredDocs extends ManageRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = LoanOrderRequiredDocsResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
CreateAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Settings\LoanOrderRequiredDocs\Schemas;
|
||||||
|
|
||||||
|
use AbdulmajeedJamaan\FilamentTranslatableTabs\TranslatableTabs;
|
||||||
|
use Filament\Forms\Components\RichEditor;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
|
||||||
|
class LoanOrderRequiredDocsForm
|
||||||
|
{
|
||||||
|
public static function configure(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema
|
||||||
|
->components([
|
||||||
|
TranslatableTabs::make('anyLabel')
|
||||||
|
->columnSpanFull()
|
||||||
|
->schema([
|
||||||
|
TextInput::make('name')
|
||||||
|
->label(__('Name'))
|
||||||
|
->required()
|
||||||
|
->maxLength(255),
|
||||||
|
|
||||||
|
RichEditor::make('value')
|
||||||
|
->label(__('Value'))
|
||||||
|
->required()
|
||||||
|
->maxLength(255),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Settings\LoanOrderRequiredDocs\Tables;
|
||||||
|
|
||||||
|
use Filament\Actions\BulkActionGroup;
|
||||||
|
use Filament\Actions\DeleteBulkAction;
|
||||||
|
use Filament\Actions\EditAction;
|
||||||
|
use Filament\Tables\Columns\TextColumn;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
|
||||||
|
class LoanOrderRequiredDocsTable
|
||||||
|
{
|
||||||
|
public static function configure(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->columns([
|
||||||
|
TextColumn::make('name')
|
||||||
|
->label(__('Name'))
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
|
||||||
|
TextColumn::make('created_at')
|
||||||
|
->label(__('Created At'))
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
|
||||||
|
TextColumn::make('updated_at')
|
||||||
|
->label(__('Updated At'))
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
])
|
||||||
|
->filters([
|
||||||
|
//
|
||||||
|
])
|
||||||
|
->recordActions([
|
||||||
|
EditAction::make(),
|
||||||
|
])
|
||||||
|
->toolbarActions([
|
||||||
|
BulkActionGroup::make([
|
||||||
|
DeleteBulkAction::make(),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Settings\LoanTypes;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\Settings\LoanTypes\Pages\ListLoanTypes;
|
||||||
|
use App\Filament\Clusters\Settings\LoanTypes\Schemas\LoanTypeForm;
|
||||||
|
use App\Filament\Clusters\Settings\LoanTypes\Schemas\LoanTypeInfolist;
|
||||||
|
use App\Filament\Clusters\Settings\LoanTypes\Tables\LoanTypesTable;
|
||||||
|
use App\Filament\Clusters\Settings\SettingsCluster;
|
||||||
|
use App\Modules\LoanOrder\Models\LoanType;
|
||||||
|
use BackedEnum;
|
||||||
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
use Filament\Support\Icons\Heroicon;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
|
||||||
|
class LoanTypeResource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?string $model = LoanType::class;
|
||||||
|
|
||||||
|
protected static ?string $cluster = SettingsCluster::class;
|
||||||
|
|
||||||
|
protected static ?int $navigationSort = 1;
|
||||||
|
|
||||||
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedBanknotes;
|
||||||
|
|
||||||
|
protected static ?string $recordTitleAttribute = 'name';
|
||||||
|
|
||||||
|
public static function getNavigationGroup(): ?string
|
||||||
|
{
|
||||||
|
return __('module.loan-order::loan-order.loans');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getModelLabel(): string
|
||||||
|
{
|
||||||
|
return __('module.loan-order::loan-type.loan_type');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPluralModelLabel(): string
|
||||||
|
{
|
||||||
|
return __('module.loan-order::loan-type.loan_type');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function form(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return LoanTypeForm::configure($schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function infolist(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return LoanTypeInfolist::configure($schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return LoanTypesTable::configure($table);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getRelations(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => ListLoanTypes::route('/'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Settings\LoanTypes\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\Settings\LoanTypes\LoanTypeResource;
|
||||||
|
use Filament\Actions\CreateAction;
|
||||||
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
|
class ListLoanTypes extends ListRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = LoanTypeResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
CreateAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Settings\LoanTypes\Schemas;
|
||||||
|
|
||||||
|
use AbdulmajeedJamaan\FilamentTranslatableTabs\TranslatableTabs;
|
||||||
|
use Filament\Forms\Components\Textarea;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Forms\Components\Toggle;
|
||||||
|
use Filament\Schemas\Components\Section;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
|
||||||
|
class LoanTypeForm
|
||||||
|
{
|
||||||
|
public static function configure(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema
|
||||||
|
->components([
|
||||||
|
TranslatableTabs::make()
|
||||||
|
->schema([
|
||||||
|
TextInput::make('name')
|
||||||
|
->label(__('Name'))
|
||||||
|
->required()
|
||||||
|
->maxLength(255),
|
||||||
|
|
||||||
|
Textarea::make('notes')
|
||||||
|
->label(__('Notes'))
|
||||||
|
->rows(3),
|
||||||
|
]),
|
||||||
|
|
||||||
|
Section::make()
|
||||||
|
->columns(2)
|
||||||
|
->schema([
|
||||||
|
TextInput::make('tax')
|
||||||
|
->label(__('Tax'))
|
||||||
|
->numeric()
|
||||||
|
->suffix('%')
|
||||||
|
->maxLength(255),
|
||||||
|
|
||||||
|
TextInput::make('maturity')
|
||||||
|
->label(__('Loan term'))
|
||||||
|
->maxLength(255),
|
||||||
|
|
||||||
|
Toggle::make('active')
|
||||||
|
->label(__('Active'))
|
||||||
|
->default(true)
|
||||||
|
->required(),
|
||||||
|
]),
|
||||||
|
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Settings\LoanTypes\Schemas;
|
||||||
|
|
||||||
|
use Filament\Infolists\Components\IconEntry;
|
||||||
|
use Filament\Infolists\Components\TextEntry;
|
||||||
|
use Filament\Schemas\Components\Section;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
|
||||||
|
class LoanTypeInfolist
|
||||||
|
{
|
||||||
|
public static function configure(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema
|
||||||
|
->components([
|
||||||
|
Section::make(__('Loan Type Information'))
|
||||||
|
->columns(2)
|
||||||
|
->components([
|
||||||
|
TextEntry::make('name')
|
||||||
|
->label(__('Name')),
|
||||||
|
|
||||||
|
TextEntry::make('tax')
|
||||||
|
->label(__('Tax'))
|
||||||
|
->suffix('%')
|
||||||
|
->default('—'),
|
||||||
|
|
||||||
|
TextEntry::make('maturity')
|
||||||
|
->label(__('Loan term'))
|
||||||
|
->default('—'),
|
||||||
|
|
||||||
|
IconEntry::make('active')
|
||||||
|
->label(__('Active'))
|
||||||
|
->boolean(),
|
||||||
|
|
||||||
|
TextEntry::make('notes')
|
||||||
|
->label(__('Notes'))
|
||||||
|
->columnSpanFull()
|
||||||
|
->default('—'),
|
||||||
|
|
||||||
|
TextEntry::make('created_at')
|
||||||
|
->label(__('Created At'))
|
||||||
|
->dateTime(),
|
||||||
|
|
||||||
|
TextEntry::make('updated_at')
|
||||||
|
->label(__('Updated At'))
|
||||||
|
->dateTime(),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Settings\LoanTypes\Tables;
|
||||||
|
|
||||||
|
use Filament\Actions\BulkActionGroup;
|
||||||
|
use Filament\Actions\DeleteBulkAction;
|
||||||
|
use Filament\Actions\EditAction;
|
||||||
|
use Filament\Tables\Columns\IconColumn;
|
||||||
|
use Filament\Tables\Columns\TextColumn;
|
||||||
|
use Filament\Tables\Filters\TernaryFilter;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
|
||||||
|
class LoanTypesTable
|
||||||
|
{
|
||||||
|
public static function configure(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->columns([
|
||||||
|
TextColumn::make('name')
|
||||||
|
->label(__('Name'))
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
|
||||||
|
TextColumn::make('tax')
|
||||||
|
->label(__('Tax'))
|
||||||
|
->suffix('%')
|
||||||
|
->sortable()
|
||||||
|
->default('—'),
|
||||||
|
|
||||||
|
TextColumn::make('maturity')
|
||||||
|
->label(__('Loan term'))
|
||||||
|
->sortable()
|
||||||
|
->default('—'),
|
||||||
|
|
||||||
|
IconColumn::make('active')
|
||||||
|
->label(__('Active'))
|
||||||
|
->boolean()
|
||||||
|
->sortable(),
|
||||||
|
|
||||||
|
TextColumn::make('created_at')
|
||||||
|
->label(__('Created At'))
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
|
||||||
|
TextColumn::make('updated_at')
|
||||||
|
->label(__('Updated At'))
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
])
|
||||||
|
->filters([
|
||||||
|
TernaryFilter::make('active')
|
||||||
|
->label(__('Active'))
|
||||||
|
->boolean()
|
||||||
|
->trueLabel(__('Active only'))
|
||||||
|
->falseLabel(__('Inactive only'))
|
||||||
|
->native(false),
|
||||||
|
])
|
||||||
|
->recordActions([
|
||||||
|
EditAction::make(),
|
||||||
|
])
|
||||||
|
->toolbarActions([
|
||||||
|
BulkActionGroup::make([
|
||||||
|
DeleteBulkAction::make(),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Settings\Provinces\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\Settings\Provinces\ProvinceResource;
|
||||||
|
use Filament\Actions\CreateAction;
|
||||||
|
use Filament\Resources\Pages\ManageRecords;
|
||||||
|
|
||||||
|
class ManageProvinces extends ManageRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = ProvinceResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
CreateAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Settings\Provinces;
|
||||||
|
|
||||||
|
use App\Filament\Clusters\Settings\Provinces\Pages\ManageProvinces;
|
||||||
|
use App\Filament\Clusters\Settings\Provinces\Schemas\ProvinceForm;
|
||||||
|
use App\Filament\Clusters\Settings\Provinces\Tables\ProvincesTable;
|
||||||
|
use App\Filament\Clusters\Settings\SettingsCluster;
|
||||||
|
use App\Modules\Province\Models\Province;
|
||||||
|
use BackedEnum;
|
||||||
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
use Filament\Support\Icons\Heroicon;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
|
||||||
|
class ProvinceResource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?string $model = Province::class;
|
||||||
|
|
||||||
|
protected static ?string $cluster = SettingsCluster::class;
|
||||||
|
|
||||||
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedMapPin;
|
||||||
|
|
||||||
|
protected static ?string $recordTitleAttribute = 'name';
|
||||||
|
|
||||||
|
public static function getNavigationGroup(): ?string
|
||||||
|
{
|
||||||
|
return __('Branches and provinces');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getModelLabel(): string
|
||||||
|
{
|
||||||
|
return __('module.province::base.Province');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPluralModelLabel(): string
|
||||||
|
{
|
||||||
|
return __('module.province::base.Provinces');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function form(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return ProvinceForm::configure($schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return ProvincesTable::configure($table);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => ManageProvinces::route('/'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Settings\Provinces\Schemas;
|
||||||
|
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Forms\Components\Toggle;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
|
||||||
|
class ProvinceForm
|
||||||
|
{
|
||||||
|
public static function configure(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema
|
||||||
|
->components([
|
||||||
|
Select::make('region')
|
||||||
|
->label(__('Region'))
|
||||||
|
->options(fn () => regions())
|
||||||
|
->required()
|
||||||
|
->native(false)
|
||||||
|
->searchable(),
|
||||||
|
|
||||||
|
TextInput::make('name')
|
||||||
|
->label(__('Name'))
|
||||||
|
->required()
|
||||||
|
->maxLength(255)
|
||||||
|
->translatableTabs(),
|
||||||
|
|
||||||
|
Toggle::make('active')
|
||||||
|
->label(__('Active'))
|
||||||
|
->default(true)
|
||||||
|
->required(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Settings\Provinces\Tables;
|
||||||
|
|
||||||
|
use App\Modules\Region\Repositories\RegionRepository;
|
||||||
|
use Filament\Actions\BulkActionGroup;
|
||||||
|
use Filament\Actions\DeleteBulkAction;
|
||||||
|
use Filament\Actions\EditAction;
|
||||||
|
use Filament\Tables\Columns\IconColumn;
|
||||||
|
use Filament\Tables\Columns\TextColumn;
|
||||||
|
use Filament\Tables\Filters\SelectFilter;
|
||||||
|
use Filament\Tables\Filters\TernaryFilter;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
|
||||||
|
class ProvincesTable
|
||||||
|
{
|
||||||
|
public static function configure(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->columns([
|
||||||
|
TextColumn::make('name')
|
||||||
|
->label(__('Name'))
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
|
||||||
|
TextColumn::make('region')
|
||||||
|
->label(__('Region'))
|
||||||
|
->formatStateUsing(fn (string $state): string => RegionRepository::label($state))
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
|
||||||
|
IconColumn::make('active')
|
||||||
|
->label(__('Active'))
|
||||||
|
->boolean()
|
||||||
|
->sortable(),
|
||||||
|
|
||||||
|
TextColumn::make('created_at')
|
||||||
|
->label(__('Created At'))
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
|
||||||
|
TextColumn::make('updated_at')
|
||||||
|
->label(__('Updated At'))
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
])
|
||||||
|
->filters([
|
||||||
|
SelectFilter::make('region')
|
||||||
|
->label(__('Region'))
|
||||||
|
->options(fn () => regions())
|
||||||
|
->native(false),
|
||||||
|
|
||||||
|
TernaryFilter::make('active')
|
||||||
|
->label(__('Active'))
|
||||||
|
->boolean()
|
||||||
|
->trueLabel(__('Active only'))
|
||||||
|
->falseLabel(__('Inactive only'))
|
||||||
|
->native(false),
|
||||||
|
])
|
||||||
|
->recordActions([
|
||||||
|
EditAction::make(),
|
||||||
|
])
|
||||||
|
->toolbarActions([
|
||||||
|
BulkActionGroup::make([
|
||||||
|
DeleteBulkAction::make(),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
20
app/Filament/Clusters/Settings/SettingsCluster.php
Normal file
20
app/Filament/Clusters/Settings/SettingsCluster.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Clusters\Settings;
|
||||||
|
|
||||||
|
use BackedEnum;
|
||||||
|
use Filament\Clusters\Cluster;
|
||||||
|
use Filament\Pages\Enums\SubNavigationPosition;
|
||||||
|
use Filament\Support\Icons\Heroicon;
|
||||||
|
|
||||||
|
class SettingsCluster extends Cluster
|
||||||
|
{
|
||||||
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedCog8Tooth;
|
||||||
|
|
||||||
|
protected static ?SubNavigationPosition $subNavigationPosition = SubNavigationPosition::End;
|
||||||
|
|
||||||
|
public static function getNavigationLabel(): string
|
||||||
|
{
|
||||||
|
return __('Settings');
|
||||||
|
}
|
||||||
|
}
|
||||||
34
app/Filament/Pages/Auth/EditProfile.php
Normal file
34
app/Filament/Pages/Auth/EditProfile.php
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Pages\Auth;
|
||||||
|
|
||||||
|
use Filament\Auth\Pages\EditProfile as BaseEditProfile;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Schemas\Components\Section;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
|
||||||
|
class EditProfile extends BaseEditProfile
|
||||||
|
{
|
||||||
|
public function form(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema
|
||||||
|
->components([
|
||||||
|
Section::make('Profile Information')
|
||||||
|
->description('Update your account\'s profile information and email address.')
|
||||||
|
->components([
|
||||||
|
TextInput::make('name')
|
||||||
|
->label('Name')
|
||||||
|
->required()
|
||||||
|
->maxLength(255)
|
||||||
|
->placeholder('Enter your full name'),
|
||||||
|
$this->getEmailFormComponent(),
|
||||||
|
]),
|
||||||
|
Section::make('Update Password')
|
||||||
|
->description('Ensure your account is using a long, random password to stay secure.')
|
||||||
|
->components([
|
||||||
|
$this->getPasswordFormComponent(),
|
||||||
|
$this->getPasswordConfirmationFormComponent(),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
60
app/Helpers/helpers.php
Normal file
60
app/Helpers/helpers.php
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Contracts\Cache\Repository as CacheRepository;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filament path
|
||||||
|
*
|
||||||
|
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
|
||||||
|
*/
|
||||||
|
function filament_path(): string
|
||||||
|
{
|
||||||
|
$path = config()->string('app.filament_path');
|
||||||
|
|
||||||
|
abort_if(! $path, 500, 'Filament path missing');
|
||||||
|
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Temprory cache for single request
|
||||||
|
*
|
||||||
|
* @return ($key is '' ? CacheRepository : mixed)
|
||||||
|
*/
|
||||||
|
function temp_cache(string $key = ''): mixed
|
||||||
|
{
|
||||||
|
$tempCache = cache()->driver('array');
|
||||||
|
|
||||||
|
return ($key === '') ? $tempCache : $tempCache->get($key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log
|
||||||
|
*/
|
||||||
|
function logDB(): void
|
||||||
|
{
|
||||||
|
if (! app()->isLocal()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::listen(function ($query) {
|
||||||
|
Log::info($query->sql, $query->bindings, $query->time);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User
|
||||||
|
*/
|
||||||
|
function user(): User
|
||||||
|
{
|
||||||
|
abort_unless(Auth::check(), 'not-authenticated');
|
||||||
|
|
||||||
|
/** @var \App\Models\User */
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
12
app/Http/Controllers/Controller.php
Normal file
12
app/Http/Controllers/Controller.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||||
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||||
|
use Illuminate\Routing\Controller as BaseController;
|
||||||
|
|
||||||
|
abstract class Controller extends BaseController
|
||||||
|
{
|
||||||
|
use AuthorizesRequests, ValidatesRequests;
|
||||||
|
}
|
||||||
58
app/Http/Middleware/EnsureProfileIsFilled.php
Normal file
58
app/Http/Middleware/EnsureProfileIsFilled.php
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Joaopaulolndev\FilamentEditProfile\Pages\EditProfilePage;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class EnsureProfileIsFilled
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next): Response
|
||||||
|
{
|
||||||
|
/** @var \App\Models\User */
|
||||||
|
$user = $request->user();
|
||||||
|
|
||||||
|
// 1. If user is not logged in, or profile is already complete, do nothing.
|
||||||
|
// (Based on your logic: must_fill_profile == true means complete)
|
||||||
|
if (! $user->must_fill_profile) {
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Define the 'safe' routes
|
||||||
|
$profilePageClass = EditProfilePage::class; // <-- !! IMPORTANT: Change to your page
|
||||||
|
$profilePageUrl = $profilePageClass::getUrl();
|
||||||
|
|
||||||
|
$panelId = filament()->getCurrentPanel()->getId();
|
||||||
|
$logoutRouteName = "filament.{$panelId}.auth.logout";
|
||||||
|
|
||||||
|
// 4. Check for 'safe' conditions
|
||||||
|
|
||||||
|
// Are they ALREADY on the profile page?
|
||||||
|
// We check the full URL to be precise.
|
||||||
|
$isProfilePage = $request->fullUrlIs($profilePageUrl);
|
||||||
|
|
||||||
|
// Are they trying to log out?
|
||||||
|
$isLoggingOut = $request->routeIs($logoutRouteName);
|
||||||
|
|
||||||
|
// Is this an internal Livewire request?
|
||||||
|
// This is the KEY to fixing the SPA redirect loop.
|
||||||
|
$isLivewireRequest = $request->is('livewire/*');
|
||||||
|
|
||||||
|
// 5. If they are on a safe route, let them proceed.
|
||||||
|
if ($isProfilePage || $isLoggingOut || $isLivewireRequest) {
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6. If not, redirect them to the profile page.
|
||||||
|
// Filament's SPA mode will intercept this 302 redirect
|
||||||
|
// and navigate without a full page reload.
|
||||||
|
return redirect($profilePageUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
197
app/Livewire/UserPassportFields.php
Normal file
197
app/Livewire/UserPassportFields.php
Normal file
@@ -0,0 +1,197 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use App\Modules\PhoneNumberVerification\Rules\PhoneNumberVerificationRule;
|
||||||
|
use App\Modules\TurkmenPassport\Repositories\TurkmenPassportRepository;
|
||||||
|
use Filament\Forms\Components\DatePicker;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Forms\Concerns\InteractsWithForms;
|
||||||
|
use Filament\Forms\Contracts\HasForms;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
|
use Filament\Schemas\Components\Fieldset;
|
||||||
|
use Filament\Schemas\Components\Section;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
use Filament\Support\Exceptions\Halt;
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
|
use Joaopaulolndev\FilamentEditProfile\Concerns\HasSort;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class UserPassportFields extends Component implements HasForms
|
||||||
|
{
|
||||||
|
use HasSort;
|
||||||
|
use InteractsWithForms;
|
||||||
|
|
||||||
|
public ?array $data = [];
|
||||||
|
|
||||||
|
protected static int $sort = 10;
|
||||||
|
|
||||||
|
public function mount(): void
|
||||||
|
{
|
||||||
|
$this->form->fill();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function form(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema
|
||||||
|
->components([
|
||||||
|
Section::make(__('Profile Information'))
|
||||||
|
->aside()
|
||||||
|
->columns(6)
|
||||||
|
->description(__('Fill your account profile information'))
|
||||||
|
->schema([
|
||||||
|
TextInput::make('first_name')
|
||||||
|
->label(__('First name'))
|
||||||
|
->string()
|
||||||
|
->maxLength(255)
|
||||||
|
->default(user()->first_name)
|
||||||
|
->columnSpan(2)
|
||||||
|
->required(),
|
||||||
|
|
||||||
|
TextInput::make('last_name')
|
||||||
|
->label(__('Last name'))
|
||||||
|
->string()
|
||||||
|
->maxLength(255)
|
||||||
|
->default(user()->last_name)
|
||||||
|
->columnSpan(2)
|
||||||
|
->required(),
|
||||||
|
|
||||||
|
TextInput::make('patronic_name')
|
||||||
|
->label(__('Patronic name'))
|
||||||
|
->columnSpan(2)
|
||||||
|
->default(user()->getOption('patronic_name'))
|
||||||
|
->maxLength(255),
|
||||||
|
|
||||||
|
DatePicker::make('born_at')
|
||||||
|
->displayFormat('d.m.Y')
|
||||||
|
->label(__('Birth date'))
|
||||||
|
->native(false)
|
||||||
|
->default(user()->getOption('born_at'))
|
||||||
|
->columnSpan(2)
|
||||||
|
->required()
|
||||||
|
->beforeOrEqual('today'),
|
||||||
|
|
||||||
|
TextInput::make('phone')
|
||||||
|
->label(__('Phone'))
|
||||||
|
->mask('99 99 99 99')
|
||||||
|
->prefix('+993')
|
||||||
|
->rules([
|
||||||
|
new PhoneNumberVerificationRule,
|
||||||
|
])
|
||||||
|
->unique(ignoreRecord: false)
|
||||||
|
->default(user()->phone)
|
||||||
|
->columnSpan(2)
|
||||||
|
->required(),
|
||||||
|
|
||||||
|
TextInput::make('email')
|
||||||
|
->label(__('Email'))
|
||||||
|
->email()
|
||||||
|
->default(user()->email)
|
||||||
|
->columnSpan(2),
|
||||||
|
|
||||||
|
Fieldset::make(__('Passport'))
|
||||||
|
->columns([
|
||||||
|
'default' => 1,
|
||||||
|
'md' => 6,
|
||||||
|
'xl' => 6,
|
||||||
|
])
|
||||||
|
->columnSpan(6)
|
||||||
|
->schema([
|
||||||
|
Select::make('passport_serie')
|
||||||
|
->label(__('Passport serie'))
|
||||||
|
->options(TurkmenPassportRepository::values())
|
||||||
|
->native(false)
|
||||||
|
->default(user()->getOption('passport_serie'))
|
||||||
|
->required()
|
||||||
|
->columnSpan(2),
|
||||||
|
|
||||||
|
TextInput::make('passport_id')
|
||||||
|
->label(__('Passport number'))
|
||||||
|
->default(user()->getOption('passport_id'))
|
||||||
|
->required()
|
||||||
|
->columnSpan(2)
|
||||||
|
->mask('999999'),
|
||||||
|
|
||||||
|
DatePicker::make('passport_given_at')
|
||||||
|
->label(__('Passport given date'))
|
||||||
|
->columnSpan(2)
|
||||||
|
->displayFormat('d.m.Y')
|
||||||
|
->native(false)
|
||||||
|
->closeOnDateSelection()
|
||||||
|
->beforeOrEqual('today')
|
||||||
|
->default(user()->getOption('passport_given_at'))
|
||||||
|
->required(),
|
||||||
|
|
||||||
|
TextInput::make('born_place')
|
||||||
|
->columnSpan(3)
|
||||||
|
->label(__('Born place (passport)'))
|
||||||
|
->maxLength(255)
|
||||||
|
->default(user()->getOption('born_place'))
|
||||||
|
->required(),
|
||||||
|
|
||||||
|
TextInput::make('passport_given_by')
|
||||||
|
->label(__('Passport given by'))
|
||||||
|
->columnSpan(3)
|
||||||
|
->maxLength(255)
|
||||||
|
->default(user()->getOption('passport_given_by'))
|
||||||
|
->required(),
|
||||||
|
|
||||||
|
TextInput::make('passport_address')
|
||||||
|
->columnSpan(3)
|
||||||
|
->label(__('Proscription for home'))
|
||||||
|
->maxLength(255)
|
||||||
|
->default(user()->getOption('passport_address'))
|
||||||
|
->required(),
|
||||||
|
|
||||||
|
TextInput::make('real_address')
|
||||||
|
->label(__('Current home address'))
|
||||||
|
->columnSpan(3)
|
||||||
|
->maxLength(255)
|
||||||
|
->default(user()->getOption('real_address'))
|
||||||
|
->required(),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
])
|
||||||
|
->statePath('data');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function save(): void
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
/** @var array{first_name: string, last_name: string, patronic_name: null|string, born_at: string, phone: string, email: string, passport_serie: string, passport_id: string, passport_given_at: string, born_place: string, passport_given_by: string, passport_address: string, real_address: string} */
|
||||||
|
$data = $this->form->getState();
|
||||||
|
|
||||||
|
user()->update([
|
||||||
|
'first_name' => $data['first_name'],
|
||||||
|
'last_name' => $data['last_name'],
|
||||||
|
'phone' => $data['phone'],
|
||||||
|
'email' => $data['email'],
|
||||||
|
'options->patronic_name' => $data['patronic_name'],
|
||||||
|
'options->born_at' => $data['born_at'],
|
||||||
|
'options->passport_serie' => $data['passport_serie'],
|
||||||
|
'options->passport_id' => $data['passport_id'],
|
||||||
|
'options->passport_given_at' => $data['passport_given_at'],
|
||||||
|
'options->born_place' => $data['born_place'],
|
||||||
|
'options->passport_given_by' => $data['passport_given_by'],
|
||||||
|
'options->passport_address' => $data['passport_address'],
|
||||||
|
'options->real_address' => $data['real_address'],
|
||||||
|
'must_fill_profile' => false,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->dispatch('refresh-topbar');
|
||||||
|
} catch (Halt $exception) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Notification::make()
|
||||||
|
->success()
|
||||||
|
->title(__('Profile updated'))
|
||||||
|
->send();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render(): View
|
||||||
|
{
|
||||||
|
return view('livewire.user-passport-fields');
|
||||||
|
}
|
||||||
|
}
|
||||||
51
app/Models/User.php
Normal file
51
app/Models/User.php
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Modules\UserAdjustments\Traits\UserAdjustments;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
use Illuminate\Support\Facades\Date;
|
||||||
|
use Spatie\Permission\Traits\HasRoles;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property int $id
|
||||||
|
* @property string $name
|
||||||
|
* @property null|string $email [unique]
|
||||||
|
* @property Date|null $email_verified_at
|
||||||
|
* @property string $password [hidden]
|
||||||
|
* @property string|null $remember_token
|
||||||
|
* @property Date|null $created_at
|
||||||
|
* @property Date|null $updated_at
|
||||||
|
*/
|
||||||
|
class User extends Authenticatable
|
||||||
|
{
|
||||||
|
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
use HasRoles;
|
||||||
|
use Notifiable;
|
||||||
|
use UserAdjustments;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that are mass assignable.
|
||||||
|
*
|
||||||
|
* @var list<string>
|
||||||
|
*/
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
'email',
|
||||||
|
'password',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The attributes that should be hidden for serialization.
|
||||||
|
*
|
||||||
|
* @var list<string>
|
||||||
|
*/
|
||||||
|
protected $hidden = [
|
||||||
|
'password',
|
||||||
|
'remember_token',
|
||||||
|
];
|
||||||
|
}
|
||||||
64
app/Modules/AppHelpers/AppHelpersModule.php
Normal file
64
app/Modules/AppHelpers/AppHelpersModule.php
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\AppHelpers;
|
||||||
|
|
||||||
|
use App\Modules\Makeable;
|
||||||
|
use App\Modules\ModuleContract;
|
||||||
|
|
||||||
|
class AppHelpersModule 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 [];
|
||||||
|
}
|
||||||
|
}
|
||||||
67
app/Modules/AppHelpers/Repositories/CacheRepository.php
Normal file
67
app/Modules/AppHelpers/Repositories/CacheRepository.php
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\AppHelpers\Repositories;
|
||||||
|
|
||||||
|
class CacheRepository
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Cache name
|
||||||
|
*/
|
||||||
|
protected string $name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Value
|
||||||
|
*/
|
||||||
|
protected mixed $value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Time
|
||||||
|
*/
|
||||||
|
protected int $time;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cache repo
|
||||||
|
*/
|
||||||
|
public function __construct(string $name, mixed $value, int $time = 600)
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
$this->value = $value;
|
||||||
|
$this->time = $time;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cache Repo
|
||||||
|
*
|
||||||
|
* @param string $name key
|
||||||
|
* @param mixed $value value
|
||||||
|
* @param int|int $time time in seconds
|
||||||
|
*/
|
||||||
|
public static function make(string $name, mixed $value, int $time = 600): mixed
|
||||||
|
{
|
||||||
|
$repo = new self($name, $value, $time);
|
||||||
|
|
||||||
|
return $repo->handle();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle cache
|
||||||
|
*/
|
||||||
|
public function handle(): mixed
|
||||||
|
{
|
||||||
|
return cache()->has($this->name)
|
||||||
|
? cache($this->name)
|
||||||
|
: cache()->remember(
|
||||||
|
key: $this->name,
|
||||||
|
ttl: $this->time,
|
||||||
|
callback: fn () => is_callable($this->value) ? call_user_func($this->value) : $this->value
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forget the key from cache
|
||||||
|
*/
|
||||||
|
public static function forget(string $name): void
|
||||||
|
{
|
||||||
|
cache()->forget($name);
|
||||||
|
}
|
||||||
|
}
|
||||||
78
app/Modules/BaseAuth/BaseAuthModule.php
Normal file
78
app/Modules/BaseAuth/BaseAuthModule.php
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\BaseAuth;
|
||||||
|
|
||||||
|
use App\Modules\Core\ModulePackage;
|
||||||
|
use App\Modules\Core\ModulePackageType;
|
||||||
|
use App\Modules\Makeable;
|
||||||
|
use App\Modules\ModuleContract;
|
||||||
|
|
||||||
|
class BaseAuthModule 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 [
|
||||||
|
new ModulePackage(
|
||||||
|
type: ModulePackageType::PACKAGE,
|
||||||
|
name: 'laravel/ui',
|
||||||
|
message: 'Required for authentication scaffolding.',
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get module composer suggestions
|
||||||
|
*/
|
||||||
|
public function getComposerSuggestions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
new ModulePackage(
|
||||||
|
type: ModulePackageType::MODULE,
|
||||||
|
name: 'BaseLocale',
|
||||||
|
message: 'Good for multiple language support.',
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
22
app/Modules/BaseAuth/Configs/base-auth-config.php
Normal file
22
app/Modules/BaseAuth/Configs/base-auth-config.php
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
// Redirect path after login, register, reset password, etc.
|
||||||
|
'redirect_path' => filament_path(),
|
||||||
|
|
||||||
|
// Default username, send from request and for validation, also db column
|
||||||
|
'default_username' => 'username',
|
||||||
|
|
||||||
|
// If multiple usernames are supported for login, will be searched by user columns
|
||||||
|
'multiple_usernames' => true,
|
||||||
|
'usernames' => [
|
||||||
|
'username',
|
||||||
|
'phone',
|
||||||
|
],
|
||||||
|
|
||||||
|
// If auth events should be stored
|
||||||
|
'store_auth_events' => true,
|
||||||
|
|
||||||
|
// If sms verification is enabled, will be sent to the user
|
||||||
|
'sms_verification' => true,
|
||||||
|
];
|
||||||
184
app/Modules/BaseAuth/Controllers/LoginController.php
Normal file
184
app/Modules/BaseAuth/Controllers/LoginController.php
Normal file
@@ -0,0 +1,184 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\BaseAuth\Controllers;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Modules\BaseLocale\Middleware\SetLocale;
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
|
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||||
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\Response;
|
||||||
|
use Illuminate\Routing\Controller;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
|
||||||
|
class LoginController extends Controller
|
||||||
|
{
|
||||||
|
use AuthenticatesUsers, ValidatesRequests;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Middleware
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$middleware = [];
|
||||||
|
|
||||||
|
if (module('BaseLocale')->isEnabled()) {
|
||||||
|
array_push($middleware, SetLocale::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->middleware($middleware)->except('logout');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the login username to be used by the controller, also send via request.
|
||||||
|
*/
|
||||||
|
public function username(): string
|
||||||
|
{
|
||||||
|
return config()->string('module.base-auth.default_username');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Supports multiple usernames
|
||||||
|
*/
|
||||||
|
public function supportsMultipleUsernames(): bool
|
||||||
|
{
|
||||||
|
return config()->boolean('module.base-auth.multiple_usernames');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Supports multiple usernames
|
||||||
|
*
|
||||||
|
* @return array<int, string>
|
||||||
|
*/
|
||||||
|
public function usernames(): array
|
||||||
|
{
|
||||||
|
/** @var array<int, string> */
|
||||||
|
$usernames = config()->array('module.base-auth.usernames');
|
||||||
|
|
||||||
|
return $usernames;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the application's login form.
|
||||||
|
*/
|
||||||
|
public function showLoginForm(): View
|
||||||
|
{
|
||||||
|
return view('module.base-auth::pages.login');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The user has been authenticated.
|
||||||
|
*/
|
||||||
|
protected function authenticated(Request $request, User $user): JsonResponse|RedirectResponse
|
||||||
|
{
|
||||||
|
$redirect = redirect()->intended($this->redirectPath());
|
||||||
|
|
||||||
|
return $request->wantsJson()
|
||||||
|
? new JsonResponse([
|
||||||
|
'redirect' => $redirect->getTargetUrl(),
|
||||||
|
], 200)
|
||||||
|
: $redirect;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log the user out of the application.
|
||||||
|
*/
|
||||||
|
public function logout(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
$this->guard()->logout();
|
||||||
|
|
||||||
|
$request->session()->invalidate();
|
||||||
|
|
||||||
|
return redirect()->intended($this->redirectPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the post register / login redirect path.
|
||||||
|
*/
|
||||||
|
public function redirectPath(): string
|
||||||
|
{
|
||||||
|
return config()->string('module.base-auth.redirect_path');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate the user login request.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @throws \Illuminate\Validation\ValidationException
|
||||||
|
*/
|
||||||
|
protected function validateLogin(Request $request): void
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
$this->username() => ['required', 'string', 'max:250'],
|
||||||
|
'password' => ['required', 'string', 'max:250'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle a login request to the application.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\Response|\Illuminate\Http\JsonResponse|\Symfony\Component\HttpFoundation\Response
|
||||||
|
*
|
||||||
|
* @throws \Illuminate\Validation\ValidationException
|
||||||
|
*/
|
||||||
|
public function login(Request $request)
|
||||||
|
{
|
||||||
|
$this->validateLogin($request);
|
||||||
|
|
||||||
|
// If the class is using the ThrottlesLogins trait, we can automatically throttle
|
||||||
|
// the login attempts for this application. We'll key this by the username and
|
||||||
|
// the IP address of the client making these requests into this application.
|
||||||
|
if (method_exists($this, 'hasTooManyLoginAttempts') && $this->hasTooManyLoginAttempts($request)) {
|
||||||
|
$this->fireLockoutEvent($request);
|
||||||
|
|
||||||
|
return $this->sendLockoutResponse($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = User::query()
|
||||||
|
->when($this->supportsMultipleUsernames(), function ($query) use ($request) {
|
||||||
|
foreach ($this->usernames() as $username) {
|
||||||
|
$query->orWhere($username, $request->username);
|
||||||
|
}
|
||||||
|
}, function ($query) use ($request) {
|
||||||
|
$query->where($this->username(), $request->username);
|
||||||
|
})
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (! $user) {
|
||||||
|
return $this->sendFailedLoginResponse($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Hash::check($request->string('password'), $user->password)) {
|
||||||
|
Auth::login($user);
|
||||||
|
|
||||||
|
if ($request->hasSession()) {
|
||||||
|
$request->session()->put('auth.password_confirmed_at', time());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->sendLoginResponse($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the login attempt was unsuccessful we will increment the number of attempts
|
||||||
|
// to login and redirect the user back to the login form. Of course, when this
|
||||||
|
// user surpasses their maximum number of attempts they will get locked out.
|
||||||
|
$this->incrementLoginAttempts($request);
|
||||||
|
|
||||||
|
return $this->sendFailedLoginResponse($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send the response after the user was authenticated.
|
||||||
|
*/
|
||||||
|
protected function sendLoginResponse(Request $request): RedirectResponse|JsonResponse
|
||||||
|
{
|
||||||
|
$request->session()->regenerate();
|
||||||
|
|
||||||
|
$this->clearLoginAttempts($request);
|
||||||
|
|
||||||
|
return $this->authenticated($request, $this->guard()->user()); // @phpstan-ignore-line
|
||||||
|
}
|
||||||
|
}
|
||||||
173
app/Modules/BaseAuth/Controllers/RegisterController.php
Normal file
173
app/Modules/BaseAuth/Controllers/RegisterController.php
Normal file
@@ -0,0 +1,173 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\BaseAuth\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\System\Verification;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Modules\BaseAuth\Models\AuthEvent;
|
||||||
|
use App\Modules\BaseLocale\Middleware\SetLocale;
|
||||||
|
use App\Modules\OtpVerification\Rules\OtpVerificationRule;
|
||||||
|
use App\Modules\PhoneNumberVerification\Rules\PhoneNumberVerificationRule;
|
||||||
|
use Illuminate\Auth\Events\Registered;
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
|
||||||
|
class RegisterController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Middleware
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$middleware = [];
|
||||||
|
|
||||||
|
if (module('BaseLocale')->isEnabled()) {
|
||||||
|
array_push($middleware, SetLocale::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->middleware($middleware)->except('logout');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show registration page
|
||||||
|
*/
|
||||||
|
public function showNovaRegisterpageForm(): View
|
||||||
|
{
|
||||||
|
return view('module.base-auth::pages.register');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle a registration request for the application.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
|
||||||
|
*/
|
||||||
|
public function register(Request $request)
|
||||||
|
{
|
||||||
|
if ($request->has('phone')) {
|
||||||
|
$request->merge([
|
||||||
|
'phone' => unMaskTurkmenNumber($request->string('phone')),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->validator($request->all())->validate();
|
||||||
|
|
||||||
|
event(new Registered($user = $this->create($request->all())));
|
||||||
|
|
||||||
|
Auth::guard()->login($user);
|
||||||
|
|
||||||
|
if (config('module.base-auth.store_auth_events')) {
|
||||||
|
storeAuthEvent(AuthEvent::REGISTER, $request);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config('module.base-auth.sms_verification')) {
|
||||||
|
sendSMSVerification((string) $user->phone);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'url' => route('sms-verification'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'url' => config('module.base-auth.redirect_path'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a validator for an incoming registration request.
|
||||||
|
*
|
||||||
|
* @param array<string, int|string> $data
|
||||||
|
* @return \Illuminate\Contracts\Validation\Validator
|
||||||
|
*/
|
||||||
|
protected function validator(array $data)
|
||||||
|
{
|
||||||
|
return Validator::make($data, [
|
||||||
|
'name' => ['required', 'string', 'max:255'],
|
||||||
|
'phone' => ['required', new PhoneNumberVerificationRule, 'unique:users,phone'],
|
||||||
|
'username' => ['required', 'string', 'alpha_dash:ascii', 'max:255', 'unique:users,username'],
|
||||||
|
'password' => ['required', 'string', 'min:8', 'confirmed'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new user instance after a valid registration.
|
||||||
|
*
|
||||||
|
* @param array<string, int|string> $data
|
||||||
|
* @return \App\Models\User
|
||||||
|
*/
|
||||||
|
protected function create(array $data)
|
||||||
|
{
|
||||||
|
$user = User::create([
|
||||||
|
'name' => $data['name'],
|
||||||
|
'phone' => $data['phone'],
|
||||||
|
'username' => $data['username'],
|
||||||
|
'password' => Hash::make((string) $data['password']),
|
||||||
|
'must_fill_profile' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sms verification
|
||||||
|
*/
|
||||||
|
public function smsVerification(): View
|
||||||
|
{
|
||||||
|
return view('module.base-auth::pages.sms-verification', ['phone' => Auth::user()?->phone]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change users phone number
|
||||||
|
*/
|
||||||
|
public function changePhone(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
if ($request->has('phone')) {
|
||||||
|
$request->merge(['phone' => unMaskTurkmenNumber($request->string('phone'))]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$request->validate([
|
||||||
|
'phone' => ['required', new PhoneNumberVerificationRule, 'unique:users,phone'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
/** @var User */
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
|
$user->update([
|
||||||
|
'phone' => $request->phone,
|
||||||
|
]);
|
||||||
|
|
||||||
|
storeAuthEvent(AuthEvent::PHONE_CHANGED, $request);
|
||||||
|
|
||||||
|
sendSMSVerification((string) $user->phone);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'url' => route('sms-verification'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify sms code
|
||||||
|
*/
|
||||||
|
public function verifySmsCode(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
/** @var User */
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
|
$request->validate([
|
||||||
|
'code' => ['bail', 'required', 'integer', new OtpVerificationRule($user->phone)],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user->update([
|
||||||
|
'phone_verified_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
storeAuthEvent(AuthEvent::PHONE_VERIFICATION, $request);
|
||||||
|
|
||||||
|
return redirect(config()->string('module.base-auth.redirect_path'));
|
||||||
|
}
|
||||||
|
}
|
||||||
110
app/Modules/BaseAuth/Controllers/ResetPasswordController.php
Normal file
110
app/Modules/BaseAuth/Controllers/ResetPasswordController.php
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\BaseAuth\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\System\Verification;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Modules\BaseAuth\Models\AuthEvent;
|
||||||
|
use App\Modules\OtpVerification\Models\OtpVerification;
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
class ResetPasswordController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Reset password page
|
||||||
|
*/
|
||||||
|
public function index(): View
|
||||||
|
{
|
||||||
|
return view('module.base-auth::pages.reset-password');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store new password
|
||||||
|
*/
|
||||||
|
public function store(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'username' => ['required', 'string', 'max:250', 'exists:users,username'],
|
||||||
|
'verification' => ['nullable', 'integer', Rule::requiredIf(fn () => $request->filled('step-verification'))],
|
||||||
|
'step-sms' => ['nullable'],
|
||||||
|
'step-verification' => ['nullable'],
|
||||||
|
'step-password' => ['nullable'],
|
||||||
|
'password' => ['bail', 'nullable', 'string', 'min:8', 'confirmed', Rule::requiredIf(fn () => $request->filled('step-password'))],
|
||||||
|
]);
|
||||||
|
|
||||||
|
/** @var User */
|
||||||
|
$user = User::where('username', $request->username)->first();
|
||||||
|
|
||||||
|
if ($request->filled('step-sms') && $request->isNotFilled('step-verification') && $request->isNotFilled('step-password')) {
|
||||||
|
return $this->sendVerification($request, $user);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->filled('step-verification') && $request->isNotFilled('step-password')) {
|
||||||
|
return $this->verify($request, $user);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->filled('step-password')) {
|
||||||
|
return $this->updatePassword($request, $user);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send verification code
|
||||||
|
*/
|
||||||
|
public function sendVerification(Request $request, User $user): JsonResponse
|
||||||
|
{
|
||||||
|
sendSMSVerification((string) $user->phone);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'step' => 1,
|
||||||
|
'message' => __('We send you a verification code to').' ****'.substr((string) $user->phone, 4),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify phone number
|
||||||
|
*/
|
||||||
|
public function verify(Request $request, User $user): JsonResponse
|
||||||
|
{
|
||||||
|
$verification = OtpVerification::where('username', $user->phone)
|
||||||
|
->where('code', $request->verification)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (! $verification) {
|
||||||
|
return response()->json([
|
||||||
|
'errors' => [
|
||||||
|
'verification' => [
|
||||||
|
__('Incorrect verification code'),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'message' => __('Incorrect verification code'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'step' => 2,
|
||||||
|
'message' => __("Now you can set your password, but please make sure that you don't forget it!"),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update password
|
||||||
|
*/
|
||||||
|
public function updatePassword(Request $request, User $user): JsonResponse
|
||||||
|
{
|
||||||
|
$user->update(['password' => bcrypt($request->string('password'))]);
|
||||||
|
|
||||||
|
storeAuthEvent(AuthEvent::PASSWORD_RESET, request());
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'step' => 3,
|
||||||
|
'message' => __('Your password has been updated'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?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('auth_events', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
|
||||||
|
$table->string('name')->index();
|
||||||
|
$table->string('request_method')->index();
|
||||||
|
$table->string('ip')->nullable()->index();
|
||||||
|
$table->string('user_agent')->nullable()->index();
|
||||||
|
$table->string('target_url')->nullable()->index();
|
||||||
|
$table->json('options')->nullable();
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('auth_events');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\BaseAuth\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class RedirectIfUserPhoneIsUnVerfied
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next): Response
|
||||||
|
{
|
||||||
|
if (Auth::check() && is_null($request->user()?->phone_verified_at)) {
|
||||||
|
return redirect()->route('sms-verification');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\BaseAuth\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class RedirectIfUserPhoneIsVerfied
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next): Response
|
||||||
|
{
|
||||||
|
if (Auth::check() && ! is_null($request->user()?->phone_verified_at)) {
|
||||||
|
return redirect()->route(config()->string('module.base-auth.redirect_path'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
111
app/Modules/BaseAuth/Models/AuthEvent.php
Normal file
111
app/Modules/BaseAuth/Models/AuthEvent.php
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\BaseAuth\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property int $id
|
||||||
|
* @property string $name
|
||||||
|
* @property string $request_method
|
||||||
|
* @property string|null $ip
|
||||||
|
* @property string|null $user_agent
|
||||||
|
* @property string|null $target_url
|
||||||
|
* @property string|null $options
|
||||||
|
* @property Carbon|null $created_at
|
||||||
|
* @property Carbon|null $updated_at
|
||||||
|
*/
|
||||||
|
class AuthEvent extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'auth_events';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When user registers to application
|
||||||
|
*/
|
||||||
|
public const REGISTER = 'REGISTER';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When user logs into application
|
||||||
|
*/
|
||||||
|
public const LOGIN = 'LOGIN';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When user verifies phone number
|
||||||
|
*/
|
||||||
|
public const PHONE_VERIFICATION = 'PHONE_VERIFICATION';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When user verifies phone number
|
||||||
|
*/
|
||||||
|
public const PHONE_CHANGED = 'PHONE_CHANGED';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When user logs out of application
|
||||||
|
*/
|
||||||
|
public const LOGOUT = 'LOGOUT';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When user resets password
|
||||||
|
*/
|
||||||
|
public const PASSWORD_RESET = 'PASSWORD_RESET';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When user resets password
|
||||||
|
*/
|
||||||
|
public const FAILED = 'FAILED';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When user resets password
|
||||||
|
*/
|
||||||
|
public const ATTEMPTING = 'ATTEMPTING';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When user resets password
|
||||||
|
*/
|
||||||
|
public const LOCKOUT = 'LOCKOUT';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Laravel's default events
|
||||||
|
*
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public static function laravelDefaultEvents(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'Illuminate\\Auth\\Events\\Attempting' => self::ATTEMPTING,
|
||||||
|
'Illuminate\\Auth\\Events\\Failed' => self::FAILED,
|
||||||
|
'Illuminate\\Auth\\Events\\Lockout' => self::LOCKOUT,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Guest the event
|
||||||
|
*/
|
||||||
|
public static function guessEvent(string|object $event): string
|
||||||
|
{
|
||||||
|
if (is_object($event)) {
|
||||||
|
$event = get_class($event);
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::laravelDefaultEvents()[$event] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log type
|
||||||
|
*/
|
||||||
|
public static function logType(string $name): string
|
||||||
|
{
|
||||||
|
return match ($name) {
|
||||||
|
self::REGISTER => 'notice',
|
||||||
|
self::LOGIN => 'notice',
|
||||||
|
self::PHONE_VERIFICATION => 'info',
|
||||||
|
self::LOGOUT => 'notice',
|
||||||
|
self::PASSWORD_RESET => 'info',
|
||||||
|
self::FAILED => 'warning',
|
||||||
|
self::ATTEMPTING => 'alert',
|
||||||
|
self::LOCKOUT => 'alert',
|
||||||
|
default => 'info',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
16
app/Modules/BaseAuth/Resources/Lang/en/base.php
Normal file
16
app/Modules/BaseAuth/Resources/Lang/en/base.php
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'online_panel' => 'Online panel',
|
||||||
|
'login' => 'Login',
|
||||||
|
'register' => 'Register',
|
||||||
|
'reset_password' => 'Reset password',
|
||||||
|
'help' => 'Help',
|
||||||
|
'privacy_policy' => 'Privacy policy',
|
||||||
|
'phone' => 'Phone',
|
||||||
|
'username' => 'Username',
|
||||||
|
'or' => 'or',
|
||||||
|
'continue' => 'Continue',
|
||||||
|
'successfully_logged_in' => 'Successfully logged in',
|
||||||
|
'press_continue' => 'Press continue',
|
||||||
|
];
|
||||||
5
app/Modules/BaseAuth/Resources/Lang/ru/base.php
Normal file
5
app/Modules/BaseAuth/Resources/Lang/ru/base.php
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
];
|
||||||
32
app/Modules/BaseAuth/Resources/Lang/tk/base.php
Normal file
32
app/Modules/BaseAuth/Resources/Lang/tk/base.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'online_panel' => 'Onlaýn kabulhana',
|
||||||
|
'login' => 'Giriş',
|
||||||
|
'register' => 'Agza bolmak',
|
||||||
|
'reset_password' => 'Açar sözüni ýatdan çykardyňyzmy?',
|
||||||
|
'help' => 'Kömek',
|
||||||
|
'privacy_policy' => 'Gizlinlik syýasaty',
|
||||||
|
'phone' => 'Telefon',
|
||||||
|
'username' => 'ulanyjy ady',
|
||||||
|
'password' => 'Açar sözi',
|
||||||
|
'or' => 'ýada',
|
||||||
|
'continue' => 'Dowam etmek',
|
||||||
|
'successfully_logged_in' => 'Üstünlik bilen girdiňiz',
|
||||||
|
'press_continue' => 'Dowam etmek düwme basyň',
|
||||||
|
'please_wait_while_we_redirect_you_to_your_personal_account' => 'Şahsy hasabyňyza geçýänçä garaşyň',
|
||||||
|
'forgot_your_password' => 'Açar sözüni unutdyňyzmy?',
|
||||||
|
'successfully_registered' => 'Üstünlikli hasaba alyndyňyz',
|
||||||
|
'please_now_verify_your_phone_number_to_continue' => 'Dowam etmek üçin telefon belgiňizi tassyklaň',
|
||||||
|
'go_to_login_page' => 'Giriş sahypasyyna geçiň',
|
||||||
|
'full_name' => 'Adyňyz',
|
||||||
|
'confirm_password' => 'Açar sözi tassyklaňyz',
|
||||||
|
'verify_phone_number' => 'Telefon beligiňizi tassyklaň',
|
||||||
|
'verification_code' => 'Tassyklaýyş belgi',
|
||||||
|
'submit' => 'Tassyklamak',
|
||||||
|
'verification_code_has_been_send_to_number' => 'Tassyklaýyş belgi telefon belgisine ugradyldy',
|
||||||
|
'change_number' => 'Üýtget',
|
||||||
|
'change_phone_label' => 'Telefon belgini üýtgetmek',
|
||||||
|
'go_back' => 'Yza',
|
||||||
|
'successfully_changed_phone' => 'Telefon belgiňiz üýtgedildi',
|
||||||
|
];
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="{{ app()->getLocale() }}" dir="ltr" class="h-full font-sans antialiased">
|
||||||
|
<head>
|
||||||
|
<meta name="theme-color" content="#fff">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width"/>
|
||||||
|
<meta name="locale" content="tk"/>
|
||||||
|
<meta name="robots" content="noindex">
|
||||||
|
|
||||||
|
<link rel="shortcut icon" href="/favicon.png" type="image/png">
|
||||||
|
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
||||||
|
<link rel="manifest" href="/site.webmanifest">
|
||||||
|
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
|
||||||
|
|
||||||
|
<!-- Styles -->
|
||||||
|
<link rel="stylesheet" href="/assets/css/auth-layout.css">
|
||||||
|
<link rel="stylesheet" href="/assets/css/auth.css">
|
||||||
|
<link rel="stylesheet" href="/assets/css/cookieconsent.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<div class="bg-white flex justify-between px-4 py-1 absolute w-full shadow-none shadow-lg">
|
||||||
|
<div class="px-8 text-sm p-1 rounded uppercase font-bold padding-none">
|
||||||
|
<a href="#" class="d-none-copyright"> “Türkmenbaşy” PTB © </a>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center">
|
||||||
|
<a href="tel:+99312444234" class="mr-6 text-sm text-gray-900">(+99312) 44-42-34</a>
|
||||||
|
<a href="#" class="mr-6 text-sm text-gray-900 uppercase">{{ __('module.base-auth::base.help') }}</a>
|
||||||
|
|
||||||
|
<div class="flex text-sm text-gray-90a0 space-x-1 uppercase">
|
||||||
|
@if (module('BaseLocale')->isEnabled())
|
||||||
|
@foreach(baseLocales() as $localeKey => $localeDisplayName)
|
||||||
|
<a
|
||||||
|
href="{{ route('module.base-locale.set-locale', ['locale' => $localeKey]) }}"
|
||||||
|
class="{{ app()->getLocale() === $localeKey ? 'font-bold' : '' }}"
|
||||||
|
>
|
||||||
|
{{ $localeKey }}
|
||||||
|
|
||||||
|
@unless($loop->last)
|
||||||
|
|
|
||||||
|
@endif
|
||||||
|
</a>
|
||||||
|
@endforeach
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="login-section d-center items-center h-screen">
|
||||||
|
<div class="d-none h-full max-w-4xl">
|
||||||
|
<img src="/assets/images/bank-img.PNG" class="h-full object-cover">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="relative">
|
||||||
|
@yield('content')
|
||||||
|
|
||||||
|
<div class="text-center relative" style="top: 4em;">
|
||||||
|
<a href="/privacy-policy.pdf" class="text-gray-500 font-bold text-underline" target="_blank">
|
||||||
|
{{ __('module.base-auth::base.privacy_policy') }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="/assets/js/inputmask.min.js"></script>
|
||||||
|
<script src="/assets/js/sweetalert2.js"></script>
|
||||||
|
|
||||||
|
<script src="/assets/js/cookieconsent.js"></script>
|
||||||
|
<script src="/assets/js/fn.js"></script>
|
||||||
|
<script src="/assets/js/app.js"></script>
|
||||||
|
|
||||||
|
@stack('js')
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
88
app/Modules/BaseAuth/Resources/Views/pages/login.blade.php
Normal file
88
app/Modules/BaseAuth/Resources/Views/pages/login.blade.php
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
@extends('module.base-auth::layouts.auth-layout')
|
||||||
|
|
||||||
|
@push('js')
|
||||||
|
<script>
|
||||||
|
async function login(event) {
|
||||||
|
const response = await postData(event.target.action, getFormData(event))
|
||||||
|
|
||||||
|
console.log(response)
|
||||||
|
|
||||||
|
if (response.errors) {
|
||||||
|
loopObject(response.errors, item => addValidationClasses(item))
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
removeValidationClasess()
|
||||||
|
|
||||||
|
await Swal.fire({
|
||||||
|
title: '{{ __('module.base-auth::base.successfully_logged_in') }}',
|
||||||
|
text: '{{ __('module.base-auth::base.press_continue') }}',
|
||||||
|
confirmButtonText: '{{ __('module.base-auth::base.continue') }}',
|
||||||
|
icon: 'success',
|
||||||
|
showDenyButton: false,
|
||||||
|
showCancelButton: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
window.location.href = '{{ route('login') }}'
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<form
|
||||||
|
method="POST"
|
||||||
|
action="{{ route('login') }}"
|
||||||
|
onsubmit="event.preventDefault();login(event)"
|
||||||
|
class="bg-white dark:bg-gray-800 rounded-lg p-8 w-[25rem] mx-auto"
|
||||||
|
>
|
||||||
|
@csrf
|
||||||
|
<h2 class="text-2xl text-center font-normal mb-6 uppercase">{{ __('module.base-auth::base.online_panel') }}</h2>
|
||||||
|
<svg class="block mx-auto mb-6" xmlns="http://www.w3.org/2000/svg" width="100" height="2" viewBox="0 0 100 2">
|
||||||
|
<path fill="#D8E3EC" d="M0 0h100v2H0z"></path>
|
||||||
|
</svg>
|
||||||
|
<div class="mb-6">
|
||||||
|
<label class="block mb-2" for="username">
|
||||||
|
{{ __('module.base-auth::base.phone') }} {{ __('module.base-auth::base.or') }} <span class="lowecase">{{ __('module.base-auth::base.username') }}</span>
|
||||||
|
</label>
|
||||||
|
<input class="form-control form-input form-input-bordered w-full"
|
||||||
|
id="username"
|
||||||
|
type="text"
|
||||||
|
name="username"
|
||||||
|
placeholder="+99365999990 {{ __('or') }} {{ __('module.base-auth::base.username') }}"
|
||||||
|
autofocus=""
|
||||||
|
value="{{ old('username') }}"
|
||||||
|
>
|
||||||
|
|
||||||
|
<span id="username-error-box" class="text-red-500 text-italic error-box"></span>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="mb-6">
|
||||||
|
<label class="block mb-2" for="password">
|
||||||
|
{{ __('module.base-auth::base.password') }}
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
class="form-control form-input form-input-bordered w-full"
|
||||||
|
id="password"
|
||||||
|
type="password"
|
||||||
|
name="password"
|
||||||
|
>
|
||||||
|
|
||||||
|
<span id="password-error-box" class="text-red-500 text-italic error-box"></span>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="flex mb-6">
|
||||||
|
<div class="ml-auto">
|
||||||
|
<a href="{{ route('reset-password') }}" class="text-gray-500 font-bold no-underline">
|
||||||
|
{{ __('module.base-auth::base.forgot_your_password') }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button class="w-full flex justify-center shadow relative bg-primary-500 hover:bg-primary-400 text-white dark:text-gray-900 w-full flex justify-center cursor-pointer rounded text-sm font-bold focus:outline-none focus:ring ring-primary-200 dark:ring-gray-600 inline-flex items-center justify-center h-9 px-3 mb-3 w-full flex justify-center shadow relative bg-primary-500 hover:bg-primary-400 text-white dark:text-gray-900 w-full flex justify-center" type="submit">
|
||||||
|
<span class=""><span>{{ __('module.base-auth::base.login') }}</span></span>
|
||||||
|
</button>
|
||||||
|
<a href="{{ route('register') }}" class="w-full flex justify-center shadow relative bg-primary-500 hover:bg-primary-400 text-white dark:text-gray-900 w-full flex justify-center cursor-pointer rounded text-sm font-bold focus:outline-none focus:ring ring-primary-200 dark:ring-gray-600 inline-flex items-center justify-center h-9 px-3 mb-3 w-full flex justify-center shadow relative bg-primary-500 hover:bg-primary-400 text-white dark:text-gray-900 w-full flex justify-center">
|
||||||
|
<span class=""><span>{{ __('module.base-auth::base.register') }}</span></span>
|
||||||
|
</a>
|
||||||
|
</form>
|
||||||
|
@stop
|
||||||
124
app/Modules/BaseAuth/Resources/Views/pages/register.blade.php
Normal file
124
app/Modules/BaseAuth/Resources/Views/pages/register.blade.php
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
@extends('module.base-auth::layouts.auth-layout')
|
||||||
|
|
||||||
|
@push('js')
|
||||||
|
<script>
|
||||||
|
async function register(event) {
|
||||||
|
const response = await postData(event.target.action, getFormData(event))
|
||||||
|
|
||||||
|
if (response.errors) {
|
||||||
|
loopObject(response.errors, item => addValidationClasses(item))
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
removeValidationClasess()
|
||||||
|
|
||||||
|
console.log(response)
|
||||||
|
|
||||||
|
await Swal.fire({
|
||||||
|
title: '{{ __('module.base-auth::base.successfully_registered') }}',
|
||||||
|
text: '{{ __('module.base-auth::base.please_now_verify_your_phone_number_to_continue') }}',
|
||||||
|
icon: 'success',
|
||||||
|
showDenyButton: false,
|
||||||
|
showCancelButton: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
window.location.href = response.url;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<form
|
||||||
|
class="bg-white dark:bg-gray-800 rounded-lg p-8 w-[25rem] mx-auto mt-1"
|
||||||
|
method="POST"
|
||||||
|
action="{{ route('register') }}"
|
||||||
|
onsubmit="event.preventDefault();register(event)"
|
||||||
|
>
|
||||||
|
@csrf
|
||||||
|
<h2 class="text-2xl text-center font-normal mb-6">{{ __('module.base-auth::base.online_panel') }}</h2>
|
||||||
|
<svg class="block mx-auto mb-6" xmlns="http://www.w3.org/2000/svg" width="100" height="2" viewBox="0 0 100 2">
|
||||||
|
<path fill="#D8E3EC" d="M0 0h100v2H0z"></path>
|
||||||
|
</svg>
|
||||||
|
<div class="mb-1">
|
||||||
|
<label class="block mb-1" for="name">
|
||||||
|
{{ __('module.base-auth::base.full_name') }}
|
||||||
|
</label>
|
||||||
|
<input class="form-control form-input form-input-bordered w-full"
|
||||||
|
id="name"
|
||||||
|
type="text"
|
||||||
|
name="name"
|
||||||
|
autofocus=""
|
||||||
|
value="{{ old('name') }}"
|
||||||
|
>
|
||||||
|
|
||||||
|
<span id="name-error-box" class="text-red-500 text-italic error-box"></span>
|
||||||
|
</div>
|
||||||
|
<div class="mb-1">
|
||||||
|
<label class="block mb-1" for="phone">
|
||||||
|
{{ __('module.base-auth::base.phone') }}
|
||||||
|
</label>
|
||||||
|
<input class="form-control form-input form-input-bordered w-full"
|
||||||
|
id="phone"
|
||||||
|
type="text"
|
||||||
|
name="phone"
|
||||||
|
autofocus=""
|
||||||
|
value="{{ old('phone') }}"
|
||||||
|
>
|
||||||
|
|
||||||
|
<span id="phone-error-box" class="text-red-500 text-italic error-box"></span>
|
||||||
|
</div>
|
||||||
|
<div class="mb-1">
|
||||||
|
<label class="block mb-1" for="username">
|
||||||
|
{{ ucfirst(__('module.base-auth::base.username')) }}
|
||||||
|
</label>
|
||||||
|
<input class="form-control form-input form-input-bordered w-full"
|
||||||
|
id="username"
|
||||||
|
type="text"
|
||||||
|
name="username"
|
||||||
|
autofocus=""
|
||||||
|
value="{{ old('username') }}"
|
||||||
|
>
|
||||||
|
|
||||||
|
<span id="username-error-box" class="text-red-500 text-italic error-box"></span>
|
||||||
|
</div>
|
||||||
|
<div class="mb-1">
|
||||||
|
<label class="block mb-1" for="password">
|
||||||
|
{{ __('module.base-auth::base.password') }}
|
||||||
|
</label>
|
||||||
|
<input class="form-control form-input form-input-bordered w-full"
|
||||||
|
id="password"
|
||||||
|
type="password"
|
||||||
|
name="password"
|
||||||
|
>
|
||||||
|
|
||||||
|
<span id="password-error-box" class="text-red-500 text-italic error-box"></span>
|
||||||
|
</div>
|
||||||
|
<div class="mb-1">
|
||||||
|
<label class="block mb-1" for="password_confirmation">
|
||||||
|
{{ __('module.base-auth::base.confirm_password') }}
|
||||||
|
</label>
|
||||||
|
<input class="form-control form-input form-input-bordered w-full"
|
||||||
|
id="password_confirmation"
|
||||||
|
type="password"
|
||||||
|
name="password_confirmation"
|
||||||
|
>
|
||||||
|
|
||||||
|
<span id="password_confirmation-error-box" class="text-red-500 text-italic error-box"></span>
|
||||||
|
</div>
|
||||||
|
<div class="mb-6"></div>
|
||||||
|
<button
|
||||||
|
class="w-full flex justify-center shadow relative bg-primary-500 hover:bg-primary-400 text-white dark:text-gray-900 w-full flex justify-center cursor-pointer rounded text-sm font-bold focus:outline-none focus:ring ring-primary-200 dark:ring-gray-600 inline-flex items-center justify-center h-9 px-3 mb-3 w-full flex justify-center shadow relative bg-primary-500 hover:bg-primary-400 text-white dark:text-gray-900 w-full flex justify-center"
|
||||||
|
type="submit"
|
||||||
|
>
|
||||||
|
<span class=""><span>{{ __('module.base-auth::base.register') }}</span></span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<a
|
||||||
|
href="{{ route('login') }}"
|
||||||
|
class="w-full flex justify-center shadow relative bg-primary-500 hover:bg-primary-400 text-white dark:text-gray-900 w-full flex justify-center cursor-pointer rounded text-sm font-bold focus:outline-none focus:ring ring-primary-200 dark:ring-gray-600 inline-flex items-center justify-center h-9 px-3 mb-3 w-full flex justify-center shadow relative bg-primary-500 hover:bg-primary-400 text-white dark:text-gray-900 w-full flex justify-center"
|
||||||
|
>
|
||||||
|
<span class=""><span>{{ __('module.base-auth::base.go_to_login_page') }}</span></span>
|
||||||
|
</a>
|
||||||
|
</form>
|
||||||
|
@stop
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
@extends('module.base-auth::layouts.auth-layout')
|
||||||
|
|
||||||
|
@push('js')
|
||||||
|
<script>
|
||||||
|
async function resetPassword(event) {
|
||||||
|
const response = await postData(event.target.action, getFormData(event))
|
||||||
|
|
||||||
|
if (response.errors) {
|
||||||
|
loopObject(response.errors, item => addValidationClasses(item))
|
||||||
|
} else {
|
||||||
|
removeValidationClasess()
|
||||||
|
|
||||||
|
if (response.step === 1) {
|
||||||
|
showVerificationCodeBox()
|
||||||
|
|
||||||
|
Swal.fire({
|
||||||
|
title: '{{ __('Verification code') }}',
|
||||||
|
text: response.message,
|
||||||
|
icon: 'info'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response.step === 2) {
|
||||||
|
showPasswordBox()
|
||||||
|
|
||||||
|
Swal.fire({
|
||||||
|
title: '{{ __('Reset Password') }}',
|
||||||
|
text: response.message,
|
||||||
|
icon: 'warning'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response.step === 3) {
|
||||||
|
await Swal.fire({
|
||||||
|
title: response.message,
|
||||||
|
showDenyButton: false,
|
||||||
|
showCancelButton: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
window.location.href = '{{ route('login') }}'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<form
|
||||||
|
method="POST"
|
||||||
|
action="{{ route('reset-password') }}"
|
||||||
|
onsubmit="event.preventDefault();resetPassword(event)"
|
||||||
|
class="bg-white dark:bg-gray-800 rounded-lg p-8 w-[25rem] mx-auto"
|
||||||
|
>
|
||||||
|
@csrf
|
||||||
|
|
||||||
|
<h2 class="text-2xl text-center font-normal mb-6">{{ __('Enter your username to continue') }}</h2>
|
||||||
|
<svg class="block mx-auto mb-6" xmlns="http://www.w3.org/2000/svg" width="100" height="2" viewBox="0 0 100 2">
|
||||||
|
<path fill="#D8E3EC" d="M0 0h100v2H0z"></path>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
<div id="username-box" class="mb-6">
|
||||||
|
<label class="block mb-2" for="username">
|
||||||
|
{{ __('Username') }}
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
id="username"
|
||||||
|
type="text"
|
||||||
|
name="username"
|
||||||
|
class="form-control form-input form-input-bordered w-full"
|
||||||
|
autofocus=""
|
||||||
|
>
|
||||||
|
<input type="hidden" name="step-sms" value="1">
|
||||||
|
|
||||||
|
<span id="username-error-box" class="text-red-500 text-italic error-box"></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-6 hidden" id="verification-code-box">
|
||||||
|
<label class="block mb-2" for="verification">
|
||||||
|
{{ __('Verification code') }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="hidden" id="reset-password-container">
|
||||||
|
<div class="mb-6" id="password-box">
|
||||||
|
<label class="block mb-2" for="password">
|
||||||
|
{{ __('Password') }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-6" id="password-confirm-box">
|
||||||
|
<label class="block mb-2" for="password_confirmation">
|
||||||
|
{{ __('Confirm Password') }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button class="w-full flex justify-center shadow relative bg-primary-500 hover:bg-primary-400 text-white dark:text-gray-900 w-full flex justify-center cursor-pointer rounded text-sm font-bold focus:outline-none focus:ring ring-primary-200 dark:ring-gray-600 inline-flex items-center justify-center h-9 px-3 mb-3 w-full flex justify-center shadow relative bg-primary-500 hover:bg-primary-400 text-white dark:text-gray-900 w-full flex justify-center" type="submit">
|
||||||
|
<span class=""><span>{{ __('Submit') }}</span></span>
|
||||||
|
</button>
|
||||||
|
<a href="{{ route('register') }}" class="w-full flex justify-center shadow relative bg-primary-500 hover:bg-primary-400 text-white dark:text-gray-900 w-full flex justify-center cursor-pointer rounded text-sm font-bold focus:outline-none focus:ring ring-primary-200 dark:ring-gray-600 inline-flex items-center justify-center h-9 px-3 mb-3 w-full flex justify-center shadow relative bg-primary-500 hover:bg-primary-400 text-white dark:text-gray-900 w-full flex justify-center">
|
||||||
|
<span class=""><span>{{ __('Go to login page') }}</span></span>
|
||||||
|
</a>
|
||||||
|
</form>
|
||||||
|
@stop
|
||||||
@@ -0,0 +1,145 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="tk" dir="ltr" class="h-full font-sans antialiased">
|
||||||
|
<head>
|
||||||
|
<meta name="theme-color" content="#fff">
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width"/>
|
||||||
|
<meta name="locale" content="tk"/>
|
||||||
|
<meta name="robots" content="noindex">
|
||||||
|
|
||||||
|
<!-- Styles -->
|
||||||
|
<link rel="stylesheet" href="/assets/css/auth-layout.css">
|
||||||
|
<style>
|
||||||
|
.bg-secondary-500 {
|
||||||
|
background-color: rgb(186,230,253);
|
||||||
|
}
|
||||||
|
.hover:bg-secondary-400 {
|
||||||
|
background-color: rgba(24, 182, 155, 0.5);
|
||||||
|
}
|
||||||
|
.underline {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
.d-none {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body class="min-w-site text-sm font-medium min-h-full text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-gray-900">
|
||||||
|
<div class="py-6 px-1 md:px-2 lg:px-6">
|
||||||
|
<div class="mx-auto py-8 max-w-sm flex justify-center">
|
||||||
|
<span class="uppercase text-4xl">{{ __('module.base-auth::base.online_panel') }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="bg-white dark:bg-gray-800 shadow rounded-lg p-8 max-w-[25rem] mx-auto">
|
||||||
|
|
||||||
|
<h2 class="text-2xl text-center font-normal mb-6">{{ __('module.base-auth::base.verify_phone_number') }}</h2>
|
||||||
|
|
||||||
|
<div class="flex justify-center items-center mb-6">
|
||||||
|
<h2 class="text-lg text-center font-normal mr-4">+993 {{ $phone }}</h2>
|
||||||
|
|
||||||
|
<span href="#" class="underline cursor-pointer" onclick="showChangePhone()" id="change-phone-button">
|
||||||
|
{{ __('module.base-auth::base.change_number') }}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span href="#" class="underline cursor-pointer d-none" onclick="goBack()" id="go-back-button">
|
||||||
|
{{ __('module.base-auth::base.go_back') }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Border line --}}
|
||||||
|
<svg class="block mx-auto mb-6" xmlns="http://www.w3.org/2000/svg" width="100" height="2" viewBox="0 0 100 2">
|
||||||
|
<path fill="#D8E3EC" d="M0 0h100v2H0z"></path>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
{{-- Change phone form --}}
|
||||||
|
<form method="POST" action="{{ route('change-phone') }}" id="change-phone-form" class="d-none" onsubmit="event.preventDefault();changePhone(event)">
|
||||||
|
@csrf
|
||||||
|
<div class="mb-6">
|
||||||
|
<label class="block mb-2" for="phone">
|
||||||
|
{{ __('module.base-auth::base.change_phone_label') }}
|
||||||
|
</label>
|
||||||
|
<input class="form-control form-input form-input-bordered w-full" id="phone" type="text" name="phone" required="">
|
||||||
|
|
||||||
|
<span id="phone-error-box" class="text-red-500 text-italic error-box"></span>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="w-full flex justify-center shadow relative bg-primary-500 hover:bg-primary-400 text-white dark:text-gray-900 w-full flex justify-center cursor-pointer rounded text-sm font-bold focus:outline-none focus:ring ring-primary-200 dark:ring-gray-600 inline-flex items-center justify-center h-9 px-3 mb-3 w-full flex justify-center shadow relative bg-primary-500 hover:bg-primary-400 text-white dark:text-gray-900 w-full flex justify-center">
|
||||||
|
<span class=""><span>{{ __('module.base-auth::base.change_number') }}</span></span>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{{-- Verification form --}}
|
||||||
|
<form method="POST" action="{{ route('sms-verification') }}" id="verification-form">
|
||||||
|
@csrf
|
||||||
|
<div class="mb-6">
|
||||||
|
<label class="block mb-2" for="code">
|
||||||
|
{{ __('module.base-auth::base.verification_code') }}
|
||||||
|
</label>
|
||||||
|
<input class="form-control form-input form-input-bordered w-full" id="code" type="number" name="code" required="">
|
||||||
|
|
||||||
|
@if($errors->any())
|
||||||
|
@foreach($errors->all() as $error)
|
||||||
|
<p class="mt-2 text-red-500">{{ $error }}</p>
|
||||||
|
@endforeach
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="w-full flex justify-center shadow relative bg-primary-500 hover:bg-primary-400 text-white dark:text-gray-900 w-full flex justify-center cursor-pointer rounded text-sm font-bold focus:outline-none focus:ring ring-primary-200 dark:ring-gray-600 inline-flex items-center justify-center h-9 px-3 mb-3 w-full flex justify-center shadow relative bg-primary-500 hover:bg-primary-400 text-white dark:text-gray-900 w-full flex justify-center">
|
||||||
|
<span class=""><span>{{ __('module.base-auth::base.submit') }}</span></span>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="/assets/js/inputmask.min.js"></script>
|
||||||
|
<script src="/assets/js/sweetalert2.js"></script>
|
||||||
|
<script src="/assets/js/fn.js"></script>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
let phoneField = $_ID('phone')
|
||||||
|
let changePhoneform = $_ID('change-phone-form')
|
||||||
|
let verificationForm = $_ID('verification-form')
|
||||||
|
let changePhoneButton = $_ID('change-phone-button')
|
||||||
|
let goBackButton = $_ID('go-back-button')
|
||||||
|
|
||||||
|
ready(() => {
|
||||||
|
new Inputmask("+(\\9\\93)-99-99-99-99").mask(phoneField);
|
||||||
|
})
|
||||||
|
|
||||||
|
async function goBack() {
|
||||||
|
hide(changePhoneform)
|
||||||
|
show(changePhoneButton)
|
||||||
|
|
||||||
|
hide(goBackButton)
|
||||||
|
show(verificationForm)
|
||||||
|
}
|
||||||
|
|
||||||
|
function showChangePhone() {
|
||||||
|
show(changePhoneform)
|
||||||
|
hide(changePhoneButton)
|
||||||
|
|
||||||
|
show(goBackButton)
|
||||||
|
hide(verificationForm)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function changePhone(event) {
|
||||||
|
const response = await postData(event.target.action, getFormData(event))
|
||||||
|
|
||||||
|
if (response.errors) {
|
||||||
|
loopObject(response.errors, item => addValidationClasses(item))
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
removeValidationClasess()
|
||||||
|
|
||||||
|
await Swal.fire({
|
||||||
|
title: '{{ __('module.base-auth::base.successfully_changed_phone') }}',
|
||||||
|
text: '{{ __('module.base-auth::base.please_now_verify_your_phone_number_to_continue') }}',
|
||||||
|
icon: 'success',
|
||||||
|
showDenyButton: false,
|
||||||
|
showCancelButton: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
window.location.href = response.url;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
28
app/Modules/BaseAuth/Routes/base-auth-routes.php
Normal file
28
app/Modules/BaseAuth/Routes/base-auth-routes.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Modules\BaseAuth\Controllers\LoginController;
|
||||||
|
use App\Modules\BaseAuth\Controllers\RegisterController;
|
||||||
|
use App\Modules\BaseAuth\Controllers\ResetPasswordController;
|
||||||
|
use App\Modules\BaseAuth\Middleware\RedirectIfUserPhoneIsVerfied;
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
|
Route::middleware(['web', 'guest'])->group(function () {
|
||||||
|
Route::get('/login', [LoginController::class, 'showLoginForm'])->name('login');
|
||||||
|
Route::post('/login', [LoginController::class, 'login']);
|
||||||
|
|
||||||
|
Route::get('/register', [RegisterController::class, 'showNovaRegisterpageForm'])->name('register');
|
||||||
|
Route::post('/register', [RegisterController::class, 'register']);
|
||||||
|
|
||||||
|
Route::get('reset-password', [ResetPasswordController::class, 'index'])->name('reset-password');
|
||||||
|
Route::post('reset-password', [ResetPasswordController::class, 'store']);
|
||||||
|
});
|
||||||
|
|
||||||
|
Route::middleware(['web', 'auth', RedirectIfUserPhoneIsVerfied::class])->group(function () {
|
||||||
|
Route::post('change-phone', [RegisterController::class, 'changePhone'])->name('change-phone');
|
||||||
|
|
||||||
|
Route::get('sms-verification', [RegisterController::class, 'smsVerification'])
|
||||||
|
->name('sms-verification');
|
||||||
|
|
||||||
|
Route::post('sms-verification', [RegisterController::class, 'verifySmsCode']);
|
||||||
|
|
||||||
|
});
|
||||||
48
app/Modules/BaseAuth/base-auth-helpers.php
Normal file
48
app/Modules/BaseAuth/base-auth-helpers.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Modules\BaseAuth\Models\AuthEvent;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Config;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store auth event
|
||||||
|
*/
|
||||||
|
function storeAuthEvent(string $name, Request $request): void
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
AuthEvent::create([
|
||||||
|
'name' => $name,
|
||||||
|
'request_method' => $request->method(),
|
||||||
|
'ip' => $request->ip(),
|
||||||
|
'user_agent' => $request->userAgent(),
|
||||||
|
'target_url' => $request->url(),
|
||||||
|
'options' => json_encode($request->all()),
|
||||||
|
]);
|
||||||
|
|
||||||
|
Config::set('logging.channels.auth_activity', [
|
||||||
|
'driver' => 'single',
|
||||||
|
'path' => storage_path('logs/auth_activity.log'),
|
||||||
|
'level' => 'debug',
|
||||||
|
]);
|
||||||
|
|
||||||
|
Log::channel('auth_activity')
|
||||||
|
->{AuthEvent::logType($name)}(sprintf(
|
||||||
|
'%s, APP_NAME: %s, REQUEST_TYPE: %s, SOURCE_IP: %s, SOURCE_PORT: %s, SOURCE_URL: %s, DESTINATION_IP: %s, DESTINATION_PORT: %s, DESTINATION_COUNTRY: %s, USER_ID: %s',
|
||||||
|
$name,
|
||||||
|
config()->string('app.name'),
|
||||||
|
$request->method(),
|
||||||
|
$request->ip(),
|
||||||
|
$_SERVER['REMOTE_PORT'], // @phpstan-ignore-line
|
||||||
|
$request->url(),
|
||||||
|
$request->host(),
|
||||||
|
$request->getPort(),
|
||||||
|
(module('IpStack')->isEnabled()) ? getCountryCodeFromIp($request->ip()) : 'TM',
|
||||||
|
$request->user()->id ?? '-',
|
||||||
|
));
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Log::error('could-not-store-auth-event', [
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
64
app/Modules/BaseLocale/BaseLocaleModule.php
Normal file
64
app/Modules/BaseLocale/BaseLocaleModule.php
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\BaseLocale;
|
||||||
|
|
||||||
|
use App\Modules\Makeable;
|
||||||
|
use App\Modules\ModuleContract;
|
||||||
|
|
||||||
|
class BaseLocaleModule 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 [];
|
||||||
|
}
|
||||||
|
}
|
||||||
9
app/Modules/BaseLocale/Configs/base-locale-config.php
Normal file
9
app/Modules/BaseLocale/Configs/base-locale-config.php
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'locales' => [
|
||||||
|
'tk' => 'Türkmen',
|
||||||
|
'en' => 'English',
|
||||||
|
'ru' => 'Русский',
|
||||||
|
],
|
||||||
|
];
|
||||||
21
app/Modules/BaseLocale/Controllers/BaseLocaleController.php
Normal file
21
app/Modules/BaseLocale/Controllers/BaseLocaleController.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\BaseLocale\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
|
||||||
|
class BaseLocaleController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Invoke the controller
|
||||||
|
*/
|
||||||
|
public function index(string $locale): RedirectResponse
|
||||||
|
{
|
||||||
|
if (array_key_exists($locale, baseLocales())) {
|
||||||
|
session()->put('locale', $locale);
|
||||||
|
}
|
||||||
|
|
||||||
|
return safe_back();
|
||||||
|
}
|
||||||
|
}
|
||||||
35
app/Modules/BaseLocale/Middleware/SetLocale.php
Normal file
35
app/Modules/BaseLocale/Middleware/SetLocale.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\BaseLocale\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
class SetLocale
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Handle an incoming request.
|
||||||
|
*
|
||||||
|
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||||
|
*/
|
||||||
|
public function handle(Request $request, Closure $next): Response
|
||||||
|
{
|
||||||
|
if (Auth::check()) {
|
||||||
|
/** @var \App\Models\User */
|
||||||
|
$user = $request->user();
|
||||||
|
|
||||||
|
if (array_key_exists($user->locale ?? '', baseLocales())) {
|
||||||
|
app()->setLocale($user->locale);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/** @var string */
|
||||||
|
$locale = session('locale') ?: config()->string('app.locale');
|
||||||
|
|
||||||
|
app()->setLocale($locale);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
8
app/Modules/BaseLocale/Routes/base-locale-routes.php
Normal file
8
app/Modules/BaseLocale/Routes/base-locale-routes.php
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Modules\BaseLocale\Controllers\BaseLocaleController;
|
||||||
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
|
Route::name('module.base-locale.')->middleware(['web', 'guest'])->group(function () {
|
||||||
|
Route::get('locale/{locale}', [BaseLocaleController::class, 'index'])->name('set-locale');
|
||||||
|
});
|
||||||
35
app/Modules/BaseLocale/base-locale-helpers.php
Normal file
35
app/Modules/BaseLocale/base-locale-helpers.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
|
||||||
|
if (! function_exists('baseLocales')) {
|
||||||
|
/**
|
||||||
|
* Application locales
|
||||||
|
*
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
function baseLocales(): array
|
||||||
|
{
|
||||||
|
/** @var array<string, string> */
|
||||||
|
$locales = config()->array('module.base-locale.locales');
|
||||||
|
|
||||||
|
return $locales;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! function_exists('safe_back')) {
|
||||||
|
/**
|
||||||
|
* Safe back
|
||||||
|
*/
|
||||||
|
function safe_back(string $fallback = '/'): RedirectResponse
|
||||||
|
{
|
||||||
|
$back = url()->previous();
|
||||||
|
|
||||||
|
// Allow only your own domain
|
||||||
|
if (! str_starts_with($back, config()->string('app.url'))) {
|
||||||
|
return redirect($fallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->to($back);
|
||||||
|
}
|
||||||
|
}
|
||||||
15
app/Modules/BaseModule.php
Normal file
15
app/Modules/BaseModule.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules;
|
||||||
|
|
||||||
|
class BaseModule
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
public string $path,
|
||||||
|
public string $name,
|
||||||
|
public ModuleContract $app,
|
||||||
|
public bool $enabled = false,
|
||||||
|
) {
|
||||||
|
$this->enabled = $this->app->isEnabled();
|
||||||
|
}
|
||||||
|
}
|
||||||
64
app/Modules/Branch/BranchModule.php
Normal file
64
app/Modules/Branch/BranchModule.php
Normal 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 [];
|
||||||
|
}
|
||||||
|
}
|
||||||
38
app/Modules/Branch/Controllers/BranchController.php
Normal file
38
app/Modules/Branch/Controllers/BranchController.php
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -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');
|
||||||
|
}
|
||||||
|
};
|
||||||
11
app/Modules/Branch/Interfaces/BelongsToBranch.php
Normal file
11
app/Modules/Branch/Interfaces/BelongsToBranch.php
Normal 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 {}
|
||||||
80
app/Modules/Branch/Models/Branch.php
Normal file
80
app/Modules/Branch/Models/Branch.php
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
5
app/Modules/Branch/Repositories/BranchRepository.php
Normal file
5
app/Modules/Branch/Repositories/BranchRepository.php
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\Branch\Repositories;
|
||||||
|
|
||||||
|
class BranchRepository {}
|
||||||
6
app/Modules/Branch/Resources/Lang/tk/base.php
Normal file
6
app/Modules/Branch/Resources/Lang/tk/base.php
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'branch' => 'Şahamça',
|
||||||
|
'branches' => 'Şahamçalar',
|
||||||
|
];
|
||||||
313
app/Modules/Core/Commands/MakeModule.php
Normal file
313
app/Modules/Core/Commands/MakeModule.php
Normal file
@@ -0,0 +1,313 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\Core\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Contracts\Console\PromptsForMissingInput;
|
||||||
|
use Illuminate\Database\Migrations\MigrationCreator;
|
||||||
|
use Illuminate\Filesystem\Filesystem;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class MakeModule extends Command implements PromptsForMissingInput
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Filesystem instance
|
||||||
|
*/
|
||||||
|
protected Filesystem $files;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module name
|
||||||
|
*/
|
||||||
|
protected string $moduleName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module directory path
|
||||||
|
*/
|
||||||
|
protected string $moduleDirectory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'make:module {module} {--plain : Create a plain module structure without default files}';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Create new module';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prompt for missing input arguments using the returned questions.
|
||||||
|
*
|
||||||
|
* @return array<string, array<int, string>>
|
||||||
|
*/
|
||||||
|
protected function promptForMissingArgumentsUsing(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'module' => ['Module name', 'News, Product, Order...'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new command instance.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(Filesystem $files)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
$this->files = $files;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*/
|
||||||
|
public function handle(): void
|
||||||
|
{
|
||||||
|
/* @var string */
|
||||||
|
$module = $this->argument('module');
|
||||||
|
$this->moduleName = $module;
|
||||||
|
$this->moduleDirectory = modules_path($module.'/');
|
||||||
|
|
||||||
|
// Create module directory if not exists...
|
||||||
|
$this->makeDirectory($this->moduleDirectory);
|
||||||
|
|
||||||
|
// Make a module file...
|
||||||
|
$this->makeModuleFile($this->moduleDirectory);
|
||||||
|
|
||||||
|
// Repository...
|
||||||
|
$this->makeDirectory($this->moduleDirectory.'Repositories');
|
||||||
|
$this->makeRepository($this->moduleDirectory.'Repositories');
|
||||||
|
|
||||||
|
if ($this->option('plain')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Models...
|
||||||
|
$this->makeDirectory($this->moduleDirectory.'Models');
|
||||||
|
$this->makeModelFile($this->moduleDirectory.'Models');
|
||||||
|
|
||||||
|
// Database...
|
||||||
|
$this->makeDirectory($this->moduleDirectory.'Database');
|
||||||
|
$this->makeDirectory($this->moduleDirectory.'Database/Migrations');
|
||||||
|
$this->makeMigrationFile($this->moduleDirectory.'Database/Migrations');
|
||||||
|
|
||||||
|
// Controller...
|
||||||
|
$this->makeDirectory($this->moduleDirectory.'Controllers');
|
||||||
|
$this->makeController($this->moduleDirectory.'Controllers');
|
||||||
|
|
||||||
|
// Filament resource...
|
||||||
|
// $this->makeDirectory($this->moduleDirectory.'Filament');
|
||||||
|
// $this->makeDirectory($this->moduleDirectory.'Filament/Resources');
|
||||||
|
// $this->makeFilamentResource($this->moduleDirectory.'Filament/Resources');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make module file
|
||||||
|
*/
|
||||||
|
public function makeModuleFile(string $moduleDirectory): void
|
||||||
|
{
|
||||||
|
$creationStatus = $this->createFileFromStub(
|
||||||
|
createFilePath: sprintf('%s/%sModule', $moduleDirectory, $this->moduleName),
|
||||||
|
stubFile: __DIR__.'/stubs/make-module/module.stub',
|
||||||
|
stubVariables: [
|
||||||
|
'NAMESPACE' => sprintf('App\\Modules\\%s', $this->moduleName),
|
||||||
|
'CLASS_NAME' => $this->moduleName.'Module',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$creationStatus
|
||||||
|
? $this->info("Module created: {$this->moduleName} created")
|
||||||
|
: $this->info("Module: {$this->moduleName} already exits");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make model file
|
||||||
|
*/
|
||||||
|
protected function makeModelFile(string $modelPath): void
|
||||||
|
{
|
||||||
|
$creationStatus = $this->createFileFromStub(
|
||||||
|
createFilePath: sprintf('%s/%s', $modelPath, $this->moduleName),
|
||||||
|
stubFile: __DIR__.'/stubs/make-module/model.stub',
|
||||||
|
stubVariables: [
|
||||||
|
'NAMESPACE' => sprintf('App\\Modules\\%s\\Models', $this->moduleName),
|
||||||
|
'CLASS_NAME' => $this->moduleName,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$creationStatus
|
||||||
|
? $this->info("Model created: {$this->moduleName} created")
|
||||||
|
: $this->info("Model: {$this->moduleName} already exits");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make migration file
|
||||||
|
*/
|
||||||
|
protected function makeMigrationFile(string $migrationsPath): void
|
||||||
|
{
|
||||||
|
$migrationCreator = new MigrationCreator(
|
||||||
|
files: new Filesystem,
|
||||||
|
customStubPath: modules_path('Core/Commands/stubs/make-module/migration.stub')
|
||||||
|
);
|
||||||
|
|
||||||
|
$migrationPath = $migrationCreator->create(Str::lower('create_'.Str::snake(Str::plural($this->moduleName)).'_table'), $migrationsPath);
|
||||||
|
$migrationName = Str::afterLast($migrationPath, '/');
|
||||||
|
|
||||||
|
$this->info("Migration created: {$migrationName} created");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make controller file
|
||||||
|
*/
|
||||||
|
protected function makeController(string $controllersPath): void
|
||||||
|
{
|
||||||
|
$creationStatus = $this->createFileFromStub(
|
||||||
|
createFilePath: sprintf('%s/%sController', $controllersPath, $this->moduleName),
|
||||||
|
stubFile: modules_path('Core/Commands/stubs/make-module/controller.stub'),
|
||||||
|
stubVariables: [
|
||||||
|
'NAMESPACE' => sprintf('App\\Modules\\%s\\Controllers', $this->moduleName),
|
||||||
|
'CONTROLLER_NAME' => $this->moduleName.'Controller',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$creationStatus
|
||||||
|
? $this->info("Controller created: {$this->moduleName} created")
|
||||||
|
: $this->info("Controller: {$this->moduleName} already exits");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make repository file
|
||||||
|
*/
|
||||||
|
protected function makeRepository(string $path): void
|
||||||
|
{
|
||||||
|
$creationStatus = $this->createFileFromStub(
|
||||||
|
createFilePath: sprintf('%s/%s', $path, $this->moduleName.'Repository'),
|
||||||
|
stubFile: __DIR__.'/stubs/make-module/repository.stub',
|
||||||
|
stubVariables: [
|
||||||
|
'NAMESPACE' => sprintf('App\Modules\%s\Repositories', $this->moduleName),
|
||||||
|
'MODULE_NAME' => ucfirst($this->moduleName),
|
||||||
|
'MODEL_NAMESPACE' => sprintf('App\Modules\%s\Models\%s', $this->moduleName, $this->moduleName),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
$creationStatus
|
||||||
|
? $this->info("Repository created: {$this->moduleName} created")
|
||||||
|
: $this->info("Repository: {$this->moduleName} already exits");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make nova resource file
|
||||||
|
*/
|
||||||
|
public function makeFilamentResource(string $path): void
|
||||||
|
{
|
||||||
|
// Base resource...
|
||||||
|
$resourceCreateStatus = $this->createFileFromStub(
|
||||||
|
createFilePath: sprintf('%s/%s', $path, $this->moduleName.'Resource'),
|
||||||
|
stubFile: __DIR__.'/stubs/make-module/filament/base-resource.stub',
|
||||||
|
stubVariables: [
|
||||||
|
'NAMESPACE' => sprintf('App\Modules\%s\Filament\Resources', $this->moduleName),
|
||||||
|
'MODEL_NAMESPACE' => sprintf('App\Modules\%s\Models\%s', $this->moduleName, $this->moduleName),
|
||||||
|
'MODEL_NAME_SINGULAR' => Str::of($this->moduleName)->singular(),
|
||||||
|
'MODEL_NAME_PLURAL' => Str::of($this->moduleName)->plural(),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
$resourceCreateStatus
|
||||||
|
? $this->info("Filament resource created: {$this->moduleName} created")
|
||||||
|
: $this->info("Filament resource: {$this->moduleName} already exits");
|
||||||
|
|
||||||
|
$resourcePagesDir = $this->makeDirectory(sprintf('%s/%sResource', $path, $this->moduleName));
|
||||||
|
|
||||||
|
// Create page...
|
||||||
|
$resourceCreatePageStatus = $this->createFileFromStub(
|
||||||
|
createFilePath: sprintf('%s/Create%s', $resourcePagesDir, $this->moduleName),
|
||||||
|
stubFile: __DIR__.'/stubs/make-module/filament/pages/create-resource-page.stub',
|
||||||
|
stubVariables: [
|
||||||
|
'CREATE_RESOURCE_PAGE_NAMESPACE' => sprintf('App\Modules\%s\Filament\Resources\%sResource\Pages', $this->moduleName, $this->moduleName),
|
||||||
|
'BASE_RESOURCE_NAMESPACE' => sprintf('App\Modules\%s\Filament\Resources\%sResource', $this->moduleName, $this->moduleName),
|
||||||
|
'MODEL_NAME_SINGULAR' => Str::of($this->moduleName)->singular(),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
$resourceCreatePageStatus
|
||||||
|
? $this->info("Filament create page resource created: {$this->moduleName} created")
|
||||||
|
: $this->info("Filament create page resource: {$this->moduleName} already exits");
|
||||||
|
|
||||||
|
// Edit page...
|
||||||
|
$resourceEditPageStatus = $this->createFileFromStub(
|
||||||
|
createFilePath: sprintf('%s/Edit%s', $resourcePagesDir, $this->moduleName),
|
||||||
|
stubFile: __DIR__.'/stubs/make-module/filament/pages/edit-resource-page.stub',
|
||||||
|
stubVariables: [
|
||||||
|
'EDIT_RESOURCE_PAGE_NAMESPACE' => sprintf('App\Modules\%s\Filament\Resources\%sResource\Pages', $this->moduleName, $this->moduleName),
|
||||||
|
'BASE_RESOURCE_NAMESPACE' => sprintf('App\Modules\%s\Filament\Resources\%sResource', $this->moduleName, $this->moduleName),
|
||||||
|
'MODEL_NAME_SINGULAR' => Str::of($this->moduleName)->singular(),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
$resourceEditPageStatus
|
||||||
|
? $this->info("Filament edit page resource created: {$this->moduleName} created")
|
||||||
|
: $this->info("Filament edit page resource: {$this->moduleName} already exits");
|
||||||
|
|
||||||
|
// List page...
|
||||||
|
$resourceListPageStatus = $this->createFileFromStub(
|
||||||
|
createFilePath: sprintf('%s/List%s', $resourcePagesDir, Str::of($this->moduleName)->plural()),
|
||||||
|
stubFile: __DIR__.'/stubs/make-module/filament/pages/list-resource-page.stub',
|
||||||
|
stubVariables: [
|
||||||
|
'LIST_RESOURCE_PAGE_NAMESPACE' => sprintf('App\Modules\%s\Filament\Resources\%sResource\Pages', $this->moduleName, $this->moduleName),
|
||||||
|
'BASE_RESOURCE_NAMESPACE' => sprintf('App\Modules\%s\Filament\Resources\%sResource', $this->moduleName, $this->moduleName),
|
||||||
|
'MODEL_NAME_SINGULAR' => Str::of($this->moduleName)->singular(),
|
||||||
|
'MODEL_NAME_PLURAL' => Str::of($this->moduleName)->plural(),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
$resourceListPageStatus
|
||||||
|
? $this->info("Filament list page resource created: {$this->moduleName} created")
|
||||||
|
: $this->info("Filament list page resource: {$this->moduleName} already exits");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the directory for the class if necessary.
|
||||||
|
*/
|
||||||
|
protected function makeDirectory(string $path): string
|
||||||
|
{
|
||||||
|
if (! $this->files->isDirectory($path)) {
|
||||||
|
$this->files->makeDirectory($path, 0777, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a file from stub
|
||||||
|
*
|
||||||
|
* @param array<string, string> $stubVariables
|
||||||
|
*/
|
||||||
|
protected function createFileFromStub(string $createFilePath, string $stubFile, array $stubVariables): int|bool
|
||||||
|
{
|
||||||
|
$contents = $this->getStubContents($stubFile, $stubVariables);
|
||||||
|
|
||||||
|
return $this->files->missing($createFilePath)
|
||||||
|
? $this->files->put($createFilePath.'.php', $contents)
|
||||||
|
: false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace the stub variables(key) with the desire value
|
||||||
|
*
|
||||||
|
* @param array<string, string> $stubVariables
|
||||||
|
*/
|
||||||
|
protected function getStubContents(string $stub, array $stubVariables = []): string
|
||||||
|
{
|
||||||
|
$contents = (string) file_get_contents($stub);
|
||||||
|
|
||||||
|
foreach ($stubVariables as $search => $replace) {
|
||||||
|
$contents = str_replace('$'.$search.'$', $replace, $contents);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $contents;
|
||||||
|
}
|
||||||
|
}
|
||||||
47
app/Modules/Core/Commands/ModuleMakeController.php
Normal file
47
app/Modules/Core/Commands/ModuleMakeController.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\Core\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\Artisan;
|
||||||
|
|
||||||
|
class ModuleMakeController extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'module:controller {module} {controller}';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Create a new controller for a module';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*/
|
||||||
|
public function handle(): void
|
||||||
|
{
|
||||||
|
$moduleName = $this->argument('module');
|
||||||
|
$controllerName = $this->argument('controller');
|
||||||
|
$modulePath = modules_path($moduleName);
|
||||||
|
|
||||||
|
if (! is_dir($modulePath)) {
|
||||||
|
$this->error("Module [{$moduleName}] does not exist.");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$controllerPath = "App\\Modules\\{$moduleName}\\Controllers\\{$controllerName}";
|
||||||
|
|
||||||
|
Artisan::call('make:controller', [
|
||||||
|
'name' => $controllerPath,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->info("Controller [{$controllerName}] created successfully in module [{$moduleName}].");
|
||||||
|
}
|
||||||
|
}
|
||||||
48
app/Modules/Core/Commands/ModuleMakeMigration.php
Normal file
48
app/Modules/Core/Commands/ModuleMakeMigration.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\Core\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\Artisan;
|
||||||
|
|
||||||
|
class ModuleMakeMigration extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'module:migration {module} {migration}';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Create a new migration file for a module';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*/
|
||||||
|
public function handle(): void
|
||||||
|
{
|
||||||
|
$moduleName = $this->argument('module');
|
||||||
|
$migrationName = $this->argument('migration');
|
||||||
|
$modulePath = modules_path($moduleName);
|
||||||
|
|
||||||
|
if (! is_dir($modulePath)) {
|
||||||
|
$this->error("Module [{$moduleName}] does not exist.");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$migrationPath = "app/Modules/{$moduleName}/Database/Migrations";
|
||||||
|
|
||||||
|
Artisan::call('make:migration', [
|
||||||
|
'name' => $migrationName,
|
||||||
|
'--path' => $migrationPath,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->info("Migration [{$migrationName}] created successfully in module [{$moduleName}].");
|
||||||
|
}
|
||||||
|
}
|
||||||
47
app/Modules/Core/Commands/ModuleMakeModel.php
Normal file
47
app/Modules/Core/Commands/ModuleMakeModel.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\Core\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\Artisan;
|
||||||
|
|
||||||
|
class ModuleMakeModel extends Command
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name and signature of the console command.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $signature = 'module:model {module} {model}';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The console command description.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $description = 'Create a new model for a module';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the console command.
|
||||||
|
*/
|
||||||
|
public function handle(): void
|
||||||
|
{
|
||||||
|
$moduleName = $this->argument('module');
|
||||||
|
$modelName = $this->argument('model');
|
||||||
|
$modulePath = modules_path($moduleName);
|
||||||
|
|
||||||
|
if (! is_dir($modulePath)) {
|
||||||
|
$this->error("Module [{$moduleName}] does not exist.");
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$modelPath = "App\\Modules\\{$moduleName}\\Models\\{$modelName}";
|
||||||
|
|
||||||
|
Artisan::call('make:model', [
|
||||||
|
'name' => $modelPath,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->info("Model [{$modelName}] created successfully in module [{$moduleName}].");
|
||||||
|
}
|
||||||
|
}
|
||||||
49
app/Modules/Core/Commands/stubs/make-module/controller.stub
Normal file
49
app/Modules/Core/Commands/stubs/make-module/controller.stub
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace $NAMESPACE$;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class $CONTROLLER_NAME$ extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index(Request $request): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(Request $request): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*/
|
||||||
|
public function show(Request $request): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update(Request $request): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function destroy(Request $request): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace $NAMESPACE$;
|
||||||
|
|
||||||
|
use App\Modules\$MODEL_NAME_SINGULAR$\Filament\Resources\$MODEL_NAME_SINGULAR$Resource\Pages\Create$MODEL_NAME_SINGULAR$;
|
||||||
|
use App\Modules\$MODEL_NAME_SINGULAR$\Filament\Resources\$MODEL_NAME_SINGULAR$Resource\Pages\Edit$MODEL_NAME_SINGULAR$;
|
||||||
|
use App\Modules\$MODEL_NAME_SINGULAR$\Filament\Resources\$MODEL_NAME_SINGULAR$Resource\Pages\List$MODEL_NAME_SINGULAR$s;
|
||||||
|
use $MODEL_NAMESPACE$;
|
||||||
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
|
||||||
|
class $MODEL_NAME_SINGULAR$Resource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?string $model = $MODEL_NAME_SINGULAR$::class;
|
||||||
|
|
||||||
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||||
|
|
||||||
|
public static function form(Form $form): Form
|
||||||
|
{
|
||||||
|
return $form
|
||||||
|
->schema([
|
||||||
|
// ...
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->columns([
|
||||||
|
|
||||||
|
])
|
||||||
|
->filters([
|
||||||
|
//
|
||||||
|
])
|
||||||
|
->actions([
|
||||||
|
Tables\Actions\EditAction::make(),
|
||||||
|
])
|
||||||
|
->bulkActions([
|
||||||
|
Tables\Actions\BulkActionGroup::make([
|
||||||
|
Tables\Actions\DeleteBulkAction::make(),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getRelations(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => List$MODEL_NAME_PLURAL$::route('/'),
|
||||||
|
'create' => Create$MODEL_NAME_SINGULAR$::route('/create'),
|
||||||
|
'edit' => Edit$MODEL_NAME_SINGULAR$::route('/{record}/edit'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace $CREATE_RESOURCE_PAGE_NAMESPACE$;
|
||||||
|
|
||||||
|
use $BASE_RESOURCE_NAMESPACE$;
|
||||||
|
use Filament\Resources\Pages\CreateRecord;
|
||||||
|
|
||||||
|
class Create$MODEL_NAME_SINGULAR$ extends CreateRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = $MODEL_NAME_SINGULAR$Resource::class;
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace $EDIT_RESOURCE_PAGE_NAMESPACE$;
|
||||||
|
|
||||||
|
use $BASE_RESOURCE_NAMESPACE$;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\EditRecord;
|
||||||
|
|
||||||
|
class Edit$MODEL_NAME_SINGULAR$ extends EditRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = $MODEL_NAME_SINGULAR$Resource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\DeleteAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace $LIST_RESOURCE_PAGE_NAMESPACE$;
|
||||||
|
|
||||||
|
use $BASE_RESOURCE_NAMESPACE$;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
|
class List$MODEL_NAME_PLURAL$ extends ListRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = $MODEL_NAME_SINGULAR$Resource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\CreateAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
27
app/Modules/Core/Commands/stubs/make-module/migration.stub
Executable file
27
app/Modules/Core/Commands/stubs/make-module/migration.stub
Executable file
@@ -0,0 +1,27 @@
|
|||||||
|
<?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('{{ table }}', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('{{ table }}');
|
||||||
|
}
|
||||||
|
};
|
||||||
11
app/Modules/Core/Commands/stubs/make-module/model.stub
Normal file
11
app/Modules/Core/Commands/stubs/make-module/model.stub
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace $NAMESPACE$;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class $CLASS_NAME$ extends Model
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
64
app/Modules/Core/Commands/stubs/make-module/module.stub
Normal file
64
app/Modules/Core/Commands/stubs/make-module/module.stub
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace $NAMESPACE$;
|
||||||
|
|
||||||
|
use App\Modules\Makeable;
|
||||||
|
use App\Modules\ModuleContract;
|
||||||
|
|
||||||
|
class $CLASS_NAME$ 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,74 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace $NAMESPACE$;
|
||||||
|
|
||||||
|
use App\Nova\Resource;
|
||||||
|
use Laravel\Nova\Fields\ID;
|
||||||
|
use Laravel\Nova\Http\Requests\NovaRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @template TModel of \$MODEL_NAMESPACE$
|
||||||
|
*
|
||||||
|
* @extends Resource<TModel>
|
||||||
|
*/
|
||||||
|
class $RESOURCE_NAME_SINGULAR$ extends Resource
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The model the resource corresponds to.
|
||||||
|
*
|
||||||
|
* @var class-string<\$MODEL_NAMESPACE$>
|
||||||
|
*/
|
||||||
|
public static $model = \$MODEL_NAMESPACE$::class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The single value that should be used to represent the resource when being displayed.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public static $title = 'id';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The columns that should be searched.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
public static $search = [
|
||||||
|
'id',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The relationships that should be eager loaded on index queries.
|
||||||
|
*
|
||||||
|
* @var array<int, string>
|
||||||
|
*/
|
||||||
|
// public static $with = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the displayable label of the resource.
|
||||||
|
*/
|
||||||
|
public static function label(): string
|
||||||
|
{
|
||||||
|
return __('$MODEL_NAME_PLURAL$');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the displayable singular label of the resource.
|
||||||
|
*/
|
||||||
|
public static function singularLabel(): string
|
||||||
|
{
|
||||||
|
return __('$MODEL_NAME_SINGULAR$');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the fields displayed by the resource.
|
||||||
|
*
|
||||||
|
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
|
||||||
|
* @return array<int, \Laravel\Nova\Fields\FieldElement|\Laravel\Nova\Panel>
|
||||||
|
*/
|
||||||
|
public function fields(NovaRequest $request): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
ID::make('id')->sortable(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
10
app/Modules/Core/Commands/stubs/make-module/repository.stub
Normal file
10
app/Modules/Core/Commands/stubs/make-module/repository.stub
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace $NAMESPACE$;
|
||||||
|
|
||||||
|
use $MODEL_NAMESPACE$;
|
||||||
|
|
||||||
|
class $MODULE_NAME$Repository
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
13
app/Modules/Core/ModulePackage.php
Normal file
13
app/Modules/Core/ModulePackage.php
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Modules\Core;
|
||||||
|
|
||||||
|
class ModulePackage
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
public ModulePackageType $type,
|
||||||
|
public string $name,
|
||||||
|
public string $message,
|
||||||
|
public string $version = '',
|
||||||
|
) {}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user