add swiftpayments from old source

This commit is contained in:
2024-09-01 17:06:49 +05:00
parent 9d65fa72b6
commit a5978835d0
27 changed files with 1822 additions and 141 deletions

View File

@@ -0,0 +1,258 @@
<?php
namespace App\Console\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
*
* @var \Illuminate\Filesystem\Filesystem
*/
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}';
/**
* 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.
*
* @param \Illuminate\Filesystem\Filesystem $files
* @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);
// 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');
// Repository...
$this->makeDirectory($this->moduleDirectory.'Repositories');
$this->makeRepository($this->moduleDirectory.'Repositories');
// Nova...
$this->makeDirectory($this->moduleDirectory.'Nova');
$this->makeDirectory($this->moduleDirectory.'Nova/Resources');
$this->makeNovaResource($this->moduleDirectory.'Nova/Resources');
}
/**
* Make model file
*
* @param string $modelPath
*/
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
*
* @param string $migrationsPath
*/
protected function makeMigrationFile(string $migrationsPath): void
{
$migrationCreator = new MigrationCreator(
files: new Filesystem,
customStubPath: app_path('Console/Commands/stubs/make-module/migration.stub')
);
$migrationPath = $migrationCreator->create(Str::lower('create_'.Str::plural($this->moduleName).'_table'), $migrationsPath);
$migrationName = Str::afterLast($migrationPath, '/');
$this->info("Migration created: {$migrationName} created");
}
/**
* Make controller file
*
* @param string $controllersPath
*/
protected function makeController(string $controllersPath): void
{
$creationStatus = $this->createFileFromStub(
createFilePath: sprintf('%s/%sController', $controllersPath, $this->moduleName),
stubFile: app_path('Console/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
*
* @param string $path
*/
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
*
* @param string $path
*/
public function makeNovaResource(string $path): void
{
$creationStatus = $this->createFileFromStub(
createFilePath: sprintf('%s/%s', $path, 'Nova'.$this->moduleName),
stubFile: __DIR__.'/stubs/make-module/nova-resource.stub',
stubVariables: [
'NAMESPACE' => sprintf('App\Modules\%s\Nova\Resources', $this->moduleName),
'MODEL_NAMESPACE' => sprintf('App\Modules\%s\Models\%s', $this->moduleName, $this->moduleName),
'MODEL_NAME_PLURAL' => Str::of($this->moduleName)->plural(),
'MODEL_NAME_SINGULAR' => Str::of($this->moduleName)->singular(),
'RESOURCE_NAME_SINGULAR' => 'Nova'.Str::of($this->moduleName)->singular(),
],
);
$creationStatus
? $this->info("Nova resource created: {$this->moduleName} created")
: $this->info("Nova resource: {$this->moduleName} already exits");
}
/**
* Build the directory for the class if necessary.
*
* @param string $path
* @return string
*/
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 string $createFilePath
* @param string $stubFile
* @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 string $stub
* @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;
}
}

View 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
{
//
}
}

View 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 }}');
}
};

View File

@@ -0,0 +1,11 @@
<?php
namespace $NAMESPACE$;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Model;
class $CLASS_NAME$ extends Model
{
use HasUuids;
}

View File

@@ -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(),
];
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace $NAMESPACE$;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request;
use $MODEL_NAMESPACE$;
class $MODULE_NAME$Repository
{
/**
* $queryBuilder
*
* @var \Illuminate\Database\Eloquent\Builder<\$MODEL_NAMESPACE$>
*/
protected Builder $queryBuilder;
/**
* Model
*/
public static function model(): string
{
return $MODULE_NAME$::class;
}
/**
* Product repository
*/
public function __construct()
{
$this->queryBuilder = self::model()::query();
}
}

View File

@@ -8,6 +8,32 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Stevebauman\Location\Facades\Location;
/**
* Application locales
*
* @return array<string, string>
*/
function appLocales(): array
{
return is_array(config('app.locales')) ? config('app.locales') : [];
}
/**
* Modules directory path
*/
function modules_path(string $path = ''): string
{
return app_path('Modules/'.$path);
}
/**
* Check if module exists
*/
function module_exists(string $module): bool
{
return is_dir(modules_path(ucfirst($module)));
}
/**
* Check if a client IP is in our Server subnet
*

View File

@@ -8,7 +8,6 @@ use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\View\View;
use Laravel\Nova\Nova;
class LoginController extends Controller

View File

@@ -54,7 +54,7 @@ class RegisterController extends Controller
sendSMSVerification($user->phone);
return response()->json([
'url' => route('sms-verification')
'url' => route('sms-verification'),
]);
}

View File

@@ -0,0 +1,46 @@
<?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('swift_payments', function (Blueprint $table) {
$table->uuid('id');
$table->string('type')->nullable();
$table->string('passport_name')->nullable();
$table->string('passport_surname')->nullable();
$table->string('phone')->nullable();
$table->string('email')->nullable();
$table->string('region')->nullable();
$table->foreignId('branch_id')->nullable()->constrained('branches')->cascadeOnDelete();
$table->foreignId('user_id')->nullable()->constrained('users')->cascadeOnDelete();
$table->string('address')->nullable();
$table->json('sender_datas')->nullable();
$table->json('payment_reciever')->nullable();
$table->json('documents')->nullable();
$table->string('status')->nullable();
$table->string('notes')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
//
}
};

View File

@@ -0,0 +1,69 @@
<?php
namespace App\Modules\Swiftpayment\Models;
class ApplicationTypes
{
const STUDENT = 'student';
const STUDENT_VISA_MASTER_OTHER = 'student_visa_master_other';
const PATIENT = 'patient';
const PATIENT_VISA_MASTER_OTHER = 'patient_visa_master_other';
const VESTERN_UNION = 'vestern_union';
public static function applicationTypes()
{
return [
self::STUDENT => __('Talyp töleg'),
self::STUDENT_VISA_MASTER_OTHER => __('Talyp VISA/MASTER we beýleki'),
self::PATIENT => __('Hassa töleg'),
self::PATIENT_VISA_MASTER_OTHER => __('Hassa VISA/MASTER we beýleki'),
self::VESTERN_UNION => __('Halkara WesternUnion pul geçirim ulgamy'),
];
}
public static function applicationTypeFiles()
{
return [
self::STUDENT => [
'Daşary ýurt döwletiniň ýokary okuw mekdebinde okaýandygy baradaky güwänamasy',
'Daşary ýurt döwletiniň ýokary okuw mekdebi bilen talybyň arasynda baglaşylan şertnama',
'Daşary ýurt döwletiniň ýokary okuw mekdebi tarapyndan töleg üçin ýazylan hasap-nyrhnama',
'Talybyň Türkmenistandan gitmek we Türkmenistana gelmek üçin pasportyndaky ýurdumyzdan çykandygy we daşary ýurda gidendigi baradaky degişli edaralaryň bellikleri bolan sahypalarynyň göçürmesi',
'Talybyň garyndaşlarynyň garyndaşlyk derejesini tassyklaýjy resminamalary we pasportlar',
],
self::STUDENT_VISA_MASTER_OTHER => [
'Daşary ýurt döwletiniň ýokary okuw mekdebinde okaýandygy baradaky güwänamasy',
'Talybyň Türkmenistandan gitmek we Türkmenistana gelmek üçin pasportyndaky ýurdumyzdan çykandygy we daşary ýurda gidendigi baradaky degişli edaralaryň bellikleri bolan sahypalarynyň göçürmesi',
'Talybyň garyndaşlary ýüzlenen ýagdaýynda garyndaşlyk derejesini tassyklaýjy resminama',
],
self::PATIENT => [
'Türkmenistanyň Saglygy goraýyş we derman senagaty ministrliginiň Türkmenistanyň çäginden daşarda saglygynyň barlanmagynyň we bejerilmeginiň zerurlygy baradaky netijenamasy',
'Daşary ýurt saglygy goraýyş edarasy bilen hassanyň arasynda baglaşylan şertnama',
'Daşary ýurt saglygy goraýyş edarasy tarapyndan töleg üçin ýazylan hasap-nyrhnama',
'Talybyň Türkmenistandan gitmek we Türkmenistana gelmek üçin pasportyndaky ýurdumyzdan çykandygy we daşary ýurda gidendigi baradaky degişli edaralaryň bellikleri bolan sahypalarynyň göçürmesi',
'Hassanyň garyndaşlarynyň garyndaşlyk derejesini tassyklaýjy resminamalar we pasportlar',
],
self::PATIENT_VISA_MASTER_OTHER => [
'Türkmenistanyň Saglygy goraýyş we derman senagaty ministrliginiň Türkmenistanyň çäginden daşarda saglygynyň barlanmagynyň we bejerilmeginiň zerurlygy baradaky netijenamasy',
'Talybyň Türkmenistandan gitmek we Türkmenistana gelmek üçin pasportyndaky ýurdumyzdan çykandygy we daşary ýurda gidendigi baradaky degişli edaralaryň bellikleri bolan sahypalarynyň göçürmesi',
'Hassanyň garyndaşlarynyň garyndaşlyk derejesini tassyklaýjy resminamalar we pasportlar',
],
self::VESTERN_UNION => [
'Daşary ýurt döwletiniň bilim edarasynda okaýandygy baradaky güwänamasy',
'Maşgala agzalygy tassyklaýjy resminama',
'Talybyň Türkmenistandan gitmek we Türkmenistana gelmek üçin pasportyndaky ýurdumyzdan çykandygy we daşary ýurda gidendigi baradaky degişli edaralaryň bellikleri bolan sahypalarynyň göçürmesi',
],
];
}
public static function filesFor($type)
{
return view('nova.swiftpayments.required-files', [
'files' => static::applicationTypeFiles()[$type] ?? [],
])->render();
}
}

View File

@@ -0,0 +1,49 @@
<?php
namespace App\Modules\Swiftpayment\Models;
class SwiftPaymentStatus
{
const PENDING = 'pending';
const REGISTER = 'register';
const PROGRESS = 'progress';
const COMPLETED = 'completed';
const CANCELLED = 'cancelled';
public static function values(): array
{
return [
self::PENDING => __('Pending'),
self::REGISTER => __('Registered'),
self::PROGRESS => __('On Progress'),
self::COMPLETED => __('Completed'),
self::CANCELLED => __('Cancelled'),
];
}
public static function classes(): array
{
return [
self::PENDING => 'warning',
self::REGISTER => 'info',
self::PROGRESS => 'primary',
self::COMPLETED => 'success',
self::CANCELLED => 'danger',
];
}
public static function colors(): array
{
return [
self::PENDING => '#F5573B',
self::REGISTER => '#F2CB22',
self::PROGRESS => '#098F56',
self::COMPLETED => '#8FC15D',
self::CANCELLED => '#d70206',
];
}
}

View File

@@ -0,0 +1,55 @@
<?php
namespace App\Modules\Swiftpayment\Models;
use App\Models\Branch\Branch;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\InteractsWithMedia;
use Spatie\MediaLibrary\MediaCollections\Models\Media;
class Swiftpayment extends Model implements HasMedia
{
use HasUuids;
use InteractsWithMedia;
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'sender_datas' => 'array',
'payment_reciever' => 'array',
];
/**
* Media conversions
*
* @param Media|null $media
*/
public function registerMediaConversions(?Media $media = null): void
{
$this->addMediaConversion('thumb')
->width(200)
->height(200);
}
/**
* Media collections
*/
public function registerMediaCollections(): void
{
$this->addMediaCollection('main');
}
/**
* Branch
*/
public function branch(): BelongsTo
{
return $this->belongsTo(Branch::class);
}
}

View File

@@ -0,0 +1,185 @@
<?php
namespace App\Modules\Swiftpayment\Nova\Resources;
use App\Models\Branch\Branch;
use App\Modules\Swiftpayment\Models\ApplicationTypes;
use App\Modules\Swiftpayment\Models\SwiftPaymentStatus;
use App\Nova\Resource;
use App\Repos\System\Nova\NovaRepo;
use App\Repos\System\Settings\Legal\PassportRepo;
use App\Repos\System\Settings\Location\RegionRepo;
use Ebess\AdvancedNovaMediaLibrary\Fields\Files;
use Laravel\Nova\Fields\Badge;
use Laravel\Nova\Fields\Hidden;
use Laravel\Nova\Fields\ID;
use Laravel\Nova\Fields\Select;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Fields\Trix;
use Laravel\Nova\Http\Requests\NovaRequest;
use Nurmuhammet\NovaInputmask\NovaInputmask;
use Outl1ne\NovaSimpleRepeatable\SimpleRepeatable;
/**
* @template TModel of \App\Modules\Swiftpayment\Models\Swiftpayment
*/
class NovaSwiftpayment extends Resource
{
/**
* The model the resource corresponds to.
*
* @var class-string<\App\Modules\Swiftpayment\Models\Swiftpayment>
*/
public static $model = \App\Modules\Swiftpayment\Models\Swiftpayment::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',
];
/**
* Get the displayable label of the resource.
*/
public static function label(): string
{
return __('Swiftpayments');
}
/**
* Get the displayable singular label of the resource.
*/
public static function singularLabel(): string
{
return __('Swiftpayment');
}
/**
* 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(),
Hidden::make('user_id')->default(auth()->id()),
Select::make(__('Ýüztutmanyň görnüşi'), 'type')
->searchable()
->rules('required')
->displayUsingLabels()
->options(ApplicationTypes::applicationTypes()),
Select::make(__('Region'), 'region')
->displayUsingLabels()
->searchable()
->options(RegionRepo::values())
->default(RegionRepo::default())
->rules('required')
->sortable(),
Select::make(__('Branch'), 'branch_id')
->displayUsingLabels()
->searchable()
->dependsOn('region', NovaRepo::dependsOnRegion('region', Branch::class))
->rules('required')
->sortable(),
Text::make('Pasportdaky ady', 'passport_name')
->rules('required', 'string', 'max:255'),
Text::make('Pasportdaky familiýa', 'passport_surname')
->rules('required', 'string', 'max:255'),
NovaInputmask::make('Telefon belgi', 'phone')
->phonenumber('TM')
->rules('required', 'max:255')
->hideFromIndex(),
Text::make('Email', 'email')
->rules('required', 'max:255', 'email')
->hideFromIndex(),
Text::make('Ýaşaýan ýeriň salgysy', 'address')
->rules('required', 'string', 'max:255')
->hideFromIndex(),
SimpleRepeatable::make('Tölegi ugradyjynyň maglumatlar', 'sender_datas', [
Select::make(__('Passport serie'), 'passport_serie')
->displayUsingLabels()
->searchable()
->options(PassportRepo::values())
->rules('required')
->sortable(),
NovaInputmask::make('Passport nomeri')
->mask('999999')
->rules('required', 'max:255'),
Text::make('A.F.AA'),
])->minRows(1)->rules('required'),
SimpleRepeatable::make('Tölegi kabul edijiniň maglumatlary', 'payment_reciever', [
Select::make(__('Passport serie'), 'passport_serie')
->displayUsingLabels()
->searchable()
->options(PassportRepo::values())
->rules('required')
->sortable(),
NovaInputmask::make('Passport nomeri')
->mask('999999')
->rules('required', 'max:255'),
Text::make('A.F.AA'),
])->maxRows(1)->rules('required'),
// CustomHtml::make(__('Required files'), 'required_files')
// ->onlyOnForms()
// ->fillUsing(function ($request, $model, $attribute, $requestAttribute) {})
// ->dependsOn(['type'], function (CustomHtml $field, NovaRequest $request, FormData $formData) {
// if ($formData->type) {
// $field->html(\App\Models\ApplicationTypes::filesFor($formData->type));
// }
// }),
Files::make('Talap edilýän resminamalar', 'main')
->conversionOnIndexView('thumb')
->rules('required')
->hideFromIndex(),
Badge::make('Status')->map(SwiftPaymentStatus::classes())->addTypes([
'primary' => 'dark:bg-gray-900 bg-gray-600 text-white',
])->labels(SwiftPaymentStatus::values()),
Select::make(__('Status'), 'status')
->onlyOnForms()
->hideWhenCreating()
->displayUsingLabels()
->options(SwiftPaymentStatus::values())
->canSee(function ($request) {
return $request->user()->hasRole(['admin', 'manager', 'operator']);
}),
Trix::make(__('Notes'), 'notes')
->hideWhenCreating()
->alwaysShow()
->readonly(function ($request) {
return ! $request->user()->hasRole(['admin', 'manager', 'operator']);
}),
];
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Modules\Swiftpayment\Repositories;
use App\Modules\Swiftpayment\Models\Swiftpayment;
use Illuminate\Database\Eloquent\Builder;
class SwiftpaymentRepository
{
/**
* $queryBuilder
*
* @var \Illuminate\Database\Eloquent\Builder<\App\Modules\Swiftpayment\Models\Swiftpayment>
*/
protected Builder $queryBuilder;
/**
* Model
*/
public static function model(): string
{
return Swiftpayment::class;
}
/**
* Product repository
*/
public function __construct()
{
$this->queryBuilder = self::model()::query();
}
}

View File

@@ -2,11 +2,10 @@
namespace App\Nova;
use DragonCode\Contracts\Cashier\Config\Payments\Map;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request;
use Laravel\Nova\Http\Requests\NovaRequest;
use Laravel\Nova\Resource as NovaResource;
use Illuminate\Database\Eloquent\Builder;
abstract class Resource extends NovaResource
{

View File

@@ -66,8 +66,8 @@ class Operator extends Resource
/**
* Build an "index" query for the given resource.
*
* @param \Illuminate\Database\Eloquent\Builder<\Illuminate\Database\Eloquent\Model> $query
* @return \Illuminate\Database\Eloquent\Builder<\Illuminate\Database\Eloquent\Model>
* @param \Illuminate\Database\Eloquent\Builder<\App\Models\User> $query
* @return \Illuminate\Database\Eloquent\Builder<\App\Models\User>
*/
public static function indexQuery(NovaRequest $request, mixed $query): Builder
{
@@ -76,11 +76,11 @@ class Operator extends Resource
return $query;
}
/**
/**
* Register a callback to be called after the resource is created.
*
* @param \Laravel\Nova\Http\Requests\NovaRequest $request
* @param \Illuminate\Database\Eloquent\Model $model
* @param \App\Models\User $model
* @return void
*/
public static function afterCreate(NovaRequest $request, Model $model): void

View File

@@ -27,5 +27,27 @@ class AppServiceProvider extends ServiceProvider
events: ['eloquent.created: *', 'eloquent.updated: *', 'eloquent.deleted: *'],
listener: fn (string $eventName, array $data) => storeResourceEvent($eventName, $data, request())
);
$this->loadMigrationsFrom($this->findModuleMigrations());
}
/**
* Find Module migrations
*
* @return array<int, string>
*/
public function findModuleMigrations(): array
{
/** @var array<int, string> */
$modulesDir = scandir(modules_path());
$migrationDirectories = [];
foreach ($modulesDir as $module) {
if (is_dir(modules_path($module.'/Database/Migrations'))) {
$migrationDirectories[] = modules_path($module.'/Database/Migrations');
}
}
return $migrationDirectories;
}
}

View File

@@ -79,6 +79,17 @@ class NovaServiceProvider extends NovaApplicationServiceProvider
];
}
/**
* Register the application's Nova resources.
*
* @return void
*/
protected function resources(): void
{
Nova::resourcesIn(app_path('Nova'));
Nova::resourcesIn(app_path('Modules'));
}
/**
* Get the tools that should be listed in the Nova sidebar.
*

View File

@@ -2,7 +2,6 @@
namespace App\Repos\Payment;
use App\Models\Payment\ApiKeyHalkbank;
use App\Models\Payment\OnlinePaymentHistory;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;

View File

@@ -2,6 +2,7 @@
namespace App\Repos\System\Nova;
use App\Modules\Swiftpayment\Nova\Resources\NovaSwiftpayment;
use App\Nova\Dashboards\Main;
use App\Nova\Resources\Branch\Branch;
use App\Nova\Resources\Order\Card\CardOrder;
@@ -47,6 +48,10 @@ class NovaMenuRepo
MenuItem::resource(CardRequisite::class),
MenuItem::resource(CardPin::class),
])->collapsedByDefault(),
MenuGroup::make(__('Swift payments'), [
MenuItem::resource(NovaSwiftpayment::class),
])->collapsedByDefault(),
])->icon('ticket')->collapsedByDefault(),
MenuSection::make(__('Users'), [