多🌹444收拾收拾计算机视觉手机手机手机手机4大尺寸惆怅长岑长 ??????????????????????????С??????????????P??????????????????????????????????????????????????????^?????????? ????j?????????? ? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!database/migrations/2025_09_08_072943_create_ai_music_pro_table.php000064400000001734152666205370020500 0ustar00id(); $table->unsignedBigInteger('user_id')->index(); $table->string('file_path')->nullable(); $table->string('workbook_title'); $table->text('ai_music_prompt'); $table->integer('duration')->nullable(); $table->string('music_style')->nullable(); $table->timestamps(); // foreign key to users table $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); }); } /** * Reverse the migrations. */ public function down(): void { Schema::dropIfExists('ai_music_pro'); } }; database/migrations/2025_09_08_072943_add_music_slug_to_free_items.php000064400000001253152666205370021217 0ustar00free_open_ai_items; if (is_array($freeOpenAiItems) && ! in_array($slug, $freeOpenAiItems)) { $freeOpenAiItems[] = $slug; $settings->free_open_ai_items = $freeOpenAiItems; $settings->save(); Setting::forgetCache(); } } /** * Reverse the migrations. */ public function down(): void {} }; extension.json000064400000000205152666205370007464 0ustar00{ "name": "AiMusicPro", "type": "extension", "version": "1.1.0", "description": "AiMusicPro extension for magicai" } System/AiMusicProServiceProvider.php000064400000007410152666205370013626 0ustar00 * * @note When you create a new service provider, make sure to add it to the "MarketplaceServiceProvider". Otherwise, your Laravel application won’t recognize this provider, and the related functions won’t work properly. * @note If you want to perform a specific action when an extension is uninstalled, you can use the UninstallExtensionServiceProviderInterface. By implementing this interface, you can define custom operations that will be triggered during the uninstallation of the extension. * @note The registerKey() method is used to provide a unique identifier for the extension, which is essential for the healthy check and other functionalities. */ class AiMusicProServiceProvider extends ServiceProvider implements ExtensionRegisterKeyProviderInterface, UninstallExtensionServiceProviderInterface { public function register(): void { $this->registerConfig(); } public function boot(Kernel $kernel): void { $this->registerTranslations() ->registerViews() ->registerRoutes() ->registerMigrations() ->publishAssets() ->registerComponents(); } public function registerComponents(): static { // $this->loadViewComponentsAs('ai-music-pro', []); return $this; } public function publishAssets(): static { $this->publishes([ // __DIR__ . '/../resources/assets/js' => public_path('vendor/ai-music-pro/js'), // __DIR__ . '/../resources/assets/images' => public_path('vendor/ai-music-pro/images'), ], 'extension'); return $this; } public function registerConfig(): static { $this->mergeConfigFrom(__DIR__ . '/../config/aimusicpro.php', 'ai-music-pro'); return $this; } protected function registerTranslations(): static { $this->loadTranslationsFrom(__DIR__ . '/../resources/lang', 'ai-music-pro'); return $this; } public function registerViews(): static { $this->loadViewsFrom([__DIR__ . '/../resources/views'], 'ai-music-pro'); return $this; } public function registerMigrations(): static { $this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); return $this; } private function registerRoutes(): static { $this->router() ->group([ 'middleware' => ['web', 'auth'], 'prefix' => 'dashboard/user/ai-music-pro/', 'as' => 'dashboard.user.ai-music-pro.', 'controller' => AiMusicProController::class, ], function (Router $router) { $router->get('/', 'index')->name('index')->middleware(CheckTemplateTypeAndPlan::class); $router->post('/generate', 'generate')->name('generate'); $router->get('/delete/{id}', 'delete')->name('delete'); }); return $this; } private function router(): Router|Route { return $this->app['router']; } public static function uninstall(): void { // TODO: Implement uninstall() method. } public function registerKey(): string { return 'ai-music-pro'; } } System/Models/AiMusicPro.php000064400000000646152666205370012021 0ustar00id())->orderBy('id', 'desc')->paginate(10); return view('ai-music-pro::index', compact('music')); } public function generate(Request $request): JsonResponse { $request->validate([ 'workbook_title' => 'required|string|max:190', 'ai_music_prompt' => 'required|string|max:2000', 'duration' => 'nullable|integer|min:10|max:300', 'music_style' => 'nullable|string|max:190', ]); $isDemo = Helper::appIsDemo(); // --- DEMO MODE CHECK (BEFORE GENERATION) --- if ($isDemo) { $duration = (int) $request->get('duration', 30); // Assume 30 seconds if not specified $chkLmt = Helper::checkDemoSecondDailyLimit($duration); if ($chkLmt->getStatusCode() === 429) { return response()->json(['message' => $chkLmt->getData()->message, 'type' => 'error']); } } $driver = Entity::driver(EntityEnum::ELEVENLABS_AI_MUSIC)->inputMinute(1)->calculateCredit(); try { $driver->redirectIfNoCreditBalance(); } catch (Exception $e) { return response()->json(['message' => $e->getMessage(), 'type' => 'error']); } $param = [ 'prompt' => $request->get('ai_music_prompt', ''), 'model_id' => 'music_v1', ]; if ($request->filled('duration')) { $param['music_length_ms'] = $request->get('duration') * 1000; } if ($request->filled('music_style')) { $param['prompt'] .= ', in the style of ' . $request->get('music_style'); } $elevenlabsService = new PackageElevenlabsService(ApiHelper::setElevenlabsKey()); $response = $elevenlabsService->AiMusicModel()->submit($param); $fileUrl = $response->getData(true)['file_url'] ?? null; if (empty($fileUrl)) { return response()->json(['message' => __('Failed to generate music. Please try again.'), 'type' => 'error']); } $uploadsPath = public_path('uploads/' . $fileUrl); if ($request->filled('duration')) { $voiceLengthMinutes = $request->get('duration') / 60; } else { $voiceLengthMinutes = measureVoiceLength($uploadsPath); } $driver->inputMinute($voiceLengthMinutes)->calculateCredit()->decreaseCredit(); $this->storeMusicRecord( $fileUrl, $param, $request->get('workbook_title', 'Song Title'), $voiceLengthMinutes ); // --- DEMO MODE: RECORD USED TIME (AFTER GENERATION) --- if ($isDemo) { $clientIp = Helper::getRequestIp(); $cacheKey = "demo_ai_usage_seconds_{$clientIp}"; $usedSeconds = Cache::get($cacheKey, 0); $newTotal = $usedSeconds + ($voiceLengthMinutes * 60); // Convert minutes to seconds Cache::put($cacheKey, $newTotal, now()->endOfDay()); } $music = AiMusicPro::where('user_id', auth()->id())->orderBy('id', 'desc')->paginate(10); $html2 = view('ai-music-pro::components.generator_sidebar_table', compact('music'))->render(); return response()->json([ 'status' => 'success', 'message' => __('Music generated successfully!'), 'html2' => $html2, ]); } private function storeMusicRecord($fileUrl, $param, $title, $voiceLengthMinutes): void { $voiceLengthSeconds = null; if ($voiceLengthMinutes !== null) { $voiceLengthSeconds = $voiceLengthMinutes / 60; } elseif (! empty($param['music_length_ms'])) { $voiceLengthSeconds = $param['music_length_ms'] / 1000; } $data = [ 'user_id' => auth()->id(), 'file_path' => $fileUrl ?? null, 'workbook_title' => $title, 'ai_music_prompt' => $param['prompt'] ?? null, 'duration' => $voiceLengthSeconds, 'music_style' => $param['music_style'] ?? null, ]; AiMusicPro::create($data); } public function delete($id): RedirectResponse { $music = AiMusicPro::where('user_id', auth()->id())->where('id', $id)->firstOrFail(); try { if (file_exists(public_path('uploads/' . $music->file_path))) { @unlink(public_path('uploads/' . $music->file_path)); } $music->delete(); return redirect()->back()->with(['message' => __('Music deleted successfully!'), 'type' => 'success']); } catch (Exception $e) { return redirect()->back()->with(['message' => __('Failed to delete music. Please try again.'), 'type' => 'error']); } } } System/Http/Requests/.gitkeep000064400000000016152666205370012224 0ustar00* !.gitignore System/Http/Resources/.gitkeep000064400000000016152666205370012363 0ustar00* !.gitignore resources/views/index.blade.php000064400000017360152666205370012624 0ustar00@php $ai_music_options = [ 'duration' => [ '' => __('None'), '30' => '30 ' . __('seconds'), '60' => '1 ' . __('minute'), '120' => '2 ' . __('minutes'), '180' => '3 ' . __('minutes'), ], 'music_style' => [ '' => __('None'), 'techno' => 'Techno', 'lofi' => 'Lo-Fi', 'pop' => 'Pop', 'jazz' => 'Jazz', 'rock' => 'Rock', 'classical' => 'Classical', 'hiphop' => 'Hip-Hop/Trap', 'edm' => 'EDM/House', 'reggae' => 'Reggae', 'ambient' => 'Ambient', 'cozy' => 'Cozy', 'relaxed' => 'Relaxed', ] ]; @endphp @extends('panel.layout.app', ['disable_tblr' => true]) @section('title', __('AI Music Pro')) @section('titlebar_subtitle', __('Create music tracks with AI')) @section('content')

{{ __('Describe your song') }}
{{ __('Advanced Settings') }}
{{ __('Generate') }}
@include('ai-music-pro::components.generator_sidebar_table', ['music' => $music])
@endsection @push('script') @endpush resources/views/components/generator_sidebar_table.blade.php000064400000011442152666205370020523 0ustar00 {{ __('File') }} {{ __('Info') }} {{ __('Play') }} {{ __('Action') }} @forelse ($music ?? [] as $song) {{ $song->workbook_title }} {{ $song->created_at->format('M d, Y') }} {{-- --}} {{-- {{$song->duration ?? 0}} {{ __('seconds') }}--}} {{-- --}}
0:00 @empty {{ __('No entries created yet.') }} @endforelse
{{ $music->links('pagination::bootstrap-5-alt') }}
config/aimusicpro.php000064400000000051152666205370010705 0ustar00 1.0, ]; __MACOSX/._System000064400000000243152666205370007473 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/._resources000064400000000243152666205370010221 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/database/migrations/._2025_09_08_072943_add_music_slug_to_free_items.php000064400000000243152666205370022722 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/database/migrations/._2025_09_08_072943_create_ai_music_pro_table.php000064400000000243152666205370022177 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/database/._migrations000064400000000243152666205370012127 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/._database000064400000000243152666205370007753 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/._config000064400000000243152666205370007454 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/System/Models/._AiMusicPro.php000064400000000243152666205370013517 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/System/._AiMusicProServiceProvider.php000064400000000243152666205370015330 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/System/._Http000064400000000243152666205370010412 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/System/Http/Controllers/._AiMusicProController.php000064400000000243152666205370017565 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/System/Http/Requests/._.gitkeep000064400000000243152666205370013733 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/System/Http/._Requests000064400000000243152666205370012225 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/System/Http/._Resources000064400000000243152666205370012364 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/System/Http/._Controllers000064400000000243152666205370012720 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/System/Http/Resources/._.gitkeep000064400000000243152666205370014072 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/System/._Models000064400000000243152666205370010716 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/resources/views/._index.blade.php000064400000000243152666205370014321 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/resources/views/components/._generator_sidebar_table.blade.php000064400000000243152666205370022225 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/resources/views/._components000064400000000243152666205370013543 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/resources/._views000064400000000243152666205370011356 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/config/._aimusicpro.php000064400000000243152666205370012415 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç__MACOSX/._extension.json000064400000000243152666205370011173 0ustar00Mac OS X  2q£ATTR£˜ ˜ com.apple.provenance¤`˜†TÜç