From a5978835d0218ecd5f988fdccd75b3b823f0f9a4 Mon Sep 17 00:00:00 2001 From: Nurmuhammet Allanov Date: Sun, 1 Sep 2024 17:06:49 +0500 Subject: [PATCH] add swiftpayments from old source --- app/Console/Commands/MakeModule.php | 258 +++++++ .../stubs/make-module/controller.stub | 49 ++ .../Commands/stubs/make-module/migration.stub | 27 + .../Commands/stubs/make-module/model.stub | 11 + .../stubs/make-module/nova-resource.stub | 74 ++ .../stubs/make-module/repository.stub | 33 + app/Helpers/helpers.php | 26 + app/Http/Controllers/Auth/LoginController.php | 1 - .../Controllers/Auth/RegisterController.php | 2 +- ...8_31_151813_create_swiftpayments_table.php | 46 ++ .../Swiftpayment/Models/ApplicationTypes.php | 69 ++ .../Models/SwiftPaymentStatus.php | 49 ++ .../Swiftpayment/Models/Swiftpayment.php | 55 ++ .../Nova/Resources/NovaSwiftpayment.php | 185 +++++ .../Repositories/SwiftpaymentRepository.php | 32 + app/Nova/Resource.php | 3 +- app/Nova/User/Operator.php | 8 +- app/Providers/AppServiceProvider.php | 22 + app/Providers/NovaServiceProvider.php | 11 + app/Repos/Payment/OnlinePaymentRepo.php | 1 - app/Repos/System/Nova/NovaMenuRepo.php | 5 + composer.json | 4 +- composer.lock | 675 ++++++++++++++---- config/backup.php | 2 - config/media-library.php | 280 ++++++++ .../2024_08_31_171404_create_media_table.php | 32 + lang/tk.json | 3 +- 27 files changed, 1822 insertions(+), 141 deletions(-) create mode 100644 app/Console/Commands/MakeModule.php create mode 100644 app/Console/Commands/stubs/make-module/controller.stub create mode 100755 app/Console/Commands/stubs/make-module/migration.stub create mode 100644 app/Console/Commands/stubs/make-module/model.stub create mode 100644 app/Console/Commands/stubs/make-module/nova-resource.stub create mode 100644 app/Console/Commands/stubs/make-module/repository.stub create mode 100644 app/Modules/Swiftpayment/Database/Migrations/2024_08_31_151813_create_swiftpayments_table.php create mode 100644 app/Modules/Swiftpayment/Models/ApplicationTypes.php create mode 100644 app/Modules/Swiftpayment/Models/SwiftPaymentStatus.php create mode 100644 app/Modules/Swiftpayment/Models/Swiftpayment.php create mode 100644 app/Modules/Swiftpayment/Nova/Resources/NovaSwiftpayment.php create mode 100644 app/Modules/Swiftpayment/Repositories/SwiftpaymentRepository.php create mode 100644 config/media-library.php create mode 100644 database/migrations/2024_08_31_171404_create_media_table.php diff --git a/app/Console/Commands/MakeModule.php b/app/Console/Commands/MakeModule.php new file mode 100644 index 0000000..ff641da --- /dev/null +++ b/app/Console/Commands/MakeModule.php @@ -0,0 +1,258 @@ +> + */ + 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 $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 $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; + } +} diff --git a/app/Console/Commands/stubs/make-module/controller.stub b/app/Console/Commands/stubs/make-module/controller.stub new file mode 100644 index 0000000..d176162 --- /dev/null +++ b/app/Console/Commands/stubs/make-module/controller.stub @@ -0,0 +1,49 @@ +id(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('{{ table }}'); + } +}; diff --git a/app/Console/Commands/stubs/make-module/model.stub b/app/Console/Commands/stubs/make-module/model.stub new file mode 100644 index 0000000..00d7909 --- /dev/null +++ b/app/Console/Commands/stubs/make-module/model.stub @@ -0,0 +1,11 @@ + + */ +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 + */ + public static $search = [ + 'id', + ]; + + /** + * The relationships that should be eager loaded on index queries. + * + * @var array + */ + // 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 + */ + public function fields(NovaRequest $request): array + { + return [ + ID::make('id')->sortable(), + ]; + } +} diff --git a/app/Console/Commands/stubs/make-module/repository.stub b/app/Console/Commands/stubs/make-module/repository.stub new file mode 100644 index 0000000..fe8506a --- /dev/null +++ b/app/Console/Commands/stubs/make-module/repository.stub @@ -0,0 +1,33 @@ + + */ + protected Builder $queryBuilder; + + /** + * Model + */ + public static function model(): string + { + return $MODULE_NAME$::class; + } + + /** + * Product repository + */ + public function __construct() + { + $this->queryBuilder = self::model()::query(); + } +} diff --git a/app/Helpers/helpers.php b/app/Helpers/helpers.php index b8914d8..3284234 100644 --- a/app/Helpers/helpers.php +++ b/app/Helpers/helpers.php @@ -8,6 +8,32 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Log; use Stevebauman\Location\Facades\Location; +/** + * Application locales + * + * @return array + */ +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 * diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index be52b27..a9c1d72 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -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 diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index ea2498b..130cf73 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -54,7 +54,7 @@ class RegisterController extends Controller sendSMSVerification($user->phone); return response()->json([ - 'url' => route('sms-verification') + 'url' => route('sms-verification'), ]); } diff --git a/app/Modules/Swiftpayment/Database/Migrations/2024_08_31_151813_create_swiftpayments_table.php b/app/Modules/Swiftpayment/Database/Migrations/2024_08_31_151813_create_swiftpayments_table.php new file mode 100644 index 0000000..fc8b562 --- /dev/null +++ b/app/Modules/Swiftpayment/Database/Migrations/2024_08_31_151813_create_swiftpayments_table.php @@ -0,0 +1,46 @@ +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 + { + // + } +}; diff --git a/app/Modules/Swiftpayment/Models/ApplicationTypes.php b/app/Modules/Swiftpayment/Models/ApplicationTypes.php new file mode 100644 index 0000000..b5e5bd4 --- /dev/null +++ b/app/Modules/Swiftpayment/Models/ApplicationTypes.php @@ -0,0 +1,69 @@ + __('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(); + } +} diff --git a/app/Modules/Swiftpayment/Models/SwiftPaymentStatus.php b/app/Modules/Swiftpayment/Models/SwiftPaymentStatus.php new file mode 100644 index 0000000..1dd9bdd --- /dev/null +++ b/app/Modules/Swiftpayment/Models/SwiftPaymentStatus.php @@ -0,0 +1,49 @@ + __('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', + ]; + } +} diff --git a/app/Modules/Swiftpayment/Models/Swiftpayment.php b/app/Modules/Swiftpayment/Models/Swiftpayment.php new file mode 100644 index 0000000..2a8a43d --- /dev/null +++ b/app/Modules/Swiftpayment/Models/Swiftpayment.php @@ -0,0 +1,55 @@ + + */ + 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); + } +} diff --git a/app/Modules/Swiftpayment/Nova/Resources/NovaSwiftpayment.php b/app/Modules/Swiftpayment/Nova/Resources/NovaSwiftpayment.php new file mode 100644 index 0000000..17da112 --- /dev/null +++ b/app/Modules/Swiftpayment/Nova/Resources/NovaSwiftpayment.php @@ -0,0 +1,185 @@ + + */ + 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 + */ + 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 + */ + 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']); + }), + ]; + } +} diff --git a/app/Modules/Swiftpayment/Repositories/SwiftpaymentRepository.php b/app/Modules/Swiftpayment/Repositories/SwiftpaymentRepository.php new file mode 100644 index 0000000..76fa3ea --- /dev/null +++ b/app/Modules/Swiftpayment/Repositories/SwiftpaymentRepository.php @@ -0,0 +1,32 @@ + + */ + protected Builder $queryBuilder; + + /** + * Model + */ + public static function model(): string + { + return Swiftpayment::class; + } + + /** + * Product repository + */ + public function __construct() + { + $this->queryBuilder = self::model()::query(); + } +} diff --git a/app/Nova/Resource.php b/app/Nova/Resource.php index 43d367e..9af3fae 100644 --- a/app/Nova/Resource.php +++ b/app/Nova/Resource.php @@ -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 { diff --git a/app/Nova/User/Operator.php b/app/Nova/User/Operator.php index e3101d9..a2c4f3e 100644 --- a/app/Nova/User/Operator.php +++ b/app/Nova/User/Operator.php @@ -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 diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index d6bce18..28d17ef 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -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 + */ + public function findModuleMigrations(): array + { + /** @var array */ + $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; } } diff --git a/app/Providers/NovaServiceProvider.php b/app/Providers/NovaServiceProvider.php index 158e4ee..bb23b9c 100644 --- a/app/Providers/NovaServiceProvider.php +++ b/app/Providers/NovaServiceProvider.php @@ -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. * diff --git a/app/Repos/Payment/OnlinePaymentRepo.php b/app/Repos/Payment/OnlinePaymentRepo.php index 7f43f00..14db7d8 100644 --- a/app/Repos/Payment/OnlinePaymentRepo.php +++ b/app/Repos/Payment/OnlinePaymentRepo.php @@ -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; diff --git a/app/Repos/System/Nova/NovaMenuRepo.php b/app/Repos/System/Nova/NovaMenuRepo.php index a61adb0..dd01ead 100644 --- a/app/Repos/System/Nova/NovaMenuRepo.php +++ b/app/Repos/System/Nova/NovaMenuRepo.php @@ -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'), [ diff --git a/composer.json b/composer.json index d43b5eb..567fed0 100644 --- a/composer.json +++ b/composer.json @@ -7,10 +7,10 @@ "require": { "php": "^8.1", "denniseilander/pulse-about-application": "^0.1.1", + "ebess/advanced-nova-media-library": "^4.2", "eolica/nova-locale-switcher": "dev-support-nova-4", "geoip2/geoip2": "~2.0", "guzzlehttp/guzzle": "^7.2", - "konsulting/nova-target": "^1.0", "laravel/framework": "^10.10", "laravel/nova": "*", "laravel/pulse": "^1.0@beta", @@ -21,8 +21,10 @@ "nurmuhammet/nova-custom-html": "^1.0", "nurmuhammet/nova-inputmask": "^1.0", "outl1ne/nova-grid": "@dev", + "outl1ne/nova-simple-repeatable": "^2.2", "outl1ne/nova-translatable": "^2.2", "spatie/laravel-backup": "^8.4", + "spatie/laravel-medialibrary": "^11.9", "spatie/laravel-permission": "^6.1", "spatie/laravel-translatable": "^6.5", "spatie/nova-backup-tool": "^5.0", diff --git a/composer.lock b/composer.lock index dd4d3a0..ea03824 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3cd540740add5d5729bbcc32e5d8ef44", + "content-hash": "62ccda866adacb31ba0f1cd5e3300ea4", "packages": [ { "name": "brick/math", @@ -264,6 +264,87 @@ ], "time": "2024-03-15T14:00:32+00:00" }, + { + "name": "composer/semver", + "version": "3.4.0", + "source": { + "type": "git", + "url": "https://github.com/composer/semver.git", + "reference": "35e8d0af4486141bc745f23a29cc2091eb624a32" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/semver/zipball/35e8d0af4486141bc745f23a29cc2091eb624a32", + "reference": "35e8d0af4486141bc745f23a29cc2091eb624a32", + "shasum": "" + }, + "require": { + "php": "^5.3.2 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.4", + "symfony/phpunit-bridge": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Semver\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nils Adermann", + "email": "naderman@naderman.de", + "homepage": "http://www.naderman.de" + }, + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + }, + { + "name": "Rob Bast", + "email": "rob.bast@gmail.com", + "homepage": "http://robbast.nl" + } + ], + "description": "Semver library that offers utilities, version constraint parsing and validation.", + "keywords": [ + "semantic", + "semver", + "validation", + "versioning" + ], + "support": { + "irc": "ircs://irc.libera.chat:6697/composer", + "issues": "https://github.com/composer/semver/issues", + "source": "https://github.com/composer/semver/tree/3.4.0" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "time": "2023-08-31T09:50:34+00:00" + }, { "name": "denniseilander/pulse-about-application", "version": "0.1.1", @@ -1029,6 +1110,54 @@ ], "time": "2023-08-10T19:36:49+00:00" }, + { + "name": "ebess/advanced-nova-media-library", + "version": "4.2", + "source": { + "type": "git", + "url": "https://github.com/ebess/advanced-nova-media-library.git", + "reference": "08b5b8827bc42dcaf53944232774914006d82adc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ebess/advanced-nova-media-library/zipball/08b5b8827bc42dcaf53944232774914006d82adc", + "reference": "08b5b8827bc42dcaf53944232774914006d82adc", + "shasum": "" + }, + "require": { + "laravel/framework": "^8.0|^9.0|^10.0|^11.0", + "laravel/nova": "^4.0", + "php": ">=7.4", + "spatie/laravel-medialibrary": "^8.0|^9.0|^10.0|^11.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Ebess\\AdvancedNovaMediaLibrary\\AdvancedNovaMediaLibraryServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Ebess\\AdvancedNovaMediaLibrary\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Laravel Nova tools for managing the Spatie media library.", + "keywords": [ + "laravel", + "nova" + ], + "support": { + "issues": "https://github.com/ebess/advanced-nova-media-library/issues", + "source": "https://github.com/ebess/advanced-nova-media-library/tree/4.2" + }, + "time": "2024-03-18T06:36:40+00:00" + }, { "name": "egulias/email-validator", "version": "4.0.2", @@ -1966,52 +2095,6 @@ ], "time": "2023-10-27T10:59:02+00:00" }, - { - "name": "konsulting/nova-target", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/konsulting/nova-target.git", - "reference": "b9922ecbc94ea68a574d8386f7e1e612d2732418" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/konsulting/nova-target/zipball/b9922ecbc94ea68a574d8386f7e1e612d2732418", - "reference": "b9922ecbc94ea68a574d8386f7e1e612d2732418", - "shasum": "" - }, - "require": { - "laravel/nova": "^4.26", - "php": "^8.0" - }, - "type": "library", - "extra": { - "laravel": { - "providers": [ - "Konsulting\\NovaTarget\\FieldServiceProvider" - ] - } - }, - "autoload": { - "psr-4": { - "Konsulting\\NovaTarget\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Target elements to hide or adjust classes in Laravel Nova resources", - "keywords": [ - "laravel", - "nova" - ], - "support": { - "issues": "https://github.com/konsulting/nova-target/issues", - "source": "https://github.com/konsulting/nova-target/tree/1.0.1" - }, - "time": "2023-07-04T11:06:03+00:00" - }, { "name": "laravel/framework", "version": "v10.48.10", @@ -3327,6 +3410,87 @@ }, "time": "2023-12-10T21:55:46+00:00" }, + { + "name": "maennchen/zipstream-php", + "version": "3.1.0", + "source": { + "type": "git", + "url": "https://github.com/maennchen/ZipStream-PHP.git", + "reference": "b8174494eda667f7d13876b4a7bfef0f62a7c0d1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/b8174494eda667f7d13876b4a7bfef0f62a7c0d1", + "reference": "b8174494eda667f7d13876b4a7bfef0f62a7c0d1", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "ext-zlib": "*", + "php-64bit": "^8.1" + }, + "require-dev": { + "ext-zip": "*", + "friendsofphp/php-cs-fixer": "^3.16", + "guzzlehttp/guzzle": "^7.5", + "mikey179/vfsstream": "^1.6", + "php-coveralls/php-coveralls": "^2.5", + "phpunit/phpunit": "^10.0", + "vimeo/psalm": "^5.0" + }, + "suggest": { + "guzzlehttp/psr7": "^2.4", + "psr/http-message": "^2.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "ZipStream\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paul Duncan", + "email": "pabs@pablotron.org" + }, + { + "name": "Jonatan Männchen", + "email": "jonatan@maennchen.ch" + }, + { + "name": "Jesse Donat", + "email": "donatj@gmail.com" + }, + { + "name": "András Kolesár", + "email": "kolesar@kolesar.hu" + } + ], + "description": "ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.", + "keywords": [ + "stream", + "zip" + ], + "support": { + "issues": "https://github.com/maennchen/ZipStream-PHP/issues", + "source": "https://github.com/maennchen/ZipStream-PHP/tree/3.1.0" + }, + "funding": [ + { + "url": "https://github.com/maennchen", + "type": "github" + }, + { + "url": "https://opencollective.com/zipstream", + "type": "open_collective" + } + ], + "time": "2023-06-21T14:59:35+00:00" + }, { "name": "maxmind-db/reader", "version": "v1.11.1", @@ -4307,6 +4471,58 @@ }, "time": "2024-01-05T13:46:10+00:00" }, + { + "name": "outl1ne/nova-simple-repeatable", + "version": "2.2.3", + "source": { + "type": "git", + "url": "https://github.com/outl1ne/nova-simple-repeatable.git", + "reference": "d5f186b2d51401905c5868fb1561f0e94f3259d0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/outl1ne/nova-simple-repeatable/zipball/d5f186b2d51401905c5868fb1561f0e94f3259d0", + "reference": "d5f186b2d51401905c5868fb1561f0e94f3259d0", + "shasum": "" + }, + "require": { + "laravel/nova": "^4.0", + "outl1ne/nova-translations-loader": "^5.0", + "php": ">=8.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Outl1ne\\NovaSimpleRepeatable\\SimpleRepeatableServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Outl1ne\\NovaSimpleRepeatable\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A Laravel Nova simple repeatable rows field.", + "keywords": [ + "Flexible", + "field", + "keyvalue", + "laravel", + "nova", + "repeatable", + "rows" + ], + "support": { + "issues": "https://github.com/outl1ne/nova-simple-repeatable/issues", + "source": "https://github.com/outl1ne/nova-simple-repeatable/tree/2.2.3" + }, + "time": "2024-02-15T13:30:24+00:00" + }, { "name": "outl1ne/nova-translatable", "version": "2.2.0", @@ -4370,6 +4586,54 @@ }, "time": "2023-06-30T09:22:48+00:00" }, + { + "name": "outl1ne/nova-translations-loader", + "version": "5.0.2", + "source": { + "type": "git", + "url": "https://github.com/outl1ne/nova-translations-loader.git", + "reference": "baa886cb7082eb0fc399c64a54b996ca8df28f8d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/outl1ne/nova-translations-loader/zipball/baa886cb7082eb0fc399c64a54b996ca8df28f8d", + "reference": "baa886cb7082eb0fc399c64a54b996ca8df28f8d", + "shasum": "" + }, + "require": { + "laravel/nova": "^4.0", + "php": ">=8.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [], + "aliases": [] + } + }, + "autoload": { + "psr-4": { + "Outl1ne\\NovaTranslationsLoader\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "This Laravel Nova package helps developers load translations into their packages.", + "keywords": [ + "laravel", + "nova", + "optimistdigital", + "outl1ne", + "translations" + ], + "support": { + "issues": "https://github.com/outl1ne/nova-translations-loader/issues", + "source": "https://github.com/outl1ne/nova-translations-loader/tree/5.0.2" + }, + "time": "2024-03-13T08:57:31+00:00" + }, { "name": "phpoption/phpoption", "version": "1.9.2", @@ -5343,6 +5607,133 @@ ], "time": "2024-04-24T14:54:13+00:00" }, + { + "name": "spatie/image", + "version": "3.7.3", + "source": { + "type": "git", + "url": "https://github.com/spatie/image.git", + "reference": "62897055045fa74efc6d1bf201c783841a679e99" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/image/zipball/62897055045fa74efc6d1bf201c783841a679e99", + "reference": "62897055045fa74efc6d1bf201c783841a679e99", + "shasum": "" + }, + "require": { + "ext-exif": "*", + "ext-json": "*", + "ext-mbstring": "*", + "php": "^8.2", + "spatie/image-optimizer": "^1.7.5", + "spatie/temporary-directory": "^2.2", + "symfony/process": "^6.4|^7.0" + }, + "require-dev": { + "ext-gd": "*", + "ext-imagick": "*", + "pestphp/pest": "^2.28", + "phpstan/phpstan": "^1.10.50", + "spatie/pest-plugin-snapshots": "^2.1", + "spatie/pixelmatch-php": "^1.0", + "spatie/ray": "^1.40.1", + "symfony/var-dumper": "^6.4|7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\Image\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "Manipulate images with an expressive API", + "homepage": "https://github.com/spatie/image", + "keywords": [ + "image", + "spatie" + ], + "support": { + "source": "https://github.com/spatie/image/tree/3.7.3" + }, + "funding": [ + { + "url": "https://spatie.be/open-source/support-us", + "type": "custom" + }, + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2024-08-06T12:32:33+00:00" + }, + { + "name": "spatie/image-optimizer", + "version": "1.7.5", + "source": { + "type": "git", + "url": "https://github.com/spatie/image-optimizer.git", + "reference": "43aff6725cd87bb78ccd8532633cfa8bdc962505" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/image-optimizer/zipball/43aff6725cd87bb78ccd8532633cfa8bdc962505", + "reference": "43aff6725cd87bb78ccd8532633cfa8bdc962505", + "shasum": "" + }, + "require": { + "ext-fileinfo": "*", + "php": "^7.3|^8.0", + "psr/log": "^1.0 | ^2.0 | ^3.0", + "symfony/process": "^4.2|^5.0|^6.0|^7.0" + }, + "require-dev": { + "pestphp/pest": "^1.21", + "phpunit/phpunit": "^8.5.21|^9.4.4", + "symfony/var-dumper": "^4.2|^5.0|^6.0|^7.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\ImageOptimizer\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "Easily optimize images using PHP", + "homepage": "https://github.com/spatie/image-optimizer", + "keywords": [ + "image-optimizer", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/image-optimizer/issues", + "source": "https://github.com/spatie/image-optimizer/tree/1.7.5" + }, + "time": "2024-05-16T08:48:33+00:00" + }, { "name": "spatie/laravel-backup", "version": "8.8.0", @@ -5442,6 +5833,115 @@ ], "time": "2024-05-02T13:09:01+00:00" }, + { + "name": "spatie/laravel-medialibrary", + "version": "11.9.0", + "source": { + "type": "git", + "url": "https://github.com/spatie/laravel-medialibrary.git", + "reference": "b103470caad6e7cd8013130e2651e637da94d4ef" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/laravel-medialibrary/zipball/b103470caad6e7cd8013130e2651e637da94d4ef", + "reference": "b103470caad6e7cd8013130e2651e637da94d4ef", + "shasum": "" + }, + "require": { + "composer/semver": "^3.4", + "ext-exif": "*", + "ext-fileinfo": "*", + "ext-json": "*", + "illuminate/bus": "^10.0|^11.0", + "illuminate/conditionable": "^10.0|^11.0", + "illuminate/console": "^10.0|^11.0", + "illuminate/database": "^10.0|^11.0", + "illuminate/pipeline": "^10.0|^11.0", + "illuminate/support": "^10.0|^11.0", + "maennchen/zipstream-php": "^3.1", + "php": "^8.2", + "spatie/image": "^3.3.2", + "spatie/laravel-package-tools": "^1.16.1", + "spatie/temporary-directory": "^2.2", + "symfony/console": "^6.4.1|^7.0" + }, + "conflict": { + "php-ffmpeg/php-ffmpeg": "<0.6.1" + }, + "require-dev": { + "aws/aws-sdk-php": "^3.293.10", + "ext-imagick": "*", + "ext-pdo_sqlite": "*", + "ext-zip": "*", + "guzzlehttp/guzzle": "^7.8.1", + "larastan/larastan": "^2.7", + "league/flysystem-aws-s3-v3": "^3.22", + "mockery/mockery": "^1.6.7", + "orchestra/testbench": "^7.0|^8.17|^9.0", + "pestphp/pest": "^2.28", + "phpstan/extension-installer": "^1.3.1", + "spatie/laravel-ray": "^1.33", + "spatie/pdf-to-image": "^2.2|^3.0", + "spatie/pest-plugin-snapshots": "^2.1" + }, + "suggest": { + "league/flysystem-aws-s3-v3": "Required to use AWS S3 file storage", + "php-ffmpeg/php-ffmpeg": "Required for generating video thumbnails", + "spatie/pdf-to-image": "Required for generating thumbnails of PDFs and SVGs" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Spatie\\MediaLibrary\\MediaLibraryServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Spatie\\MediaLibrary\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "Associate files with Eloquent models", + "homepage": "https://github.com/spatie/laravel-medialibrary", + "keywords": [ + "cms", + "conversion", + "downloads", + "images", + "laravel", + "laravel-medialibrary", + "media", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/laravel-medialibrary/issues", + "source": "https://github.com/spatie/laravel-medialibrary/tree/11.9.0" + }, + "funding": [ + { + "url": "https://spatie.be/open-source/support-us", + "type": "custom" + }, + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2024-08-22T09:20:42+00:00" + }, { "name": "spatie/laravel-package-tools", "version": "1.16.4", @@ -9043,87 +9543,6 @@ }, "time": "2023-02-15T13:05:41+00:00" }, - { - "name": "composer/semver", - "version": "3.4.0", - "source": { - "type": "git", - "url": "https://github.com/composer/semver.git", - "reference": "35e8d0af4486141bc745f23a29cc2091eb624a32" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/composer/semver/zipball/35e8d0af4486141bc745f23a29cc2091eb624a32", - "reference": "35e8d0af4486141bc745f23a29cc2091eb624a32", - "shasum": "" - }, - "require": { - "php": "^5.3.2 || ^7.0 || ^8.0" - }, - "require-dev": { - "phpstan/phpstan": "^1.4", - "symfony/phpunit-bridge": "^4.2 || ^5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "3.x-dev" - } - }, - "autoload": { - "psr-4": { - "Composer\\Semver\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nils Adermann", - "email": "naderman@naderman.de", - "homepage": "http://www.naderman.de" - }, - { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be", - "homepage": "http://seld.be" - }, - { - "name": "Rob Bast", - "email": "rob.bast@gmail.com", - "homepage": "http://robbast.nl" - } - ], - "description": "Semver library that offers utilities, version constraint parsing and validation.", - "keywords": [ - "semantic", - "semver", - "validation", - "versioning" - ], - "support": { - "irc": "ircs://irc.libera.chat:6697/composer", - "issues": "https://github.com/composer/semver/issues", - "source": "https://github.com/composer/semver/tree/3.4.0" - }, - "funding": [ - { - "url": "https://packagist.com", - "type": "custom" - }, - { - "url": "https://github.com/composer", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/composer/composer", - "type": "tidelift" - } - ], - "time": "2023-08-31T09:50:34+00:00" - }, { "name": "dragon-code/contracts", "version": "2.23.0", diff --git a/config/backup.php b/config/backup.php index 475feab..b12f1f9 100644 --- a/config/backup.php +++ b/config/backup.php @@ -1,7 +1,5 @@ [ diff --git a/config/media-library.php b/config/media-library.php new file mode 100644 index 0000000..22517c5 --- /dev/null +++ b/config/media-library.php @@ -0,0 +1,280 @@ + env('MEDIA_DISK', 'public'), + + /* + * The maximum file size of an item in bytes. + * Adding a larger file will result in an exception. + */ + 'max_file_size' => 1024 * 1024 * 10, // 10MB + + /* + * This queue connection will be used to generate derived and responsive images. + * Leave empty to use the default queue connection. + */ + 'queue_connection_name' => env('QUEUE_CONNECTION', 'sync'), + + /* + * This queue will be used to generate derived and responsive images. + * Leave empty to use the default queue. + */ + 'queue_name' => env('MEDIA_QUEUE', ''), + + /* + * By default all conversions will be performed on a queue. + */ + 'queue_conversions_by_default' => env('QUEUE_CONVERSIONS_BY_DEFAULT', true), + + /* + * Should database transactions be run after database commits? + */ + 'queue_conversions_after_database_commit' => env('QUEUE_CONVERSIONS_AFTER_DB_COMMIT', true), + + /* + * The fully qualified class name of the media model. + */ + 'media_model' => Spatie\MediaLibrary\MediaCollections\Models\Media::class, + + /* + * When enabled, media collections will be serialised using the default + * laravel model serialization behaviour. + * + * Keep this option disabled if using Media Library Pro components (https://medialibrary.pro) + */ + 'use_default_collection_serialization' => false, + + /* + * The fully qualified class name of the model used for temporary uploads. + * + * This model is only used in Media Library Pro (https://medialibrary.pro) + */ + 'temporary_upload_model' => Spatie\MediaLibraryPro\Models\TemporaryUpload::class, + + /* + * When enabled, Media Library Pro will only process temporary uploads that were uploaded + * in the same session. You can opt to disable this for stateless usage of + * the pro components. + */ + 'enable_temporary_uploads_session_affinity' => true, + + /* + * When enabled, Media Library pro will generate thumbnails for uploaded file. + */ + 'generate_thumbnails_for_temporary_uploads' => true, + + /* + * This is the class that is responsible for naming generated files. + */ + 'file_namer' => Spatie\MediaLibrary\Support\FileNamer\DefaultFileNamer::class, + + /* + * The class that contains the strategy for determining a media file's path. + */ + 'path_generator' => Spatie\MediaLibrary\Support\PathGenerator\DefaultPathGenerator::class, + + /* + * The class that contains the strategy for determining how to remove files. + */ + 'file_remover_class' => Spatie\MediaLibrary\Support\FileRemover\DefaultFileRemover::class, + + /* + * Here you can specify which path generator should be used for the given class. + */ + 'custom_path_generators' => [ + // Model::class => PathGenerator::class + // or + // 'model_morph_alias' => PathGenerator::class + ], + + /* + * When urls to files get generated, this class will be called. Use the default + * if your files are stored locally above the site root or on s3. + */ + 'url_generator' => Spatie\MediaLibrary\Support\UrlGenerator\DefaultUrlGenerator::class, + + /* + * Moves media on updating to keep path consistent. Enable it only with a custom + * PathGenerator that uses, for example, the media UUID. + */ + 'moves_media_on_update' => false, + + /* + * Whether to activate versioning when urls to files get generated. + * When activated, this attaches a ?v=xx query string to the URL. + */ + 'version_urls' => false, + + /* + * The media library will try to optimize all converted images by removing + * metadata and applying a little bit of compression. These are + * the optimizers that will be used by default. + */ + 'image_optimizers' => [ + Spatie\ImageOptimizer\Optimizers\Jpegoptim::class => [ + '-m85', // set maximum quality to 85% + '--force', // ensure that progressive generation is always done also if a little bigger + '--strip-all', // this strips out all text information such as comments and EXIF data + '--all-progressive', // this will make sure the resulting image is a progressive one + ], + Spatie\ImageOptimizer\Optimizers\Pngquant::class => [ + '--force', // required parameter for this package + ], + Spatie\ImageOptimizer\Optimizers\Optipng::class => [ + '-i0', // this will result in a non-interlaced, progressive scanned image + '-o2', // this set the optimization level to two (multiple IDAT compression trials) + '-quiet', // required parameter for this package + ], + Spatie\ImageOptimizer\Optimizers\Svgo::class => [ + '--disable=cleanupIDs', // disabling because it is known to cause troubles + ], + Spatie\ImageOptimizer\Optimizers\Gifsicle::class => [ + '-b', // required parameter for this package + '-O3', // this produces the slowest but best results + ], + Spatie\ImageOptimizer\Optimizers\Cwebp::class => [ + '-m 6', // for the slowest compression method in order to get the best compression. + '-pass 10', // for maximizing the amount of analysis pass. + '-mt', // multithreading for some speed improvements. + '-q 90', //quality factor that brings the least noticeable changes. + ], + Spatie\ImageOptimizer\Optimizers\Avifenc::class => [ + '-a cq-level=23', // constant quality level, lower values mean better quality and greater file size (0-63). + '-j all', // number of jobs (worker threads, "all" uses all available cores). + '--min 0', // min quantizer for color (0-63). + '--max 63', // max quantizer for color (0-63). + '--minalpha 0', // min quantizer for alpha (0-63). + '--maxalpha 63', // max quantizer for alpha (0-63). + '-a end-usage=q', // rate control mode set to Constant Quality mode. + '-a tune=ssim', // SSIM as tune the encoder for distortion metric. + ], + ], + + /* + * These generators will be used to create an image of media files. + */ + 'image_generators' => [ + Spatie\MediaLibrary\Conversions\ImageGenerators\Image::class, + Spatie\MediaLibrary\Conversions\ImageGenerators\Webp::class, + Spatie\MediaLibrary\Conversions\ImageGenerators\Avif::class, + Spatie\MediaLibrary\Conversions\ImageGenerators\Pdf::class, + Spatie\MediaLibrary\Conversions\ImageGenerators\Svg::class, + Spatie\MediaLibrary\Conversions\ImageGenerators\Video::class, + ], + + /* + * The path where to store temporary files while performing image conversions. + * If set to null, storage_path('media-library/temp') will be used. + */ + 'temporary_directory_path' => null, + + /* + * The engine that should perform the image conversions. + * Should be either `gd` or `imagick`. + */ + 'image_driver' => env('IMAGE_DRIVER', 'gd'), + + /* + * FFMPEG & FFProbe binaries paths, only used if you try to generate video + * thumbnails and have installed the php-ffmpeg/php-ffmpeg composer + * dependency. + */ + 'ffmpeg_path' => env('FFMPEG_PATH', '/usr/bin/ffmpeg'), + 'ffprobe_path' => env('FFPROBE_PATH', '/usr/bin/ffprobe'), + + /* + * Here you can override the class names of the jobs used by this package. Make sure + * your custom jobs extend the ones provided by the package. + */ + 'jobs' => [ + 'perform_conversions' => Spatie\MediaLibrary\Conversions\Jobs\PerformConversionsJob::class, + 'generate_responsive_images' => Spatie\MediaLibrary\ResponsiveImages\Jobs\GenerateResponsiveImagesJob::class, + ], + + /* + * When using the addMediaFromUrl method you may want to replace the default downloader. + * This is particularly useful when the url of the image is behind a firewall and + * need to add additional flags, possibly using curl. + */ + 'media_downloader' => Spatie\MediaLibrary\Downloaders\DefaultDownloader::class, + + /* + * When using the addMediaFromUrl method the SSL is verified by default. + * This is option disables SSL verification when downloading remote media. + * Please note that this is a security risk and should only be false in a local environment. + */ + 'media_downloader_ssl' => env('MEDIA_DOWNLOADER_SSL', true), + + 'remote' => [ + /* + * Any extra headers that should be included when uploading media to + * a remote disk. Even though supported headers may vary between + * different drivers, a sensible default has been provided. + * + * Supported by S3: CacheControl, Expires, StorageClass, + * ServerSideEncryption, Metadata, ACL, ContentEncoding + */ + 'extra_headers' => [ + 'CacheControl' => 'max-age=604800', + ], + ], + + 'responsive_images' => [ + /* + * This class is responsible for calculating the target widths of the responsive + * images. By default we optimize for filesize and create variations that each are 30% + * smaller than the previous one. More info in the documentation. + * + * https://docs.spatie.be/laravel-medialibrary/v9/advanced-usage/generating-responsive-images + */ + 'width_calculator' => Spatie\MediaLibrary\ResponsiveImages\WidthCalculator\FileSizeOptimizedWidthCalculator::class, + + /* + * By default rendering media to a responsive image will add some javascript and a tiny placeholder. + * This ensures that the browser can already determine the correct layout. + * When disabled, no tiny placeholder is generated. + */ + 'use_tiny_placeholders' => true, + + /* + * This class will generate the tiny placeholder used for progressive image loading. By default + * the media library will use a tiny blurred jpg image. + */ + 'tiny_placeholder_generator' => Spatie\MediaLibrary\ResponsiveImages\TinyPlaceholderGenerator\Blurred::class, + ], + + /* + * When enabling this option, a route will be registered that will enable + * the Media Library Pro Vue and React components to move uploaded files + * in a S3 bucket to their right place. + */ + 'enable_vapor_uploads' => env('ENABLE_MEDIA_LIBRARY_VAPOR_UPLOADS', false), + + /* + * When converting Media instances to response the media library will add + * a `loading` attribute to the `img` tag. Here you can set the default + * value of that attribute. + * + * Possible values: 'lazy', 'eager', 'auto' or null if you don't want to set any loading instruction. + * + * More info: https://css-tricks.com/native-lazy-loading/ + */ + 'default_loading_attribute_value' => null, + + /* + * You can specify a prefix for that is used for storing all media. + * If you set this to `/my-subdir`, all your media will be stored in a `/my-subdir` directory. + */ + 'prefix' => env('MEDIA_PREFIX', ''), + + /* + * When forcing lazy loading, media will be loaded even if you don't eager load media and you have + * disabled lazy loading globally in the service provider. + */ + 'force_lazy_loading' => env('FORCE_MEDIA_LIBRARY_LAZY_LOADING', true), +]; diff --git a/database/migrations/2024_08_31_171404_create_media_table.php b/database/migrations/2024_08_31_171404_create_media_table.php new file mode 100644 index 0000000..47a4be9 --- /dev/null +++ b/database/migrations/2024_08_31_171404_create_media_table.php @@ -0,0 +1,32 @@ +id(); + + $table->morphs('model'); + $table->uuid()->nullable()->unique(); + $table->string('collection_name'); + $table->string('name'); + $table->string('file_name'); + $table->string('mime_type')->nullable(); + $table->string('disk'); + $table->string('conversions_disk')->nullable(); + $table->unsignedBigInteger('size'); + $table->json('manipulations'); + $table->json('custom_properties'); + $table->json('generated_conversions'); + $table->json('responsive_images'); + $table->unsignedInteger('order_column')->nullable()->index(); + + $table->nullableTimestamps(); + }); + } +}; diff --git a/lang/tk.json b/lang/tk.json index 3af5b3f..08e5af2 100644 --- a/lang/tk.json +++ b/lang/tk.json @@ -283,5 +283,6 @@ "Clients": "Müşderiler", "Client": "Müşderi", "Successfully registered": "Üstünlikli hasaba alyndyňyz", - "Please, now verify your phone number to continue": "Dowam etmek üçin telefon belgiňizi tassyklaň" + "Please, now verify your phone number to continue": "Dowam etmek üçin telefon belgiňizi tassyklaň", + "Swift payments": "Swift tölegler" }