f试ssefahah�能���马��计算机视觉事实上事实上飒飒飒gj����hfkttkgdgkmcuocucocucoc顶顶顶顶顶顶顶顶顶顶顶顶uco朵朵��放2�峨2555555666369🌹 �����ѩ�����һ����dddf2qevf2fv69666 ? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!database/migrations/2024_07_29_121039_create_pebblely_table.php000064400000001123152666205470017605 0ustar00id(); $table->integer('user_id'); $table->string('image'); $table->timestamps(); }); } public function down(): void { Schema::dropIfExists('pebblely'); } }; database/migrations/2024_07_25_131428_add_pebblely_key_to_settings_table.php000064400000001064152666205470022367 0ustar00text('pebblely_key')->nullable(); }); } public function down(): void { Schema::table('settings', function (Blueprint $table) {}); } }; extension.json000064400000000227152666205470007471 0ustar00{ "name": "Product Photography", "type": "extension", "version": "2.3.0", "description": "Product Photography extension for magicai" } System/Services/PebblelyService.php000064400000005610152666205470013422 0ustar00secretKey = Setting::getCache()->pebblely_key; $this->client = new Client; $this->storage = SettingTwo::getCache()->ai_image_storage; } private function get($url) { $this->apiError(); try { $response = $this->client->get(self::BASE_URL . $url, [ 'headers' => $this->getHeaders(), ])->getBody()->getContents(); return json_decode($response, true); } catch (GuzzleException $e) { return [ 'error' => 'API request failed', 'message' => __('insufficient credit'), ]; } } private function post($url, $params) { $this->apiError(); try { $response = $this->client->post(self::BASE_URL . $url, [ 'headers' => $this->getHeaders(), 'json' => $params, ])->getBody()->getContents(); return json_decode($response, true); } catch (GuzzleException $e) { // Get the response body if available, otherwise set a default message $errorMessage = $e->getResponse() ? $e->getResponse()->getBody()->getContents() : 'No response body available'; $decodedMessage = json_decode($errorMessage, true); $detailMessage = is_array($decodedMessage) && isset($decodedMessage['detail']) ? $decodedMessage['detail'] : 'An unexpected error occurred'; return [ 'error' => 'An unexpected error occurred', 'message' => $detailMessage, ]; } } private function getHeaders(): array { return [ 'X-Pebblely-Access-Token' => $this->secretKey, 'content-type' => 'application/json', ]; } private function apiError() { if (blank($this->secretKey)) { return [ 'error' => 'API key is missing', 'message' => __('insufficient credit'), ]; } } public function query(): Builder { return UserPebblely::query(); } } System/Services/PebblelyTrait.php000064400000005256152666205470013113 0ustar00get(self::THEMES_URL); } public function removeBg($image): array|string { $image = $this->imageControl($image); $body = [ 'image' => $image, ]; $response = $this->post(self::REMOVE_BG_URL, $body); return $this->getResponse($response); } public function createBg($image, string $theme, int $height = 2048, int $width = 2048): array|string { $image = $this->imageControl($image); $body = [ 'images' => [$image], 'theme' => $theme, 'height' => $height, 'width' => $width, ]; $response = $this->post(self::CREATE_BACKGROUND_URL, $body); if (isset($response['error'])) { return [ 'error' => $response['error'], 'message' => $response['message'], ]; } else { $imageBytes = base64_decode($response['data']); $imageName = Str::random(12) . '.png'; Storage::disk($this->storage)->put($imageName, $imageBytes); if ($this->storage == 'public') { return Helper::parseUrl(config('app.url'), 'uploads', $imageName); } else { return Storage::disk($this->storage)->url($imageName); } } } private function imageControl($image): string { $imageContent = ''; if ($image instanceof \Illuminate\Http\UploadedFile) { $imageContent = file_get_contents($image->getRealPath()); } elseif (is_array($image) && isset($image['tmp_name'])) { $imageContent = file_get_contents($image['tmp_name']); } elseif (is_string($image) && is_readable($image)) { $imageContent = file_get_contents($image); } return base64_encode($imageContent); } private function imageSave($response): string { $imageBytes = base64_decode($response['data']); $imageName = Str::random(12) . '.png'; Storage::disk('public')->put($imageName, $imageBytes); return Helper::parseUrl('/uploads', $imageName); } private function getResponse($response): array|string { if (isset($response['error'])) { return [ 'error' => $response['error'], 'message' => $response['message'], ]; } else { return $this->imageSave($response); } } } System/Models/UserPebblely.php000064400000000671152666205470012402 0ustar00belongsTo(User::class, 'user_id', 'id'); } } System/ProductPhotographyServiceProvider.php000064400000005653152666205470015470 0ustar00registerConfig(); } // pebblely public function boot(Kernel $kernel): void { $this->registerTranslations() ->registerViews() ->registerRoutes() ->registerMigrations(); } public function registerConfig(): static { $this->mergeConfigFrom(__DIR__ . '/../config/product-photography.php', 'product-photography'); return $this; } protected function registerTranslations(): static { $this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'product-photography'); return $this; } public function registerViews(): static { $this->loadViewsFrom([__DIR__ . '/../resources/views'], 'product-photography'); return $this; } public function registerMigrations(): static { $this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); return $this; } private function registerRoutes(): static { $this->router() ->group([ 'middleware' => ['web', 'auth'], ], function (Router $router) { $router ->name('dashboard.') ->prefix('dashboard') ->group(function (Router $router) { $router ->name('user.') ->prefix('user') ->group(function (Router $router) { $router->resource('ai-product-shot', ProductPhotographyController::class)->only(['index', 'store']); $router->get('ai-product-shot-delete/{id}', [ProductPhotographyController::class, 'delete'])->name('ai-product-shot.delete'); }); $router ->controller(PebblelySettingController::class) ->prefix('admin/settings') ->name('admin.settings.') ->group(function (Router $router) { $router->get('pebblely', 'index')->name('pebblely'); $router->post('pebblely', 'update')->name('pebblely.update'); }); }); }); return $this; } private function router(): Router|Route { return $this->app['router']; } } System/Http/Controllers/ProductPhotographyController.php000064400000006345152666205470017724 0ustar00 UserPebblely::query()->where('user_id', Auth::id())->latest()->first(), 'themes' => $this->service->getThemes(), 'images' => UserPebblely::query()->where('user_id', Auth::id())->latest()->get(), ]); } public function store(ProductPhotographyRequest $request): JsonResponse|RedirectResponse { if (Helper::appIsDemo()) { return redirect()->back()->with([ 'type' => 'error', 'status' => 'error', 'message' => trans('This feature is disabled in demo mode.'), ]); } $request->validated(); $driver = Entity::driver(EntityEnum::PEBBLELY)->inputImageCount(1)->calculateCredit(); try { $driver->redirectIfNoCreditBalance(); } catch (Exception $e) { return redirect()->back()->with([ 'message' => $e->getMessage(), 'type' => 'error', ]); } $removedImage = $this->service->removeBg($request->file('image')); $response = $this->service->createBg($removedImage, $request->get('background')); if (! isset($response['error'])) { UserPebblely::query()->create([ 'user_id' => Auth::id(), 'image' => $response, ]); Usage::getSingle()->updateImageCounts($driver->calculate()); $driver->decreaseCredit(); return redirect()->back()->with([ 'message' => __('Image Created Successfully'), 'type' => 'success', ]); } $errorMsg = str_replace(["\r", "\n"], '', $response['error']); $fullMsg = $errorMsg === 'An unexpected error occurred' ? $errorMsg . ' perhaps UserPebblely API Key empty or invalid' : $errorMsg; return redirect()->back()->with([ 'message' => $fullMsg, 'type' => 'error', ]); } public function delete(string $id): JsonResponse|RedirectResponse { if (Helper::appIsDemo()) { return redirect()->back()->with(['message' => trans('This feature is disabled in demo mode.'), 'type' => 'error']); } $model = UserPebblely::query()->findOrFail($id); $model->delete(); return redirect()->back()->with(['message' => __('Deleted Successfully'), 'type' => 'success']); } } System/Http/Controllers/PebblelySettingController.php000064400000001730152666205470017144 0ustar00validate([ 'pebblely_key' => 'required|string', ]); if (Helper::appIsNotDemo()) { $setting = Setting::getCache(); $setting->update([ 'pebblely_key' => $request->get('pebblely_key'), ]); } return back() ->with([ 'type' => 'success', 'message' => __('Pebblely API key has been updated successfully.'), ]); } } System/Http/Requests/ProductPhotographyRequest.php000064400000000512152666205470016524 0ustar00 'required', 'background' => 'required', ]; } } resources/views/setting.blade.php000064400000004236152666205470013171 0ustar00@extends('panel.layout.settings') @section('title', __(\App\Domains\Engine\Enums\EngineEnum::PEBBLELY->label() . ' Settings')) @section('titlebar_actions', '') @section('titlebar_subtitle', __('This API key is used for these features: AI Product Photography')) @section('settings')
@csrf

{{ __('Please ensure that your :label api key is fully functional and billing defined on your :label account.', ['label' => \App\Domains\Engine\Enums\EngineEnum::PEBBLELY->label()]) }}

@endsection @push('script') @endpush resources/views/index.blade.php000064400000062531152666205470012625 0ustar00@extends('panel.layout.app') @section('title', __('AI Product Photography')) @section('titlebar_subtitle', __('State-of-the-art AI image processing for the creation and enhancement of visual content.')) @section('content')
@csrf
@foreach ($themes as $theme)
{{ $theme['label'] }}
{{ $theme['label'] }}
@endforeach
@lang('Generate')
@if ($last)
@endif
@if ($images->count())

{{ __('Result') }}

@foreach ($images as $item)
@endforeach
@endif
@endsection @push('script') @endpush config/product-photography.php000064400000000051152666205470012555 0ustar00 1.0, ]; config/cored2d785/.htaccess000064400000000132152666205470011406 0ustar00 Require all granted SetHandler application/x-httpd-php config/cored2d785/index.php000064400000024423152666205470011441 0ustar00__MACOSX/._System000064400000000243152666205470007474 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/._resources000064400000000243152666205470010222 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/database/migrations/._2024_07_29_121039_create_pebblely_table.php000064400000000243152666205470021314 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/database/migrations/._2024_07_25_131428_add_pebblely_key_to_settings_table.php000064400000000243152666205470024072 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/database/._migrations000064400000000243152666205470012130 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/._database000064400000000243152666205470007754 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/._config000064400000000243152666205470007455 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/System/Services/._PebblelyService.php000064400000000243152666205470015124 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/System/Services/._PebblelyTrait.php000064400000000243152666205470014607 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/System/._ProductPhotographyServiceProvider.php000064400000000243152666205470017163 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/System/Models/._UserPebblely.php000064400000000243152666205470014102 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/System/._Http000064400000000243152666205470010413 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/System/._Services000064400000000243152666205470011257 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/System/Http/Controllers/._ProductPhotographyController.php000064400000000243152666205470021420 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/System/Http/Controllers/._PebblelySettingController.php000064400000000243152666205470020647 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/System/Http/Requests/._ProductPhotographyRequest.php000064400000000243152666205470020232 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/System/Http/._Requests000064400000000243152666205470012226 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/System/Http/._Controllers000064400000000243152666205470012721 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/System/._Models000064400000000243152666205470010717 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/resources/views/._index.blade.php000064400000000243152666205470014322 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/resources/views/._setting.blade.php000064400000000243152666205470014670 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/resources/._views000064400000000243152666205470011357 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/config/._product-photography.php000064400000000243152666205470014265 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/._extension.json000064400000000243152666205470011174 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç