├── public ├── favicon.ico ├── robots.txt ├── cover.png ├── default.png ├── .htaccess ├── index.php └── favicon.svg ├── database ├── .gitignore ├── .DS_Store ├── seeders │ └── DatabaseSeeder.php ├── migrations │ ├── 2023_03_12_080403_create_github_webhook_calls_table.php │ ├── 2023_02_22_045409_add_polymorphic_relations_to_prompts.php │ ├── 2023_02_18_080735_create_openai_api_table.php │ ├── 2014_10_12_100000_create_password_reset_tokens_table.php │ ├── 2020_05_21_100000_create_teams_table.php │ ├── 2020_05_21_200000_create_team_user_table.php │ ├── 2020_05_21_300000_create_team_invitations_table.php │ ├── 2019_08_19_000000_create_failed_jobs_table.php │ ├── 2023_02_18_074945_create_sessions_table.php │ ├── 2019_12_14_000001_create_personal_access_tokens_table.php │ ├── 2014_10_12_000000_create_users_table.php │ └── 2014_10_12_200000_add_two_factor_columns_to_users_table.php └── factories │ ├── TeamFactory.php │ └── UserFactory.php ├── resources ├── views │ ├── vendor │ │ └── openai-api │ │ │ └── .gitkeep │ ├── app.blade.php │ └── emails │ │ └── team-invitation.blade.php ├── css │ └── app.css ├── .DS_Store ├── markdown │ ├── policy.md │ └── terms.md └── js │ ├── Components │ ├── SectionBorder.vue │ ├── InputError.vue │ ├── InputLabel.vue │ ├── AuthenticationCard.vue │ ├── ActionMessage.vue │ ├── SectionTitle.vue │ ├── DangerButton.vue │ ├── SecondaryButton.vue │ ├── PrimaryButton.vue │ ├── ActionSection.vue │ ├── TextInput.vue │ ├── Checkbox.vue │ ├── APIDocs.vue │ ├── FAQs.vue │ ├── NavLink.vue │ ├── DropdownLink.vue │ ├── DialogModal.vue │ ├── ResponsiveNavLink.vue │ ├── FormSection.vue │ ├── ApplicationMark.vue │ ├── Pricing.vue │ ├── ConfirmationModal.vue │ ├── Dropdown.vue │ ├── ApplicationLogo.vue │ ├── AuthenticationCardLogo.vue │ └── Banner.vue │ ├── Pages │ ├── Teams │ │ ├── Create.vue │ │ ├── Show.vue │ │ └── Partials │ │ │ ├── CreateTeamForm.vue │ │ │ ├── DeleteTeamForm.vue │ │ │ └── UpdateTeamNameForm.vue │ ├── FAQs.vue │ ├── Dashboard.vue │ ├── Pricing.vue │ ├── APIDocs.vue │ ├── PrivacyPolicy.vue │ ├── TermsOfService.vue │ ├── Generate.vue │ ├── API │ │ └── Index.vue │ ├── Auth │ │ ├── ForgotPassword.vue │ │ ├── ConfirmPassword.vue │ │ ├── VerifyEmail.vue │ │ └── ResetPassword.vue │ └── Profile │ │ └── Show.vue │ ├── app.js │ └── bootstrap.js ├── bootstrap ├── cache │ └── .gitignore ├── .DS_Store └── app.php ├── storage ├── logs │ └── .gitignore ├── app │ ├── public │ │ └── .gitignore │ └── .gitignore ├── framework │ ├── testing │ │ └── .gitignore │ ├── views │ │ └── .gitignore │ ├── cache │ │ ├── data │ │ │ └── .gitignore │ │ └── .gitignore │ ├── sessions │ │ └── .gitignore │ └── .gitignore └── .DS_Store ├── app ├── .DS_Store ├── Models │ ├── Membership.php │ ├── TeamInvitation.php │ ├── Team.php │ └── User.php ├── Http │ ├── Controllers │ │ └── Controller.php │ └── Middleware │ │ ├── EncryptCookies.php │ │ ├── VerifyCsrfToken.php │ │ ├── PreventRequestsDuringMaintenance.php │ │ ├── TrimStrings.php │ │ ├── TrustHosts.php │ │ ├── Authenticate.php │ │ ├── ValidateSignature.php │ │ ├── EnsureUserIsSubscribed.php │ │ ├── TrustProxies.php │ │ ├── RedirectIfAuthenticated.php │ │ └── HandleInertiaRequests.php ├── Providers │ ├── BroadcastServiceProvider.php │ ├── AppServiceProvider.php │ ├── AuthServiceProvider.php │ ├── EventServiceProvider.php │ ├── FortifyServiceProvider.php │ ├── RouteServiceProvider.php │ └── JetstreamServiceProvider.php ├── Actions │ ├── Jetstream │ │ ├── DeleteTeam.php │ │ ├── UpdateTeamName.php │ │ ├── CreateTeam.php │ │ ├── DeleteUser.php │ │ ├── RemoveTeamMember.php │ │ ├── AddTeamMember.php │ │ └── InviteTeamMember.php │ └── Fortify │ │ ├── PasswordValidationRules.php │ │ ├── ResetUserPassword.php │ │ ├── UpdateUserPassword.php │ │ ├── CreateNewUser.php │ │ └── UpdateUserProfileInformation.php ├── Console │ └── Kernel.php ├── Jobs │ └── HandlePullRequestWebhookJob.php ├── Exceptions │ └── Handler.php └── Policies │ └── TeamPolicy.php ├── docker ├── .DS_Store ├── 7.4 │ ├── php.ini │ ├── start-container │ ├── supervisord.conf │ └── Dockerfile ├── 8.0 │ ├── php.ini │ ├── start-container │ ├── supervisord.conf │ └── Dockerfile ├── 8.1 │ ├── php.ini │ ├── start-container │ ├── supervisord.conf │ └── Dockerfile └── 8.2 │ ├── php.ini │ ├── start-container │ ├── supervisord.conf │ └── Dockerfile ├── tests ├── .DS_Store ├── TestCase.php ├── Unit │ └── ExampleTest.php ├── Feature │ ├── ExampleTest.php │ ├── BrowserSessionsTest.php │ ├── CreateTeamTest.php │ ├── UpdateTeamNameTest.php │ ├── ProfileInformationTest.php │ ├── DeleteApiTokenTest.php │ ├── CreateApiTokenTest.php │ ├── LeaveTeamTest.php │ ├── DeleteTeamTest.php │ ├── AuthenticationTest.php │ ├── RemoveTeamMemberTest.php │ ├── DeleteAccountTest.php │ ├── PasswordConfirmationTest.php │ ├── ApiTokenPermissionsTest.php │ ├── UpdateTeamMemberRoleTest.php │ ├── UpdatePasswordTest.php │ ├── InviteTeamMemberTest.php │ ├── RegistrationTest.php │ ├── TwoFactorAuthenticationSettingsTest.php │ └── EmailVerificationTest.php └── CreatesApplication.php ├── postcss.config.js ├── .gitattributes ├── .editorconfig ├── .gitignore ├── vite.config.js ├── routes ├── channels.php ├── console.php └── api.php ├── package.json ├── tailwind.config.js ├── config ├── openai.php ├── cors.php ├── view.php ├── services.php ├── hashing.php ├── broadcasting.php ├── github-webhooks.php ├── sanctum.php ├── filesystems.php └── jetstream.php ├── phpunit.xml ├── .env.example ├── README.md ├── artisan └── composer.json /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite* 2 | -------------------------------------------------------------------------------- /resources/views/vendor/openai-api/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bootstrap/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /storage/app/public/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/app/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !public/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /storage/framework/testing/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/views/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/cache/data/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/sessions/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /storage/framework/cache/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !data/ 3 | !.gitignore 4 | -------------------------------------------------------------------------------- /app/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GreatHub1204/laravel-gpt-api/HEAD/app/.DS_Store -------------------------------------------------------------------------------- /resources/css/app.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | -------------------------------------------------------------------------------- /docker/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GreatHub1204/laravel-gpt-api/HEAD/docker/.DS_Store -------------------------------------------------------------------------------- /public/cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GreatHub1204/laravel-gpt-api/HEAD/public/cover.png -------------------------------------------------------------------------------- /storage/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GreatHub1204/laravel-gpt-api/HEAD/storage/.DS_Store -------------------------------------------------------------------------------- /tests/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GreatHub1204/laravel-gpt-api/HEAD/tests/.DS_Store -------------------------------------------------------------------------------- /bootstrap/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GreatHub1204/laravel-gpt-api/HEAD/bootstrap/.DS_Store -------------------------------------------------------------------------------- /database/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GreatHub1204/laravel-gpt-api/HEAD/database/.DS_Store -------------------------------------------------------------------------------- /public/default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GreatHub1204/laravel-gpt-api/HEAD/public/default.png -------------------------------------------------------------------------------- /resources/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GreatHub1204/laravel-gpt-api/HEAD/resources/.DS_Store -------------------------------------------------------------------------------- /docker/7.4/php.ini: -------------------------------------------------------------------------------- 1 | [PHP] 2 | post_max_size = 100M 3 | upload_max_filesize = 100M 4 | variables_order = EGPCS 5 | -------------------------------------------------------------------------------- /docker/8.0/php.ini: -------------------------------------------------------------------------------- 1 | [PHP] 2 | post_max_size = 100M 3 | upload_max_filesize = 100M 4 | variables_order = EGPCS 5 | -------------------------------------------------------------------------------- /docker/8.1/php.ini: -------------------------------------------------------------------------------- 1 | [PHP] 2 | post_max_size = 100M 3 | upload_max_filesize = 100M 4 | variables_order = EGPCS 5 | -------------------------------------------------------------------------------- /docker/8.2/php.ini: -------------------------------------------------------------------------------- 1 | [PHP] 2 | post_max_size = 100M 3 | upload_max_filesize = 100M 4 | variables_order = EGPCS 5 | -------------------------------------------------------------------------------- /resources/markdown/policy.md: -------------------------------------------------------------------------------- 1 | # Privacy Policy 2 | 3 | Edit this file to define the privacy policy for your application. 4 | -------------------------------------------------------------------------------- /resources/markdown/terms.md: -------------------------------------------------------------------------------- 1 | # Terms of Service 2 | 3 | Edit this file to define the terms of service for your application. 4 | -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | }; 7 | -------------------------------------------------------------------------------- /storage/framework/.gitignore: -------------------------------------------------------------------------------- 1 | compiled.php 2 | config.php 3 | down 4 | events.scanned.php 5 | maintenance.php 6 | routes.php 7 | routes.scanned.php 8 | schedule-* 9 | services.json 10 | -------------------------------------------------------------------------------- /resources/js/Components/SectionBorder.vue: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /tests/TestCase.php: -------------------------------------------------------------------------------- 1 | 2 | defineProps({ 3 | message: String, 4 | }); 5 | 6 | 7 | 14 | -------------------------------------------------------------------------------- /resources/js/Components/InputLabel.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 13 | -------------------------------------------------------------------------------- /tests/Unit/ExampleTest.php: -------------------------------------------------------------------------------- 1 | assertTrue(true); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 4 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.{yml,yaml}] 15 | indent_size = 2 16 | 17 | [docker-compose.yml] 18 | indent_size = 4 19 | -------------------------------------------------------------------------------- /app/Models/Membership.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /resources/js/Components/AuthenticationCard.vue: -------------------------------------------------------------------------------- 1 | 12 | -------------------------------------------------------------------------------- /app/Http/Middleware/VerifyCsrfToken.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /docker/7.4/supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | user=root 4 | logfile=/var/log/supervisor/supervisord.log 5 | pidfile=/var/run/supervisord.pid 6 | 7 | [program:php] 8 | command=/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan serve --host=0.0.0.0 --port=80 9 | user=sail 10 | environment=LARAVEL_SAIL="1" 11 | stdout_logfile=/dev/stdout 12 | stdout_logfile_maxbytes=0 13 | stderr_logfile=/dev/stderr 14 | stderr_logfile_maxbytes=0 15 | -------------------------------------------------------------------------------- /docker/8.0/supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | user=root 4 | logfile=/var/log/supervisor/supervisord.log 5 | pidfile=/var/run/supervisord.pid 6 | 7 | [program:php] 8 | command=/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan serve --host=0.0.0.0 --port=80 9 | user=sail 10 | environment=LARAVEL_SAIL="1" 11 | stdout_logfile=/dev/stdout 12 | stdout_logfile_maxbytes=0 13 | stderr_logfile=/dev/stderr 14 | stderr_logfile_maxbytes=0 15 | -------------------------------------------------------------------------------- /docker/8.1/supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | user=root 4 | logfile=/var/log/supervisor/supervisord.log 5 | pidfile=/var/run/supervisord.pid 6 | 7 | [program:php] 8 | command=/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan serve --host=0.0.0.0 --port=80 9 | user=sail 10 | environment=LARAVEL_SAIL="1" 11 | stdout_logfile=/dev/stdout 12 | stdout_logfile_maxbytes=0 13 | stderr_logfile=/dev/stderr 14 | stderr_logfile_maxbytes=0 15 | -------------------------------------------------------------------------------- /docker/8.2/supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | user=root 4 | logfile=/var/log/supervisor/supervisord.log 5 | pidfile=/var/run/supervisord.pid 6 | 7 | [program:php] 8 | command=/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan serve --host=0.0.0.0 --port=80 9 | user=sail 10 | environment=LARAVEL_SAIL="1" 11 | stdout_logfile=/dev/stdout 12 | stdout_logfile_maxbytes=0 13 | stderr_logfile=/dev/stderr 14 | stderr_logfile_maxbytes=0 15 | -------------------------------------------------------------------------------- /resources/js/Components/ActionMessage.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 16 | -------------------------------------------------------------------------------- /tests/Feature/ExampleTest.php: -------------------------------------------------------------------------------- 1 | get('/'); 16 | 17 | $response->assertStatus(200); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/Providers/BroadcastServiceProvider.php: -------------------------------------------------------------------------------- 1 | purge(); 16 | $team->owner->subscription('default', 'orikul-monthly-team')->decrementQuantity(1); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/Http/Middleware/PreventRequestsDuringMaintenance.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 16 | ]; 17 | } 18 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrimStrings.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | 'current_password', 16 | 'password', 17 | 'password_confirmation', 18 | ]; 19 | } 20 | -------------------------------------------------------------------------------- /tests/CreatesApplication.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class)->bootstrap(); 18 | 19 | return $app; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrustHosts.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | public function hosts(): array 15 | { 16 | return [ 17 | $this->allSubdomainsOfApplicationUrl(), 18 | ]; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected function passwordRules(): array 15 | { 16 | return ['required', 'string', new Password, 'confirmed']; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/Http/Middleware/Authenticate.php: -------------------------------------------------------------------------------- 1 | expectsJson() ? null : route('login'); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /resources/js/Components/SectionTitle.vue: -------------------------------------------------------------------------------- 1 | 18 | -------------------------------------------------------------------------------- /vite.config.js: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite'; 2 | import laravel from 'laravel-vite-plugin'; 3 | import vue from '@vitejs/plugin-vue'; 4 | 5 | export default defineConfig({ 6 | plugins: [ 7 | laravel({ 8 | input: 'resources/js/app.js', 9 | refresh: true, 10 | }), 11 | vue({ 12 | template: { 13 | transformAssetUrls: { 14 | base: null, 15 | includeAbsolute: false, 16 | }, 17 | }, 18 | }), 19 | ], 20 | }); 21 | -------------------------------------------------------------------------------- /app/Http/Middleware/ValidateSignature.php: -------------------------------------------------------------------------------- 1 | 13 | */ 14 | protected $except = [ 15 | // 'fbclid', 16 | // 'utm_campaign', 17 | // 'utm_content', 18 | // 'utm_medium', 19 | // 'utm_source', 20 | // 'utm_term', 21 | ]; 22 | } 23 | -------------------------------------------------------------------------------- /resources/js/Components/DangerButton.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 15 | -------------------------------------------------------------------------------- /resources/js/Components/SecondaryButton.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 15 | -------------------------------------------------------------------------------- /database/seeders/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | create(); 16 | 17 | // \App\Models\User::factory()->create([ 18 | // 'name' => 'Test User', 19 | // 'email' => 'test@example.com', 20 | // ]); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /resources/js/Components/PrimaryButton.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 15 | -------------------------------------------------------------------------------- /routes/channels.php: -------------------------------------------------------------------------------- 1 | id === (int) $id; 18 | }); 19 | -------------------------------------------------------------------------------- /tests/Feature/BrowserSessionsTest.php: -------------------------------------------------------------------------------- 1 | actingAs($user = User::factory()->create()); 16 | 17 | $response = $this->delete('/user/other-browser-sessions', [ 18 | 'password' => 'password', 19 | ]); 20 | 21 | $response->assertSessionHasNoErrors(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /resources/js/Pages/Teams/Create.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | 21 | -------------------------------------------------------------------------------- /routes/console.php: -------------------------------------------------------------------------------- 1 | comment(Inspiring::quote()); 19 | })->purpose('Display an inspiring quote'); 20 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "dev": "vite", 5 | "build": "vite build" 6 | }, 7 | "devDependencies": { 8 | "@inertiajs/vue3": "^1.0.0", 9 | "@tailwindcss/forms": "^0.5.2", 10 | "@tailwindcss/typography": "^0.5.2", 11 | "@vitejs/plugin-vue": "^4.0.0", 12 | "autoprefixer": "^10.4.7", 13 | "axios": "^1.1.2", 14 | "laravel-vite-plugin": "^0.7.2", 15 | "postcss": "^8.4.14", 16 | "tailwindcss": "^3.1.0", 17 | "vite": "^4.0.0", 18 | "vue": "^3.2.31" 19 | }, 20 | "dependencies": { 21 | "@mastashake08/speech-kit": "^2.0.8" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | 3 | Options -MultiViews -Indexes 4 | 5 | 6 | RewriteEngine On 7 | 8 | # Handle Authorization Header 9 | RewriteCond %{HTTP:Authorization} . 10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 11 | 12 | # Redirect Trailing Slashes If Not A Folder... 13 | RewriteCond %{REQUEST_FILENAME} !-d 14 | RewriteCond %{REQUEST_URI} (.+)/$ 15 | RewriteRule ^ %1 [L,R=301] 16 | 17 | # Send Requests To Front Controller... 18 | RewriteCond %{REQUEST_FILENAME} !-d 19 | RewriteCond %{REQUEST_FILENAME} !-f 20 | RewriteRule ^ index.php [L] 21 | 22 | -------------------------------------------------------------------------------- /app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire')->hourly(); 16 | } 17 | 18 | /** 19 | * Register the commands for the application. 20 | */ 21 | protected function commands(): void 22 | { 23 | $this->load(__DIR__.'/Commands'); 24 | 25 | require base_path('routes/console.php'); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /database/migrations/2023_03_12_080403_create_github_webhook_calls_table.php: -------------------------------------------------------------------------------- 1 | bigIncrements('id'); 12 | 13 | $table->string('url'); 14 | $table->string('name'); 15 | $table->json('headers')->nullable(); 16 | $table->json('payload')->nullable(); 17 | $table->text('exception')->nullable(); 18 | 19 | $table->timestamps(); 20 | }); 21 | } 22 | }; 23 | -------------------------------------------------------------------------------- /resources/js/Pages/FAQs.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | 23 | -------------------------------------------------------------------------------- /tests/Feature/CreateTeamTest.php: -------------------------------------------------------------------------------- 1 | actingAs($user = User::factory()->withPersonalTeam()->create()); 16 | 17 | $response = $this->post('/teams', [ 18 | 'name' => 'Test Team', 19 | ]); 20 | 21 | $this->assertCount(2, $user->fresh()->ownedTeams); 22 | $this->assertEquals('Test Team', $user->fresh()->ownedTeams()->latest('id')->first()->name); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /resources/js/Components/ActionSection.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 23 | -------------------------------------------------------------------------------- /app/Models/TeamInvitation.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | protected $fillable = [ 17 | 'email', 18 | 'role', 19 | ]; 20 | 21 | /** 22 | * Get the team that the invitation belongs to. 23 | */ 24 | public function team(): BelongsTo 25 | { 26 | return $this->belongsTo(Jetstream::teamModel()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /database/migrations/2023_02_22_045409_add_polymorphic_relations_to_prompts.php: -------------------------------------------------------------------------------- 1 | unsignedBigInteger('user_id')->nullable(); 16 | $table->string('user_type')->nullable(); 17 | }); 18 | } 19 | 20 | /** 21 | * Reverse the migrations. 22 | */ 23 | public function down(): void 24 | { 25 | 26 | } 27 | }; 28 | -------------------------------------------------------------------------------- /tests/Feature/UpdateTeamNameTest.php: -------------------------------------------------------------------------------- 1 | actingAs($user = User::factory()->withPersonalTeam()->create()); 16 | 17 | $response = $this->put('/teams/'.$user->currentTeam->id, [ 18 | 'name' => 'Test Team', 19 | ]); 20 | 21 | $this->assertCount(1, $user->fresh()->ownedTeams); 22 | $this->assertEquals('Test Team', $user->currentTeam->fresh()->name); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /resources/js/Components/TextInput.vue: -------------------------------------------------------------------------------- 1 | 20 | 21 | 29 | -------------------------------------------------------------------------------- /resources/js/Pages/Dashboard.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | 23 | -------------------------------------------------------------------------------- /resources/js/Pages/Pricing.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | 23 | -------------------------------------------------------------------------------- /app/Providers/AuthServiceProvider.php: -------------------------------------------------------------------------------- 1 | 15 | */ 16 | protected $policies = [ 17 | Team::class => TeamPolicy::class, 18 | ]; 19 | 20 | /** 21 | * Register any authentication / authorization services. 22 | */ 23 | public function boot(): void 24 | { 25 | $this->registerPolicies(); 26 | 27 | // 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /resources/js/Pages/APIDocs.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | 23 | -------------------------------------------------------------------------------- /tailwind.config.js: -------------------------------------------------------------------------------- 1 | const defaultTheme = require('tailwindcss/defaultTheme'); 2 | 3 | /** @type {import('tailwindcss').Config} */ 4 | module.exports = { 5 | content: [ 6 | './vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php', 7 | './vendor/laravel/jetstream/**/*.blade.php', 8 | './storage/framework/views/*.php', 9 | './resources/views/**/*.blade.php', 10 | './resources/js/**/*.vue', 11 | ], 12 | 13 | theme: { 14 | extend: { 15 | fontFamily: { 16 | sans: ['Figtree', ...defaultTheme.fontFamily.sans], 17 | }, 18 | }, 19 | }, 20 | 21 | plugins: [require('@tailwindcss/forms'), require('@tailwindcss/typography')], 22 | }; 23 | -------------------------------------------------------------------------------- /tests/Feature/ProfileInformationTest.php: -------------------------------------------------------------------------------- 1 | actingAs($user = User::factory()->create()); 16 | 17 | $response = $this->put('/user/profile-information', [ 18 | 'name' => 'Test Name', 19 | 'email' => 'test@example.com', 20 | ]); 21 | 22 | $this->assertEquals('Test Name', $user->fresh()->name); 23 | $this->assertEquals('test@example.com', $user->fresh()->email); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/Http/Middleware/EnsureUserIsSubscribed.php: -------------------------------------------------------------------------------- 1 | user() && ! $request->user()->subscribed('default')) { 19 | // This user is not a paying customer... 20 | 21 | return redirect(route('billing')); 22 | } 23 | 24 | return $next($request); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /database/factories/TeamFactory.php: -------------------------------------------------------------------------------- 1 | 22 | */ 23 | public function definition(): array 24 | { 25 | return [ 26 | 'name' => $this->faker->unique()->company(), 27 | 'user_id' => User::factory(), 28 | 'personal_team' => true, 29 | ]; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /routes/api.php: -------------------------------------------------------------------------------- 1 | get('/user', function (Request $request) { 20 | return $request->user(); 21 | }); 22 | 23 | 24 | Route::githubWebhooks('github/webhook'); 25 | -------------------------------------------------------------------------------- /database/migrations/2023_02_18_080735_create_openai_api_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('prompt_text'); 17 | $table->json('data'); 18 | $table->timestamps(); 19 | }); 20 | } 21 | 22 | /** 23 | * Reverse the migrations. 24 | */ 25 | public function down(): void 26 | { 27 | Schema::dropIfExists('prompts'); 28 | } 29 | }; 30 | -------------------------------------------------------------------------------- /app/Http/Middleware/TrustProxies.php: -------------------------------------------------------------------------------- 1 | |string|null 14 | */ 15 | protected $proxies; 16 | 17 | /** 18 | * The headers that should be used to detect proxies. 19 | * 20 | * @var int 21 | */ 22 | protected $headers = 23 | Request::HEADER_X_FORWARDED_FOR | 24 | Request::HEADER_X_FORWARDED_HOST | 25 | Request::HEADER_X_FORWARDED_PORT | 26 | Request::HEADER_X_FORWARDED_PROTO | 27 | Request::HEADER_X_FORWARDED_AWS_ELB; 28 | } 29 | -------------------------------------------------------------------------------- /resources/views/app.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | {{ config('app.name', 'Laravel') }} 8 | 9 | 10 | 11 | 12 | 13 | 14 | @routes 15 | @vite(['resources/js/app.js', "resources/js/Pages/{$page['component']}.vue"]) 16 | @inertiaHead 17 | 18 | 19 | @inertia 20 | 21 | 22 | -------------------------------------------------------------------------------- /resources/js/Pages/PrivacyPolicy.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 25 | -------------------------------------------------------------------------------- /resources/js/Pages/TermsOfService.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 25 | -------------------------------------------------------------------------------- /resources/js/Pages/Generate.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | 23 | -------------------------------------------------------------------------------- /resources/js/Components/Checkbox.vue: -------------------------------------------------------------------------------- 1 | 27 | 28 | 29 | 37 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_100000_create_password_reset_tokens_table.php: -------------------------------------------------------------------------------- 1 | string('email')->primary(); 16 | $table->string('token'); 17 | $table->timestamp('created_at')->nullable(); 18 | }); 19 | } 20 | 21 | /** 22 | * Reverse the migrations. 23 | */ 24 | public function down(): void 25 | { 26 | Schema::dropIfExists('password_reset_tokens'); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /resources/js/Components/APIDocs.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 23 | -------------------------------------------------------------------------------- /resources/js/Components/FAQs.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 23 | -------------------------------------------------------------------------------- /config/openai.php: -------------------------------------------------------------------------------- 1 | env('OPENAI_API_KEY'), 16 | 'organization' => env('OPENAI_ORGANIZATION'), 17 | 'api_url' => env('OPENAI_API_URL') !== null ? env('OPENAI_API_URL') : '/api/generate-result', 18 | 'use_sanctum' => env('OPENAI_USE_SANCTUM') !== null ? env('OPENAI_USE_SANCTUM') == true : false 19 | 20 | ]; 21 | -------------------------------------------------------------------------------- /database/migrations/2020_05_21_100000_create_teams_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->foreignId('user_id')->index(); 17 | $table->string('name'); 18 | $table->boolean('personal_team'); 19 | $table->timestamps(); 20 | }); 21 | } 22 | 23 | /** 24 | * Reverse the migrations. 25 | */ 26 | public function down(): void 27 | { 28 | Schema::dropIfExists('teams'); 29 | } 30 | }; 31 | -------------------------------------------------------------------------------- /app/Actions/Fortify/ResetUserPassword.php: -------------------------------------------------------------------------------- 1 | $input 18 | */ 19 | public function reset(User $user, array $input): void 20 | { 21 | Validator::make($input, [ 22 | 'password' => $this->passwordRules(), 23 | ])->validate(); 24 | 25 | $user->forceFill([ 26 | 'password' => Hash::make($input['password']), 27 | ])->save(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/Jobs/HandlePullRequestWebhookJob.php: -------------------------------------------------------------------------------- 1 | webhookCall->payload` 26 | $data = $this->webhookCall->payload; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /resources/js/app.js: -------------------------------------------------------------------------------- 1 | import './bootstrap'; 2 | import '../css/app.css'; 3 | 4 | import { createApp, h } from 'vue'; 5 | import { createInertiaApp } from '@inertiajs/vue3'; 6 | import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers'; 7 | import { ZiggyVue } from '../../vendor/tightenco/ziggy/dist/vue.m'; 8 | 9 | const appName = window.document.getElementsByTagName('title')[0]?.innerText || 'Laravel'; 10 | 11 | createInertiaApp({ 12 | title: (title) => `${title} - ${appName}`, 13 | resolve: (name) => resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue')), 14 | setup({ el, App, props, plugin }) { 15 | return createApp({ render: () => h(App, props) }) 16 | .use(plugin) 17 | .use(ZiggyVue, Ziggy) 18 | .mount(el); 19 | }, 20 | progress: { 21 | color: '#4B5563', 22 | }, 23 | }); 24 | -------------------------------------------------------------------------------- /resources/js/Components/NavLink.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 22 | -------------------------------------------------------------------------------- /app/Actions/Jetstream/UpdateTeamName.php: -------------------------------------------------------------------------------- 1 | $input 17 | */ 18 | public function update(User $user, Team $team, array $input): void 19 | { 20 | Gate::forUser($user)->authorize('update', $team); 21 | 22 | Validator::make($input, [ 23 | 'name' => ['required', 'string', 'max:255'], 24 | ])->validateWithBag('updateTeamName'); 25 | 26 | $team->forceFill([ 27 | 'name' => $input['name'], 28 | ])->save(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /database/migrations/2020_05_21_200000_create_team_user_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->foreignId('team_id'); 17 | $table->foreignId('user_id'); 18 | $table->string('role')->nullable(); 19 | $table->timestamps(); 20 | 21 | $table->unique(['team_id', 'user_id']); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | */ 28 | public function down(): void 29 | { 30 | Schema::dropIfExists('team_user'); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /app/Http/Middleware/RedirectIfAuthenticated.php: -------------------------------------------------------------------------------- 1 | check()) { 24 | return redirect(RouteServiceProvider::HOME); 25 | } 26 | } 27 | 28 | return $next($request); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /database/migrations/2020_05_21_300000_create_team_invitations_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->foreignId('team_id')->constrained()->cascadeOnDelete(); 17 | $table->string('email'); 18 | $table->string('role')->nullable(); 19 | $table->timestamps(); 20 | 21 | $table->unique(['team_id', 'email']); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | */ 28 | public function down(): void 29 | { 30 | Schema::dropIfExists('team_invitations'); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /database/migrations/2019_08_19_000000_create_failed_jobs_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('uuid')->unique(); 17 | $table->text('connection'); 18 | $table->text('queue'); 19 | $table->longText('payload'); 20 | $table->longText('exception'); 21 | $table->timestamp('failed_at')->useCurrent(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | */ 28 | public function down(): void 29 | { 30 | Schema::dropIfExists('failed_jobs'); 31 | } 32 | }; 33 | -------------------------------------------------------------------------------- /database/migrations/2023_02_18_074945_create_sessions_table.php: -------------------------------------------------------------------------------- 1 | string('id')->primary(); 16 | $table->foreignId('user_id')->nullable()->index(); 17 | $table->string('ip_address', 45)->nullable(); 18 | $table->text('user_agent')->nullable(); 19 | $table->longText('payload'); 20 | $table->integer('last_activity')->index(); 21 | }); 22 | } 23 | 24 | /** 25 | * Reverse the migrations. 26 | */ 27 | public function down(): void 28 | { 29 | Schema::dropIfExists('sessions'); 30 | } 31 | }; 32 | -------------------------------------------------------------------------------- /resources/js/Pages/API/Index.vue: -------------------------------------------------------------------------------- 1 | 11 | 12 | 31 | -------------------------------------------------------------------------------- /resources/js/Components/DropdownLink.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 25 | -------------------------------------------------------------------------------- /config/cors.php: -------------------------------------------------------------------------------- 1 | ['api/*', 'sanctum/csrf-cookie'], 19 | 20 | 'allowed_methods' => ['*'], 21 | 22 | 'allowed_origins' => ['*'], 23 | 24 | 'allowed_origins_patterns' => [], 25 | 26 | 'allowed_headers' => ['*'], 27 | 28 | 'exposed_headers' => [], 29 | 30 | 'max_age' => 0, 31 | 32 | 'supports_credentials' => false, 33 | 34 | ]; 35 | -------------------------------------------------------------------------------- /tests/Feature/DeleteApiTokenTest.php: -------------------------------------------------------------------------------- 1 | markTestSkipped('API support is not enabled.'); 19 | 20 | return; 21 | } 22 | 23 | $this->actingAs($user = User::factory()->withPersonalTeam()->create()); 24 | 25 | $token = $user->tokens()->create([ 26 | 'name' => 'Test Token', 27 | 'token' => Str::random(40), 28 | 'abilities' => ['create', 'read'], 29 | ]); 30 | 31 | $response = $this->delete('/user/api-tokens/'.$token->id); 32 | 33 | $this->assertCount(0, $user->fresh()->tokens); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /resources/views/emails/team-invitation.blade.php: -------------------------------------------------------------------------------- 1 | @component('mail::message') 2 | {{ __('You have been invited to join the :team team!', ['team' => $invitation->team->name]) }} 3 | 4 | @if (Laravel\Fortify\Features::enabled(Laravel\Fortify\Features::registration())) 5 | {{ __('If you do not have an account, you may create one by clicking the button below. After creating an account, you may click the invitation acceptance button in this email to accept the team invitation:') }} 6 | 7 | @component('mail::button', ['url' => route('register')]) 8 | {{ __('Create Account') }} 9 | @endcomponent 10 | 11 | {{ __('If you already have an account, you may accept this invitation by clicking the button below:') }} 12 | 13 | @else 14 | {{ __('You may accept this invitation by clicking the button below:') }} 15 | @endif 16 | 17 | 18 | @component('mail::button', ['url' => $acceptUrl]) 19 | {{ __('Accept Invitation') }} 20 | @endcomponent 21 | 22 | {{ __('If you did not expect to receive an invitation to this team, you may discard this email.') }} 23 | @endcomponent 24 | -------------------------------------------------------------------------------- /database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->morphs('tokenable'); 17 | $table->string('name'); 18 | $table->string('token', 64)->unique(); 19 | $table->text('abilities')->nullable(); 20 | $table->timestamp('last_used_at')->nullable(); 21 | $table->timestamp('expires_at')->nullable(); 22 | $table->timestamps(); 23 | }); 24 | } 25 | 26 | /** 27 | * Reverse the migrations. 28 | */ 29 | public function down(): void 30 | { 31 | Schema::dropIfExists('personal_access_tokens'); 32 | } 33 | }; 34 | -------------------------------------------------------------------------------- /app/Providers/EventServiceProvider.php: -------------------------------------------------------------------------------- 1 | > 16 | */ 17 | protected $listen = [ 18 | Registered::class => [ 19 | SendEmailVerificationNotification::class, 20 | ], 21 | ]; 22 | 23 | /** 24 | * Register any events for your application. 25 | */ 26 | public function boot(): void 27 | { 28 | // 29 | } 30 | 31 | /** 32 | * Determine if events and listeners should be automatically discovered. 33 | */ 34 | public function shouldDiscoverEvents(): bool 35 | { 36 | return false; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /app/Actions/Fortify/UpdateUserPassword.php: -------------------------------------------------------------------------------- 1 | $input 18 | */ 19 | public function update(User $user, array $input): void 20 | { 21 | Validator::make($input, [ 22 | 'current_password' => ['required', 'string', 'current_password:web'], 23 | 'password' => $this->passwordRules(), 24 | ], [ 25 | 'current_password.current_password' => __('The provided password does not match your current password.'), 26 | ])->validateWithBag('updatePassword'); 27 | 28 | $user->forceFill([ 29 | 'password' => Hash::make($input['password']), 30 | ])->save(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Actions/Jetstream/CreateTeam.php: -------------------------------------------------------------------------------- 1 | $input 19 | */ 20 | public function create(User $user, array $input): Team 21 | { 22 | Gate::forUser($user)->authorize('create', Jetstream::newTeamModel()); 23 | 24 | Validator::make($input, [ 25 | 'name' => ['required', 'string', 'max:255'], 26 | ])->validateWithBag('createTeam'); 27 | AddingTeam::dispatch($user); 28 | 29 | $user->switchTeam($team = $user->ownedTeams()->create([ 30 | 'name' => $input['name'], 31 | 'personal_team' => false, 32 | ])); 33 | 34 | return $team; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/Models/Team.php: -------------------------------------------------------------------------------- 1 | 19 | */ 20 | protected $casts = [ 21 | 'personal_team' => 'boolean', 22 | ]; 23 | 24 | /** 25 | * The attributes that are mass assignable. 26 | * 27 | * @var array 28 | */ 29 | protected $fillable = [ 30 | 'name', 31 | 'personal_team', 32 | ]; 33 | 34 | /** 35 | * The event map for the model. 36 | * 37 | * @var array 38 | */ 39 | protected $dispatchesEvents = [ 40 | 'created' => TeamCreated::class, 41 | 'updated' => TeamUpdated::class, 42 | 'deleted' => TeamDeleted::class, 43 | ]; 44 | } 45 | -------------------------------------------------------------------------------- /resources/js/Components/DialogModal.vue: -------------------------------------------------------------------------------- 1 | 25 | 26 | 48 | -------------------------------------------------------------------------------- /resources/js/Components/ResponsiveNavLink.vue: -------------------------------------------------------------------------------- 1 | 17 | 18 | 29 | -------------------------------------------------------------------------------- /tests/Feature/CreateApiTokenTest.php: -------------------------------------------------------------------------------- 1 | markTestSkipped('API support is not enabled.'); 18 | 19 | return; 20 | } 21 | 22 | $this->actingAs($user = User::factory()->withPersonalTeam()->create()); 23 | 24 | $response = $this->post('/user/api-tokens', [ 25 | 'name' => 'Test Token', 26 | 'permissions' => [ 27 | 'read', 28 | 'update', 29 | ], 30 | ]); 31 | 32 | $this->assertCount(1, $user->fresh()->tokens); 33 | $this->assertEquals('Test Token', $user->fresh()->tokens->first()->name); 34 | $this->assertTrue($user->fresh()->tokens->first()->can('read')); 35 | $this->assertFalse($user->fresh()->tokens->first()->can('delete')); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | ./tests/Unit 10 | 11 | 12 | ./tests/Feature 13 | 14 | 15 | 16 | 17 | ./app 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /config/view.php: -------------------------------------------------------------------------------- 1 | [ 17 | resource_path('views'), 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Compiled View Path 23 | |-------------------------------------------------------------------------- 24 | | 25 | | This option determines where all the compiled Blade templates will be 26 | | stored for your application. Typically, this is within the storage 27 | | directory. However, as usual, you are free to change this value. 28 | | 29 | */ 30 | 31 | 'compiled' => env( 32 | 'VIEW_COMPILED_PATH', 33 | realpath(storage_path('framework/views')) 34 | ), 35 | 36 | ]; 37 | -------------------------------------------------------------------------------- /app/Http/Middleware/HandleInertiaRequests.php: -------------------------------------------------------------------------------- 1 | withPersonalTeam()->create(); 16 | 17 | $user->currentTeam->users()->attach( 18 | $otherUser = User::factory()->create(), ['role' => 'admin'] 19 | ); 20 | 21 | $this->actingAs($otherUser); 22 | 23 | $response = $this->delete('/teams/'.$user->currentTeam->id.'/members/'.$otherUser->id); 24 | 25 | $this->assertCount(0, $user->currentTeam->fresh()->users); 26 | } 27 | 28 | public function test_team_owners_cant_leave_their_own_team(): void 29 | { 30 | $this->actingAs($user = User::factory()->withPersonalTeam()->create()); 31 | 32 | $response = $this->delete('/teams/'.$user->currentTeam->id.'/members/'.$user->id); 33 | 34 | $response->assertSessionHasErrorsIn('removeTeamMember', ['team']); 35 | 36 | $this->assertNotNull($user->currentTeam->fresh()); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /tests/Feature/DeleteTeamTest.php: -------------------------------------------------------------------------------- 1 | actingAs($user = User::factory()->withPersonalTeam()->create()); 17 | 18 | $user->ownedTeams()->save($team = Team::factory()->make([ 19 | 'personal_team' => false, 20 | ])); 21 | 22 | $team->users()->attach( 23 | $otherUser = User::factory()->create(), ['role' => 'test-role'] 24 | ); 25 | 26 | $response = $this->delete('/teams/'.$team->id); 27 | 28 | $this->assertNull($team->fresh()); 29 | $this->assertCount(0, $otherUser->fresh()->teams); 30 | } 31 | 32 | public function test_personal_teams_cant_be_deleted(): void 33 | { 34 | $this->actingAs($user = User::factory()->withPersonalTeam()->create()); 35 | 36 | $response = $this->delete('/teams/'.$user->currentTeam->id); 37 | 38 | $this->assertNotNull($user->currentTeam->fresh()); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/Exceptions/Handler.php: -------------------------------------------------------------------------------- 1 | , \Psr\Log\LogLevel::*> 14 | */ 15 | protected $levels = [ 16 | // 17 | ]; 18 | 19 | /** 20 | * A list of the exception types that are not reported. 21 | * 22 | * @var array> 23 | */ 24 | protected $dontReport = [ 25 | // 26 | ]; 27 | 28 | /** 29 | * A list of the inputs that are never flashed to the session on validation exceptions. 30 | * 31 | * @var array 32 | */ 33 | protected $dontFlash = [ 34 | 'current_password', 35 | 'password', 36 | 'password_confirmation', 37 | ]; 38 | 39 | /** 40 | * Register the exception handling callbacks for the application. 41 | */ 42 | public function register(): void 43 | { 44 | $this->reportable(function (Throwable $e) { 45 | // 46 | }); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_000000_create_users_table.php: -------------------------------------------------------------------------------- 1 | id(); 16 | $table->string('name'); 17 | $table->string('email')->unique(); 18 | $table->timestamp('email_verified_at')->nullable(); 19 | $table->string('password'); 20 | $table->rememberToken(); 21 | $table->foreignId('current_team_id')->nullable(); 22 | $table->string('profile_photo_path', 2048)->nullable(); 23 | $table->string('github_id')->nullable(); 24 | $table->string('github_token')->nullable(); 25 | $table->string('github_refresh_token')->nullable(); 26 | $table->timestamps(); 27 | }); 28 | } 29 | 30 | /** 31 | * Reverse the migrations. 32 | */ 33 | public function down(): void 34 | { 35 | Schema::dropIfExists('users'); 36 | } 37 | }; 38 | -------------------------------------------------------------------------------- /tests/Feature/AuthenticationTest.php: -------------------------------------------------------------------------------- 1 | get('/login'); 17 | 18 | $response->assertStatus(200); 19 | } 20 | 21 | public function test_users_can_authenticate_using_the_login_screen(): void 22 | { 23 | $user = User::factory()->create(); 24 | 25 | $response = $this->post('/login', [ 26 | 'email' => $user->email, 27 | 'password' => 'password', 28 | ]); 29 | 30 | $this->assertAuthenticated(); 31 | $response->assertRedirect(RouteServiceProvider::HOME); 32 | } 33 | 34 | public function test_users_can_not_authenticate_with_invalid_password(): void 35 | { 36 | $user = User::factory()->create(); 37 | 38 | $this->post('/login', [ 39 | 'email' => $user->email, 40 | 'password' => 'wrong-password', 41 | ]); 42 | 43 | $this->assertGuest(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /tests/Feature/RemoveTeamMemberTest.php: -------------------------------------------------------------------------------- 1 | actingAs($user = User::factory()->withPersonalTeam()->create()); 16 | 17 | $user->currentTeam->users()->attach( 18 | $otherUser = User::factory()->create(), ['role' => 'admin'] 19 | ); 20 | 21 | $response = $this->delete('/teams/'.$user->currentTeam->id.'/members/'.$otherUser->id); 22 | 23 | $this->assertCount(0, $user->currentTeam->fresh()->users); 24 | } 25 | 26 | public function test_only_team_owner_can_remove_team_members(): void 27 | { 28 | $user = User::factory()->withPersonalTeam()->create(); 29 | 30 | $user->currentTeam->users()->attach( 31 | $otherUser = User::factory()->create(), ['role' => 'admin'] 32 | ); 33 | 34 | $this->actingAs($otherUser); 35 | 36 | $response = $this->delete('/teams/'.$user->currentTeam->id.'/members/'.$user->id); 37 | 38 | $response->assertStatus(403); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), 21 | 'scheme' => 'https', 22 | ], 23 | 24 | 'postmark' => [ 25 | 'token' => env('POSTMARK_TOKEN'), 26 | ], 27 | 28 | 'ses' => [ 29 | 'key' => env('AWS_ACCESS_KEY_ID'), 30 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 31 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 32 | ], 33 | 'github' => [ 34 | 'client_id' => env('GITHUB_CLIENT_ID'), 35 | 'client_secret' => env('GITHUB_CLIENT_SECRET'), 36 | 'redirect' => env('GITHUB_REDIRECT_URL'), 37 | ], 38 | 39 | ]; 40 | -------------------------------------------------------------------------------- /tests/Feature/DeleteAccountTest.php: -------------------------------------------------------------------------------- 1 | markTestSkipped('Account deletion is not enabled.'); 18 | 19 | return; 20 | } 21 | 22 | $this->actingAs($user = User::factory()->create()); 23 | 24 | $response = $this->delete('/user', [ 25 | 'password' => 'password', 26 | ]); 27 | 28 | $this->assertNull($user->fresh()); 29 | } 30 | 31 | public function test_correct_password_must_be_provided_before_account_can_be_deleted(): void 32 | { 33 | if (! Features::hasAccountDeletionFeatures()) { 34 | $this->markTestSkipped('Account deletion is not enabled.'); 35 | 36 | return; 37 | } 38 | 39 | $this->actingAs($user = User::factory()->create()); 40 | 41 | $response = $this->delete('/user', [ 42 | 'password' => 'wrong-password', 43 | ]); 44 | 45 | $this->assertNotNull($user->fresh()); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /tests/Feature/PasswordConfirmationTest.php: -------------------------------------------------------------------------------- 1 | withPersonalTeam()->create(); 17 | 18 | $response = $this->actingAs($user)->get('/user/confirm-password'); 19 | 20 | $response->assertStatus(200); 21 | } 22 | 23 | public function test_password_can_be_confirmed(): void 24 | { 25 | $user = User::factory()->create(); 26 | 27 | $response = $this->actingAs($user)->post('/user/confirm-password', [ 28 | 'password' => 'password', 29 | ]); 30 | 31 | $response->assertRedirect(); 32 | $response->assertSessionHasNoErrors(); 33 | } 34 | 35 | public function test_password_is_not_confirmed_with_invalid_password(): void 36 | { 37 | $user = User::factory()->create(); 38 | 39 | $response = $this->actingAs($user)->post('/user/confirm-password', [ 40 | 'password' => 'wrong-password', 41 | ]); 42 | 43 | $response->assertSessionHasErrors(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /resources/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | /** 2 | * We'll load the axios HTTP library which allows us to easily issue requests 3 | * to our Laravel back-end. This library automatically handles sending the 4 | * CSRF token as a header based on the value of the "XSRF" token cookie. 5 | */ 6 | 7 | import axios from 'axios'; 8 | window.axios = axios; 9 | 10 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 11 | 12 | /** 13 | * Echo exposes an expressive API for subscribing to channels and listening 14 | * for events that are broadcast by Laravel. Echo and event broadcasting 15 | * allows your team to easily build robust real-time web applications. 16 | */ 17 | 18 | // import Echo from 'laravel-echo'; 19 | 20 | // import Pusher from 'pusher-js'; 21 | // window.Pusher = Pusher; 22 | 23 | // window.Echo = new Echo({ 24 | // broadcaster: 'pusher', 25 | // key: import.meta.env.VITE_PUSHER_APP_KEY, 26 | // cluster: import.meta.env.VITE_PUSHER_APP_CLUSTER ?? 'mt1', 27 | // wsHost: import.meta.env.VITE_PUSHER_HOST ? import.meta.env.VITE_PUSHER_HOST : `ws-${import.meta.env.VITE_PUSHER_APP_CLUSTER}.pusher.com`, 28 | // wsPort: import.meta.env.VITE_PUSHER_PORT ?? 80, 29 | // wssPort: import.meta.env.VITE_PUSHER_PORT ?? 443, 30 | // forceTLS: (import.meta.env.VITE_PUSHER_SCHEME ?? 'https') === 'https', 31 | // enabledTransports: ['ws', 'wss'], 32 | // }); 33 | -------------------------------------------------------------------------------- /tests/Feature/ApiTokenPermissionsTest.php: -------------------------------------------------------------------------------- 1 | markTestSkipped('API support is not enabled.'); 19 | 20 | return; 21 | } 22 | 23 | $this->actingAs($user = User::factory()->withPersonalTeam()->create()); 24 | 25 | $token = $user->tokens()->create([ 26 | 'name' => 'Test Token', 27 | 'token' => Str::random(40), 28 | 'abilities' => ['create', 'read'], 29 | ]); 30 | 31 | $response = $this->put('/user/api-tokens/'.$token->id, [ 32 | 'name' => $token->name, 33 | 'permissions' => [ 34 | 'delete', 35 | 'missing-permission', 36 | ], 37 | ]); 38 | 39 | $this->assertTrue($user->fresh()->tokens->first()->can('delete')); 40 | $this->assertFalse($user->fresh()->tokens->first()->can('read')); 41 | $this->assertFalse($user->fresh()->tokens->first()->can('missing-permission')); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /resources/js/Components/FormSection.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 39 | -------------------------------------------------------------------------------- /app/Providers/FortifyServiceProvider.php: -------------------------------------------------------------------------------- 1 | email; 37 | 38 | return Limit::perMinute(5)->by($email.$request->ip()); 39 | }); 40 | 41 | RateLimiter::for('two-factor', function (Request $request) { 42 | return Limit::perMinute(5)->by($request->session()->get('login.id')); 43 | }); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_200000_add_two_factor_columns_to_users_table.php: -------------------------------------------------------------------------------- 1 | text('two_factor_secret') 17 | ->after('password') 18 | ->nullable(); 19 | 20 | $table->text('two_factor_recovery_codes') 21 | ->after('two_factor_secret') 22 | ->nullable(); 23 | 24 | if (Fortify::confirmsTwoFactorAuthentication()) { 25 | $table->timestamp('two_factor_confirmed_at') 26 | ->after('two_factor_recovery_codes') 27 | ->nullable(); 28 | } 29 | }); 30 | } 31 | 32 | /** 33 | * Reverse the migrations. 34 | */ 35 | public function down(): void 36 | { 37 | Schema::table('users', function (Blueprint $table) { 38 | $table->dropColumn(array_merge([ 39 | 'two_factor_secret', 40 | 'two_factor_recovery_codes', 41 | ], Fortify::confirmsTwoFactorAuthentication() ? [ 42 | 'two_factor_confirmed_at', 43 | ] : [])); 44 | }); 45 | } 46 | }; 47 | -------------------------------------------------------------------------------- /resources/js/Pages/Teams/Show.vue: -------------------------------------------------------------------------------- 1 | 14 | 15 | 43 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | APP_NAME=Laravel 2 | APP_ENV=local 3 | APP_KEY= 4 | APP_DEBUG=true 5 | APP_URL=http://localhost 6 | 7 | LOG_CHANNEL=stack 8 | LOG_DEPRECATIONS_CHANNEL=null 9 | LOG_LEVEL=debug 10 | 11 | DB_CONNECTION=mysql 12 | DB_HOST=127.0.0.1 13 | DB_PORT=3306 14 | DB_DATABASE=laravel_chat_gpt_api 15 | DB_USERNAME=root 16 | DB_PASSWORD= 17 | 18 | BROADCAST_DRIVER=log 19 | CACHE_DRIVER=file 20 | FILESYSTEM_DISK=local 21 | QUEUE_CONNECTION=sync 22 | SESSION_DRIVER=database 23 | SESSION_LIFETIME=120 24 | 25 | MEMCACHED_HOST=127.0.0.1 26 | 27 | REDIS_HOST=127.0.0.1 28 | REDIS_PASSWORD=null 29 | REDIS_PORT=6379 30 | 31 | MAIL_MAILER=smtp 32 | MAIL_HOST=mailpit 33 | MAIL_PORT=1025 34 | MAIL_USERNAME=null 35 | MAIL_PASSWORD=null 36 | MAIL_ENCRYPTION=null 37 | MAIL_FROM_ADDRESS="hello@example.com" 38 | MAIL_FROM_NAME="${APP_NAME}" 39 | 40 | AWS_ACCESS_KEY_ID= 41 | AWS_SECRET_ACCESS_KEY= 42 | AWS_DEFAULT_REGION=us-east-1 43 | AWS_BUCKET= 44 | AWS_USE_PATH_STYLE_ENDPOINT=false 45 | 46 | PUSHER_APP_ID= 47 | PUSHER_APP_KEY= 48 | PUSHER_APP_SECRET= 49 | PUSHER_HOST= 50 | PUSHER_PORT=443 51 | PUSHER_SCHEME=https 52 | PUSHER_APP_CLUSTER=mt1 53 | 54 | VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}" 55 | VITE_PUSHER_HOST="${PUSHER_HOST}" 56 | VITE_PUSHER_PORT="${PUSHER_PORT}" 57 | VITE_PUSHER_SCHEME="${PUSHER_SCHEME}" 58 | VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" 59 | 60 | 61 | OPENAI_API_KEY=sk-... 62 | 63 | STRIPE_KEY=your-stripe-key 64 | STRIPE_SECRET=your-stripe-secret 65 | STRIPE_WEBHOOK_SECRET=your-stripe-webhook-secret 66 | 67 | GITHUB_REDIRECT_URL="${APP_URL}/auth/callback" 68 | -------------------------------------------------------------------------------- /tests/Feature/UpdateTeamMemberRoleTest.php: -------------------------------------------------------------------------------- 1 | actingAs($user = User::factory()->withPersonalTeam()->create()); 16 | 17 | $user->currentTeam->users()->attach( 18 | $otherUser = User::factory()->create(), ['role' => 'admin'] 19 | ); 20 | 21 | $response = $this->put('/teams/'.$user->currentTeam->id.'/members/'.$otherUser->id, [ 22 | 'role' => 'editor', 23 | ]); 24 | 25 | $this->assertTrue($otherUser->fresh()->hasTeamRole( 26 | $user->currentTeam->fresh(), 'editor' 27 | )); 28 | } 29 | 30 | public function test_only_team_owner_can_update_team_member_roles(): void 31 | { 32 | $user = User::factory()->withPersonalTeam()->create(); 33 | 34 | $user->currentTeam->users()->attach( 35 | $otherUser = User::factory()->create(), ['role' => 'admin'] 36 | ); 37 | 38 | $this->actingAs($otherUser); 39 | 40 | $response = $this->put('/teams/'.$user->currentTeam->id.'/members/'.$otherUser->id, [ 41 | 'role' => 'editor', 42 | ]); 43 | 44 | $this->assertTrue($otherUser->fresh()->hasTeamRole( 45 | $user->currentTeam->fresh(), 'admin' 46 | )); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/Actions/Jetstream/DeleteUser.php: -------------------------------------------------------------------------------- 1 | deletesTeams = $deletesTeams; 26 | } 27 | 28 | /** 29 | * Delete the given user. 30 | */ 31 | public function delete(User $user): void 32 | { 33 | DB::transaction(function () use ($user) { 34 | $this->deleteTeams($user); 35 | $user->deleteProfilePhoto(); 36 | $user->tokens->each->delete(); 37 | 38 | if($user->subscribed('default')) { 39 | $user->subscription('default')->cancel(); 40 | } 41 | 42 | $user->delete(); 43 | }); 44 | } 45 | 46 | /** 47 | * Delete the teams and team associations attached to the user. 48 | */ 49 | protected function deleteTeams(User $user): void 50 | { 51 | $user->teams()->detach(); 52 | 53 | $user->ownedTeams->each(function (Team $team) { 54 | $this->deletesTeams->delete($team); 55 | }); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /resources/js/Components/ApplicationMark.vue: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /app/Providers/RouteServiceProvider.php: -------------------------------------------------------------------------------- 1 | configureRateLimiting(); 28 | 29 | $this->routes(function () { 30 | Route::middleware('api') 31 | ->prefix('api') 32 | ->group(base_path('routes/api.php')); 33 | 34 | Route::middleware('web') 35 | ->group(base_path('routes/web.php')); 36 | Route::namespace($this->namespace) 37 | ->group(base_path('routes/jetstream.php')); 38 | }); 39 | } 40 | 41 | /** 42 | * Configure the rate limiters for the application. 43 | */ 44 | protected function configureRateLimiting(): void 45 | { 46 | RateLimiter::for('api', function (Request $request) { 47 | return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip()); 48 | }); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## About This Repo 2 | 3 | I really like AI and ChatGPT has blown my mind. I decided to create a Laravel API that uses ChatGPT to easily integrate in other applications! See the blog at [my blog](https://jyroneparker.com/2023/02/17/creating-a-laravel-chatgpt-api/) 4 | 5 | ## Usage 6 | This Laravel tutorial application is powered by the [Laravel OpenAI API] (https://github.com/mastashake08/laravel-openai-api) package created by yours truly and can be found here. This package simply requires the package and exposes the API from the package. Simply spin up the instance, run composer, set the .env file and hit the URL. 7 | 8 | ``` 9 | composer install 10 | ``` 11 | 12 | ``` 13 | POST /api/generate-result $data - a JSON object containing OpenAI configuration 14 | e.g. 15 | { 16 | "model": "text-davinci-003", 17 | "prompt" : "Write a wordpress post excerpt summarizing ChatGPT", 18 | "temperature": 0.9, 19 | "max_tokens": 20 20 | } 21 | ``` 22 | ## Consider Sponsoring 23 | Help me maintain this project, please consider looking at the [FUNDING](./.github/FUNDING.yml) file for more info. 24 | 25 | ## Changelog 26 | 27 | Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. 28 | 29 | ## Contributing 30 | 31 | Please see [CONTRIBUTING](CONTRIBUTING.md) for details. 32 | 33 | ## Security Vulnerabilities 34 | 35 | Please review [our security policy](../../security/policy) on how to report security vulnerabilities. 36 | 37 | ## Credits 38 | 39 | - [Jyrone Parker](https://github.com/mastashake08) 40 | - [All Contributors](../../contributors) 41 | 42 | ## License 43 | 44 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 45 | -------------------------------------------------------------------------------- /config/hashing.php: -------------------------------------------------------------------------------- 1 | 'bcrypt', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Bcrypt Options 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may specify the configuration options that should be used when 26 | | passwords are hashed using the Bcrypt algorithm. This will allow you 27 | | to control the amount of time it takes to hash the given password. 28 | | 29 | */ 30 | 31 | 'bcrypt' => [ 32 | 'rounds' => env('BCRYPT_ROUNDS', 10), 33 | ], 34 | 35 | /* 36 | |-------------------------------------------------------------------------- 37 | | Argon Options 38 | |-------------------------------------------------------------------------- 39 | | 40 | | Here you may specify the configuration options that should be used when 41 | | passwords are hashed using the Argon algorithm. These will allow you 42 | | to control the amount of time it takes to hash the given password. 43 | | 44 | */ 45 | 46 | 'argon' => [ 47 | 'memory' => 65536, 48 | 'threads' => 1, 49 | 'time' => 4, 50 | ], 51 | 52 | ]; 53 | -------------------------------------------------------------------------------- /app/Actions/Jetstream/RemoveTeamMember.php: -------------------------------------------------------------------------------- 1 | subscription('default', 'orikul-monthly-team')->decrementQuantity(1); 21 | $this->authorize($user, $team, $teamMember); 22 | 23 | $this->ensureUserDoesNotOwnTeam($teamMember, $team); 24 | 25 | $team->removeUser($teamMember); 26 | 27 | TeamMemberRemoved::dispatch($team, $teamMember); 28 | } 29 | 30 | /** 31 | * Authorize that the user can remove the team member. 32 | */ 33 | protected function authorize(User $user, Team $team, User $teamMember): void 34 | { 35 | if (! Gate::forUser($user)->check('removeTeamMember', $team) && 36 | $user->id !== $teamMember->id) { 37 | throw new AuthorizationException; 38 | } 39 | } 40 | 41 | /** 42 | * Ensure that the currently authenticated user does not own the team. 43 | */ 44 | protected function ensureUserDoesNotOwnTeam(User $teamMember, Team $team): void 45 | { 46 | if ($teamMember->id === $team->owner->id) { 47 | throw ValidationException::withMessages([ 48 | 'team' => [__('You may not leave a team that you created.')], 49 | ])->errorBag('removeTeamMember'); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /bootstrap/app.php: -------------------------------------------------------------------------------- 1 | singleton( 30 | Illuminate\Contracts\Http\Kernel::class, 31 | App\Http\Kernel::class 32 | ); 33 | 34 | $app->singleton( 35 | Illuminate\Contracts\Console\Kernel::class, 36 | App\Console\Kernel::class 37 | ); 38 | 39 | $app->singleton( 40 | Illuminate\Contracts\Debug\ExceptionHandler::class, 41 | App\Exceptions\Handler::class 42 | ); 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Return The Application 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This script returns the application instance. The instance is given to 50 | | the calling script so we can separate the building of the instances 51 | | from the actual running of the application and sending responses. 52 | | 53 | */ 54 | 55 | return $app; 56 | -------------------------------------------------------------------------------- /tests/Feature/UpdatePasswordTest.php: -------------------------------------------------------------------------------- 1 | actingAs($user = User::factory()->create()); 17 | 18 | $response = $this->put('/user/password', [ 19 | 'current_password' => 'password', 20 | 'password' => 'new-password', 21 | 'password_confirmation' => 'new-password', 22 | ]); 23 | 24 | $this->assertTrue(Hash::check('new-password', $user->fresh()->password)); 25 | } 26 | 27 | public function test_current_password_must_be_correct(): void 28 | { 29 | $this->actingAs($user = User::factory()->create()); 30 | 31 | $response = $this->put('/user/password', [ 32 | 'current_password' => 'wrong-password', 33 | 'password' => 'new-password', 34 | 'password_confirmation' => 'new-password', 35 | ]); 36 | 37 | $response->assertSessionHasErrors(); 38 | 39 | $this->assertTrue(Hash::check('password', $user->fresh()->password)); 40 | } 41 | 42 | public function test_new_passwords_must_match(): void 43 | { 44 | $this->actingAs($user = User::factory()->create()); 45 | 46 | $response = $this->put('/user/password', [ 47 | 'current_password' => 'password', 48 | 'password' => 'new-password', 49 | 'password_confirmation' => 'wrong-password', 50 | ]); 51 | 52 | $response->assertSessionHasErrors(); 53 | 54 | $this->assertTrue(Hash::check('password', $user->fresh()->password)); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /tests/Feature/InviteTeamMemberTest.php: -------------------------------------------------------------------------------- 1 | markTestSkipped('Team invitations not enabled.'); 20 | 21 | return; 22 | } 23 | 24 | Mail::fake(); 25 | 26 | $this->actingAs($user = User::factory()->withPersonalTeam()->create()); 27 | 28 | $response = $this->post('/teams/'.$user->currentTeam->id.'/members', [ 29 | 'email' => 'test@example.com', 30 | 'role' => 'admin', 31 | ]); 32 | 33 | Mail::assertSent(TeamInvitation::class); 34 | 35 | $this->assertCount(1, $user->currentTeam->fresh()->teamInvitations); 36 | } 37 | 38 | public function test_team_member_invitations_can_be_cancelled(): void 39 | { 40 | if (! Features::sendsTeamInvitations()) { 41 | $this->markTestSkipped('Team invitations not enabled.'); 42 | 43 | return; 44 | } 45 | 46 | Mail::fake(); 47 | 48 | $this->actingAs($user = User::factory()->withPersonalTeam()->create()); 49 | 50 | $invitation = $user->currentTeam->teamInvitations()->create([ 51 | 'email' => 'test@example.com', 52 | 'role' => 'admin', 53 | ]); 54 | 55 | $response = $this->delete('/team-invitations/'.$invitation->id); 56 | 57 | $this->assertCount(0, $user->currentTeam->fresh()->teamInvitations); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /tests/Feature/RegistrationTest.php: -------------------------------------------------------------------------------- 1 | markTestSkipped('Registration support is not enabled.'); 19 | 20 | return; 21 | } 22 | 23 | $response = $this->get('/register'); 24 | 25 | $response->assertStatus(200); 26 | } 27 | 28 | public function test_registration_screen_cannot_be_rendered_if_support_is_disabled(): void 29 | { 30 | if (Features::enabled(Features::registration())) { 31 | $this->markTestSkipped('Registration support is enabled.'); 32 | 33 | return; 34 | } 35 | 36 | $response = $this->get('/register'); 37 | 38 | $response->assertStatus(404); 39 | } 40 | 41 | public function test_new_users_can_register(): void 42 | { 43 | if (! Features::enabled(Features::registration())) { 44 | $this->markTestSkipped('Registration support is not enabled.'); 45 | 46 | return; 47 | } 48 | 49 | $response = $this->post('/register', [ 50 | 'name' => 'Test User', 51 | 'email' => 'test@example.com', 52 | 'password' => 'password', 53 | 'password_confirmation' => 'password', 54 | 'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature(), 55 | ]); 56 | 57 | $this->assertAuthenticated(); 58 | $response->assertRedirect(RouteServiceProvider::HOME); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /artisan: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | make(Illuminate\Contracts\Console\Kernel::class); 34 | 35 | $status = $kernel->handle( 36 | $input = new Symfony\Component\Console\Input\ArgvInput, 37 | new Symfony\Component\Console\Output\ConsoleOutput 38 | ); 39 | 40 | /* 41 | |-------------------------------------------------------------------------- 42 | | Shutdown The Application 43 | |-------------------------------------------------------------------------- 44 | | 45 | | Once Artisan has finished running, we will fire off the shutdown events 46 | | so that any final work may be done by the application before we shut 47 | | down the process. This is the last thing to happen to the request. 48 | | 49 | */ 50 | 51 | $kernel->terminate($input, $status); 52 | 53 | exit($status); 54 | -------------------------------------------------------------------------------- /app/Actions/Fortify/CreateNewUser.php: -------------------------------------------------------------------------------- 1 | $input 21 | */ 22 | public function create(array $input): User 23 | { 24 | Validator::make($input, [ 25 | 'name' => ['required', 'string', 'max:255'], 26 | 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 27 | 'password' => $this->passwordRules(), 28 | 'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature() ? ['accepted', 'required'] : '', 29 | ])->validate(); 30 | 31 | return DB::transaction(function () use ($input) { 32 | return tap(User::create([ 33 | 'name' => $input['name'], 34 | 'email' => $input['email'], 35 | 'password' => Hash::make($input['password']), 36 | 'trial_ends_at' => now()->addDays(7) 37 | ]), function (User $user) { 38 | $this->createTeam($user); 39 | $user->createOrGetStripeCustomer(); 40 | }); 41 | }); 42 | } 43 | 44 | /** 45 | * Create a personal team for the user. 46 | */ 47 | protected function createTeam(User $user): void 48 | { 49 | $user->ownedTeams()->save(Team::forceCreate([ 50 | 'user_id' => $user->id, 51 | 'name' => explode(' ', $user->name, 2)[0]."'s Team", 52 | 'personal_team' => true, 53 | ])); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | make(Kernel::class); 50 | 51 | $response = $kernel->handle( 52 | $request = Request::capture() 53 | )->send(); 54 | 55 | $kernel->terminate($request, $response); 56 | -------------------------------------------------------------------------------- /app/Policies/TeamPolicy.php: -------------------------------------------------------------------------------- 1 | belongsToTeam($team); 27 | } 28 | 29 | /** 30 | * Determine whether the user can create models. 31 | */ 32 | public function create(User $user): bool 33 | { 34 | return true; 35 | } 36 | 37 | /** 38 | * Determine whether the user can update the model. 39 | */ 40 | public function update(User $user, Team $team): bool 41 | { 42 | return $user->ownsTeam($team); 43 | } 44 | 45 | /** 46 | * Determine whether the user can add team members. 47 | */ 48 | public function addTeamMember(User $user, Team $team): bool 49 | { 50 | return $user->ownsTeam($team); 51 | } 52 | 53 | /** 54 | * Determine whether the user can update team member permissions. 55 | */ 56 | public function updateTeamMember(User $user, Team $team): bool 57 | { 58 | return $user->ownsTeam($team); 59 | } 60 | 61 | /** 62 | * Determine whether the user can remove team members. 63 | */ 64 | public function removeTeamMember(User $user, Team $team): bool 65 | { 66 | return $user->ownsTeam($team); 67 | } 68 | 69 | /** 70 | * Determine whether the user can delete the model. 71 | */ 72 | public function delete(User $user, Team $team): bool 73 | { 74 | return $user->ownsTeam($team); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /app/Models/User.php: -------------------------------------------------------------------------------- 1 | 31 | */ 32 | protected $fillable = [ 33 | 'name', 'email', 'password', 'github_id', 'github_token', 'github_refresh_token' 34 | ]; 35 | 36 | /** 37 | * The attributes that should be hidden for serialization. 38 | * 39 | * @var array 40 | */ 41 | protected $hidden = [ 42 | 'password', 43 | 'remember_token', 44 | 'two_factor_recovery_codes', 45 | 'two_factor_secret', 46 | 'github_id', 47 | 'github_token', 48 | 'github_refresh_token' 49 | ]; 50 | 51 | /** 52 | * The attributes that should be cast. 53 | * 54 | * @var array 55 | */ 56 | protected $casts = [ 57 | 'email_verified_at' => 'datetime', 58 | 'trial_ends_at' => 'datetime' 59 | ]; 60 | 61 | /** 62 | * The accessors to append to the model's array form. 63 | * 64 | * @var array 65 | */ 66 | protected $appends = [ 67 | 'profile_photo_url', 68 | ]; 69 | } 70 | -------------------------------------------------------------------------------- /app/Actions/Fortify/UpdateUserProfileInformation.php: -------------------------------------------------------------------------------- 1 | $input 17 | */ 18 | public function update(User $user, array $input): void 19 | { 20 | Validator::make($input, [ 21 | 'name' => ['required', 'string', 'max:255'], 22 | 'email' => ['required', 'email', 'max:255', Rule::unique('users')->ignore($user->id)], 23 | 'photo' => ['nullable', 'mimes:jpg,jpeg,png', 'max:1024'], 24 | ])->validateWithBag('updateProfileInformation'); 25 | 26 | if (isset($input['photo'])) { 27 | $user->updateProfilePhoto($input['photo']); 28 | } 29 | 30 | if ($input['email'] !== $user->email && 31 | $user instanceof MustVerifyEmail) { 32 | $this->updateVerifiedUser($user, $input); 33 | } else { 34 | $user->forceFill([ 35 | 'name' => $input['name'], 36 | 'email' => $input['email'], 37 | ])->save(); 38 | } 39 | } 40 | 41 | /** 42 | * Update the given verified user's profile information. 43 | * 44 | * @param array $input 45 | */ 46 | protected function updateVerifiedUser(User $user, array $input): void 47 | { 48 | $user->forceFill([ 49 | 'name' => $input['name'], 50 | 'email' => $input['email'], 51 | 'email_verified_at' => null, 52 | ])->save(); 53 | 54 | $user->sendEmailVerificationNotification(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /resources/js/Components/Pricing.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 62 | -------------------------------------------------------------------------------- /resources/js/Components/ConfirmationModal.vue: -------------------------------------------------------------------------------- 1 | 25 | 26 | 58 | -------------------------------------------------------------------------------- /app/Providers/JetstreamServiceProvider.php: -------------------------------------------------------------------------------- 1 | configurePermissions(); 32 | 33 | Jetstream::createTeamsUsing(CreateTeam::class); 34 | Jetstream::updateTeamNamesUsing(UpdateTeamName::class); 35 | Jetstream::addTeamMembersUsing(AddTeamMember::class); 36 | Jetstream::inviteTeamMembersUsing(InviteTeamMember::class); 37 | Jetstream::removeTeamMembersUsing(RemoveTeamMember::class); 38 | Jetstream::deleteTeamsUsing(DeleteTeam::class); 39 | Jetstream::deleteUsersUsing(DeleteUser::class); 40 | } 41 | 42 | /** 43 | * Configure the roles and permissions that are available within the application. 44 | */ 45 | protected function configurePermissions(): void 46 | { 47 | Jetstream::defaultApiTokenPermissions(['read']); 48 | 49 | Jetstream::role('admin', 'Administrator', [ 50 | 'create', 51 | 'read', 52 | 'update', 53 | 'delete', 54 | ])->description('Administrator users can perform any action.'); 55 | 56 | Jetstream::role('editor', 'Editor', [ 57 | 'read', 58 | 'create', 59 | 'update', 60 | ])->description('Editor users have the ability to read, create, and update.'); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /resources/js/Pages/Auth/ForgotPassword.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 62 | -------------------------------------------------------------------------------- /database/factories/UserFactory.php: -------------------------------------------------------------------------------- 1 | 24 | */ 25 | public function definition(): array 26 | { 27 | return [ 28 | 'name' => $this->faker->name(), 29 | 'email' => $this->faker->unique()->safeEmail(), 30 | 'email_verified_at' => now(), 31 | 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password 32 | 'two_factor_secret' => null, 33 | 'two_factor_recovery_codes' => null, 34 | 'remember_token' => Str::random(10), 35 | 'profile_photo_path' => null, 36 | 'current_team_id' => null, 37 | ]; 38 | } 39 | 40 | /** 41 | * Indicate that the model's email address should be unverified. 42 | * 43 | * @return $this 44 | */ 45 | public function unverified(): static 46 | { 47 | return $this->state(function (array $attributes) { 48 | return [ 49 | 'email_verified_at' => null, 50 | ]; 51 | }); 52 | } 53 | 54 | /** 55 | * Indicate that the user should have a personal team. 56 | * 57 | * @return $this 58 | */ 59 | public function withPersonalTeam(): static 60 | { 61 | if (! Features::hasTeamFeatures()) { 62 | return $this->state([]); 63 | } 64 | 65 | return $this->has( 66 | Team::factory() 67 | ->state(function (array $attributes, User $user) { 68 | return ['name' => $user->name.'\'s Team', 'user_id' => $user->id, 'personal_team' => true]; 69 | }), 70 | 'ownedTeams' 71 | ); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /resources/js/Pages/Auth/ConfirmPassword.vue: -------------------------------------------------------------------------------- 1 | 27 | 28 | 64 | -------------------------------------------------------------------------------- /resources/js/Pages/Profile/Show.vue: -------------------------------------------------------------------------------- 1 | 15 | 16 | 58 | -------------------------------------------------------------------------------- /config/broadcasting.php: -------------------------------------------------------------------------------- 1 | env('BROADCAST_DRIVER', 'null'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Broadcast Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may define all of the broadcast connections that will be used 26 | | to broadcast events to other systems or over websockets. Samples of 27 | | each available type of connection are provided inside this array. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'pusher' => [ 34 | 'driver' => 'pusher', 35 | 'key' => env('PUSHER_APP_KEY'), 36 | 'secret' => env('PUSHER_APP_SECRET'), 37 | 'app_id' => env('PUSHER_APP_ID'), 38 | 'options' => [ 39 | 'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com', 40 | 'port' => env('PUSHER_PORT', 443), 41 | 'scheme' => env('PUSHER_SCHEME', 'https'), 42 | 'encrypted' => true, 43 | 'useTLS' => env('PUSHER_SCHEME', 'https') === 'https', 44 | ], 45 | 'client_options' => [ 46 | // Guzzle client options: https://docs.guzzlephp.org/en/stable/request-options.html 47 | ], 48 | ], 49 | 50 | 'ably' => [ 51 | 'driver' => 'ably', 52 | 'key' => env('ABLY_KEY'), 53 | ], 54 | 55 | 'redis' => [ 56 | 'driver' => 'redis', 57 | 'connection' => 'default', 58 | ], 59 | 60 | 'log' => [ 61 | 'driver' => 'log', 62 | ], 63 | 64 | 'null' => [ 65 | 'driver' => 'null', 66 | ], 67 | 68 | ], 69 | 70 | ]; 71 | -------------------------------------------------------------------------------- /resources/js/Pages/Teams/Partials/CreateTeamForm.vue: -------------------------------------------------------------------------------- 1 | 20 | 21 | 67 | -------------------------------------------------------------------------------- /config/github-webhooks.php: -------------------------------------------------------------------------------- 1 | env('GITHUB_WEBHOOK_SECRET'), 13 | 14 | /* 15 | * You can define the job that should be run when a certain webhook hits your application 16 | * here. 17 | * 18 | * You can find a list of GitHub webhook types here: 19 | * https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads. 20 | * 21 | * You can use "*" to let a job handle all sent webhook types 22 | */ 23 | 'jobs' => [ 24 | 'pulls' => \App\Jobs\HandlePullRequestWebhookJob::class, 25 | // 'ping' => \App\Jobs\GitHubWebhooks\HandlePingWebhook::class, 26 | // 'issues.opened' => \App\Jobs\GitHubWebhooks\HandleIssueOpenedWebhookJob::class, 27 | // '*' => \App\Jobs\GitHubWebhooks\HandleAllWebhooks::class 28 | ], 29 | 30 | /* 31 | * This model will be used to store all incoming webhooks. 32 | * It should be or extend `Spatie\GitHubWebhooks\Models\GitHubWebhookCall` 33 | */ 34 | 'model' => GitHubWebhookCall::class, 35 | 36 | /* 37 | * When running `php artisan model:prune` all stored GitHub webhook calls 38 | * that were successfully processed will be deleted. 39 | * 40 | * More info on pruning: https://laravel.com/docs/8.x/eloquent#pruning-models 41 | */ 42 | 'prune_webhook_calls_after_days' => 10, 43 | 44 | /* 45 | * The classname of the job to be used. The class should equal or extend 46 | * Spatie\GitHubWebhooks\ProcessGitHubWebhookJob. 47 | */ 48 | 'job' => ProcessGitHubWebhookJob::class, 49 | 50 | /** 51 | * This class determines if the webhook call should be stored and processed. 52 | */ 53 | 'profile' => ProcessEverythingWebhookProfile::class, 54 | 55 | /* 56 | * When disabled, the package will not verify if the signature is valid. 57 | * This can be handy in local environments. 58 | */ 59 | 'verify_signature' => env('GITHUB_SIGNATURE_VERIFY', true), 60 | ]; 61 | -------------------------------------------------------------------------------- /resources/js/Components/Dropdown.vue: -------------------------------------------------------------------------------- 1 | 48 | 49 | 80 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laravel/laravel", 3 | "type": "project", 4 | "description": "The Laravel Framework.", 5 | "keywords": ["framework", "laravel"], 6 | "license": "MIT", 7 | "require": { 8 | "php": "^8.1", 9 | "guzzlehttp/guzzle": "^7.2", 10 | "inertiajs/inertia-laravel": "^0.6.8", 11 | "laravel/cashier": "^14.8", 12 | "laravel/framework": "^10.0", 13 | "laravel/jetstream": "^3.0", 14 | "laravel/sanctum": "^3.2", 15 | "laravel/socialite": "^5.6", 16 | "laravel/tinker": "^2.8", 17 | "mastashake08/laravel-openai-api": "^1.8.3", 18 | "openai-php/laravel": "^0.3.1", 19 | "spatie/laravel-github-webhooks": "^1.2", 20 | "tightenco/ziggy": "^1.0" 21 | }, 22 | "require-dev": { 23 | "fakerphp/faker": "^1.9.1", 24 | "laravel/pint": "^1.0", 25 | "laravel/sail": "^1.18", 26 | "mockery/mockery": "^1.4.4", 27 | "nunomaduro/collision": "^7.0", 28 | "phpunit/phpunit": "^10.0", 29 | "spatie/laravel-ignition": "^2.0" 30 | }, 31 | "autoload": { 32 | "psr-4": { 33 | "App\\": "app/", 34 | "Database\\Factories\\": "database/factories/", 35 | "Database\\Seeders\\": "database/seeders/" 36 | } 37 | }, 38 | "autoload-dev": { 39 | "psr-4": { 40 | "Tests\\": "tests/" 41 | } 42 | }, 43 | "scripts": { 44 | "post-autoload-dump": [ 45 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", 46 | "@php artisan package:discover --ansi" 47 | ], 48 | "post-update-cmd": [ 49 | "@php artisan vendor:publish --tag=laravel-assets --ansi --force" 50 | ], 51 | "post-root-package-install": [ 52 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" 53 | ], 54 | "post-create-project-cmd": [ 55 | "@php artisan key:generate --ansi" 56 | ] 57 | }, 58 | "extra": { 59 | "laravel": { 60 | "dont-discover": [] 61 | } 62 | }, 63 | "config": { 64 | "optimize-autoloader": true, 65 | "preferred-install": "dist", 66 | "sort-packages": true, 67 | "allow-plugins": { 68 | "pestphp/pest-plugin": true, 69 | "php-http/discovery": true 70 | } 71 | }, 72 | "minimum-stability": "stable", 73 | "prefer-stable": true 74 | } 75 | -------------------------------------------------------------------------------- /config/sanctum.php: -------------------------------------------------------------------------------- 1 | explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf( 19 | '%s%s', 20 | 'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1', 21 | Sanctum::currentApplicationUrlWithPort() 22 | ))), 23 | 24 | /* 25 | |-------------------------------------------------------------------------- 26 | | Sanctum Guards 27 | |-------------------------------------------------------------------------- 28 | | 29 | | This array contains the authentication guards that will be checked when 30 | | Sanctum is trying to authenticate a request. If none of these guards 31 | | are able to authenticate the request, Sanctum will use the bearer 32 | | token that's present on an incoming request for authentication. 33 | | 34 | */ 35 | 36 | 'guard' => ['web'], 37 | 38 | /* 39 | |-------------------------------------------------------------------------- 40 | | Expiration Minutes 41 | |-------------------------------------------------------------------------- 42 | | 43 | | This value controls the number of minutes until an issued token will be 44 | | considered expired. If this value is null, personal access tokens do 45 | | not expire. This won't tweak the lifetime of first-party sessions. 46 | | 47 | */ 48 | 49 | 'expiration' => null, 50 | 51 | /* 52 | |-------------------------------------------------------------------------- 53 | | Sanctum Middleware 54 | |-------------------------------------------------------------------------- 55 | | 56 | | When authenticating your first-party SPA with Sanctum you may need to 57 | | customize some of the middleware Sanctum uses while processing the 58 | | request. You may change the middleware listed below as required. 59 | | 60 | */ 61 | 62 | 'middleware' => [ 63 | 'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class, 64 | 'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class, 65 | ], 66 | 67 | ]; 68 | -------------------------------------------------------------------------------- /tests/Feature/TwoFactorAuthenticationSettingsTest.php: -------------------------------------------------------------------------------- 1 | markTestSkipped('Two factor authentication is not enabled.'); 18 | 19 | return; 20 | } 21 | 22 | $this->actingAs($user = User::factory()->create()); 23 | 24 | $this->withSession(['auth.password_confirmed_at' => time()]); 25 | 26 | $response = $this->post('/user/two-factor-authentication'); 27 | 28 | $this->assertNotNull($user->fresh()->two_factor_secret); 29 | $this->assertCount(8, $user->fresh()->recoveryCodes()); 30 | } 31 | 32 | public function test_recovery_codes_can_be_regenerated(): void 33 | { 34 | if (! Features::canManageTwoFactorAuthentication()) { 35 | $this->markTestSkipped('Two factor authentication is not enabled.'); 36 | 37 | return; 38 | } 39 | 40 | $this->actingAs($user = User::factory()->create()); 41 | 42 | $this->withSession(['auth.password_confirmed_at' => time()]); 43 | 44 | $this->post('/user/two-factor-authentication'); 45 | $this->post('/user/two-factor-recovery-codes'); 46 | 47 | $user = $user->fresh(); 48 | 49 | $this->post('/user/two-factor-recovery-codes'); 50 | 51 | $this->assertCount(8, $user->recoveryCodes()); 52 | $this->assertCount(8, array_diff($user->recoveryCodes(), $user->fresh()->recoveryCodes())); 53 | } 54 | 55 | public function test_two_factor_authentication_can_be_disabled(): void 56 | { 57 | if (! Features::canManageTwoFactorAuthentication()) { 58 | $this->markTestSkipped('Two factor authentication is not enabled.'); 59 | 60 | return; 61 | } 62 | 63 | $this->actingAs($user = User::factory()->create()); 64 | 65 | $this->withSession(['auth.password_confirmed_at' => time()]); 66 | 67 | $this->post('/user/two-factor-authentication'); 68 | 69 | $this->assertNotNull($user->fresh()->two_factor_secret); 70 | 71 | $this->delete('/user/two-factor-authentication'); 72 | 73 | $this->assertNull($user->fresh()->two_factor_secret); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /resources/js/Pages/Auth/VerifyEmail.vue: -------------------------------------------------------------------------------- 1 | 20 | 21 | 63 | -------------------------------------------------------------------------------- /tests/Feature/EmailVerificationTest.php: -------------------------------------------------------------------------------- 1 | markTestSkipped('Email verification not enabled.'); 22 | 23 | return; 24 | } 25 | 26 | $user = User::factory()->withPersonalTeam()->unverified()->create(); 27 | 28 | $response = $this->actingAs($user)->get('/email/verify'); 29 | 30 | $response->assertStatus(200); 31 | } 32 | 33 | public function test_email_can_be_verified(): void 34 | { 35 | if (! Features::enabled(Features::emailVerification())) { 36 | $this->markTestSkipped('Email verification not enabled.'); 37 | 38 | return; 39 | } 40 | 41 | Event::fake(); 42 | 43 | $user = User::factory()->unverified()->create(); 44 | 45 | $verificationUrl = URL::temporarySignedRoute( 46 | 'verification.verify', 47 | now()->addMinutes(60), 48 | ['id' => $user->id, 'hash' => sha1($user->email)] 49 | ); 50 | 51 | $response = $this->actingAs($user)->get($verificationUrl); 52 | 53 | Event::assertDispatched(Verified::class); 54 | 55 | $this->assertTrue($user->fresh()->hasVerifiedEmail()); 56 | $response->assertRedirect(RouteServiceProvider::HOME.'?verified=1'); 57 | } 58 | 59 | public function test_email_can_not_verified_with_invalid_hash(): void 60 | { 61 | if (! Features::enabled(Features::emailVerification())) { 62 | $this->markTestSkipped('Email verification not enabled.'); 63 | 64 | return; 65 | } 66 | 67 | $user = User::factory()->unverified()->create(); 68 | 69 | $verificationUrl = URL::temporarySignedRoute( 70 | 'verification.verify', 71 | now()->addMinutes(60), 72 | ['id' => $user->id, 'hash' => sha1('wrong-email')] 73 | ); 74 | 75 | $this->actingAs($user)->get($verificationUrl); 76 | 77 | $this->assertFalse($user->fresh()->hasVerifiedEmail()); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /resources/js/Components/ApplicationLogo.vue: -------------------------------------------------------------------------------- 1 | 5 | -------------------------------------------------------------------------------- /resources/js/Components/AuthenticationCardLogo.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 16 | -------------------------------------------------------------------------------- /config/filesystems.php: -------------------------------------------------------------------------------- 1 | env('FILESYSTEM_DISK', 'local'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Filesystem Disks 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may configure as many filesystem "disks" as you wish, and you 24 | | may even configure multiple disks of the same driver. Defaults have 25 | | been set up for each driver as an example of the required values. 26 | | 27 | | Supported Drivers: "local", "ftp", "sftp", "s3" 28 | | 29 | */ 30 | 31 | 'disks' => [ 32 | 33 | 'local' => [ 34 | 'driver' => 'local', 35 | 'root' => storage_path('app'), 36 | 'throw' => false, 37 | ], 38 | 39 | 'public' => [ 40 | 'driver' => 'local', 41 | 'root' => storage_path('app/public'), 42 | 'url' => env('APP_URL').'/storage', 43 | 'visibility' => 'public', 44 | 'throw' => false, 45 | ], 46 | 47 | 's3' => [ 48 | 'driver' => 's3', 49 | 'key' => env('AWS_ACCESS_KEY_ID'), 50 | 'secret' => env('AWS_SECRET_ACCESS_KEY'), 51 | 'region' => env('AWS_DEFAULT_REGION'), 52 | 'bucket' => env('AWS_BUCKET'), 53 | 'url' => env('AWS_URL'), 54 | 'endpoint' => env('AWS_ENDPOINT'), 55 | 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), 56 | 'throw' => false, 57 | ], 58 | 59 | ], 60 | 61 | /* 62 | |-------------------------------------------------------------------------- 63 | | Symbolic Links 64 | |-------------------------------------------------------------------------- 65 | | 66 | | Here you may configure the symbolic links that will be created when the 67 | | `storage:link` Artisan command is executed. The array keys should be 68 | | the locations of the links and the values should be their targets. 69 | | 70 | */ 71 | 72 | 'links' => [ 73 | public_path('storage') => storage_path('app/public'), 74 | ], 75 | 76 | ]; 77 | -------------------------------------------------------------------------------- /public/favicon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /resources/js/Pages/Teams/Partials/DeleteTeamForm.vue: -------------------------------------------------------------------------------- 1 | 26 | 27 | 76 | -------------------------------------------------------------------------------- /resources/js/Pages/Teams/Partials/UpdateTeamNameForm.vue: -------------------------------------------------------------------------------- 1 | 26 | 27 | 81 | -------------------------------------------------------------------------------- /docker/7.4/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 2 | 3 | LABEL maintainer="Taylor Otwell" 4 | 5 | ARG WWWGROUP 6 | ARG NODE_VERSION=16 7 | ARG POSTGRES_VERSION=13 8 | 9 | WORKDIR /var/www/html 10 | 11 | ENV DEBIAN_FRONTEND noninteractive 12 | ENV TZ=UTC 13 | 14 | RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone 15 | 16 | RUN apt-get update \ 17 | && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 dnsutils \ 18 | && curl -sS 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c' | gpg --dearmor | tee /usr/share/keyrings/ppa_ondrej_php.gpg > /dev/null \ 19 | && echo "deb [signed-by=/usr/share/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu focal main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \ 20 | && apt-get update \ 21 | && apt-get install -y php7.4-cli php7.4-dev \ 22 | php7.4-pgsql php7.4-sqlite3 php7.4-gd \ 23 | php7.4-curl php7.4-memcached \ 24 | php7.4-imap php7.4-mysql php7.4-mbstring \ 25 | php7.4-xml php7.4-zip php7.4-bcmath php7.4-soap \ 26 | php7.4-intl php7.4-readline php7.4-pcov \ 27 | php7.4-msgpack php7.4-igbinary php7.4-ldap \ 28 | php7.4-redis php7.4-xdebug \ 29 | && php -r "readfile('https://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \ 30 | && curl -sLS https://deb.nodesource.com/setup_$NODE_VERSION.x | bash - \ 31 | && apt-get install -y nodejs \ 32 | && npm install -g npm \ 33 | && curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | tee /usr/share/keyrings/yarnkey.gpg >/dev/null \ 34 | && echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \ 35 | && curl -sS https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /usr/share/keyrings/pgdg.gpg >/dev/null \ 36 | && echo "deb [signed-by=/usr/share/keyrings/pgdg.gpg] http://apt.postgresql.org/pub/repos/apt focal-pgdg main" > /etc/apt/sources.list.d/pgdg.list \ 37 | && apt-get update \ 38 | && apt-get install -y yarn \ 39 | && apt-get install -y mysql-client \ 40 | && apt-get install -y postgresql-client-$POSTGRES_VERSION \ 41 | && apt-get -y autoremove \ 42 | && apt-get clean \ 43 | && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 44 | 45 | RUN setcap "cap_net_bind_service=+ep" /usr/bin/php7.4 46 | 47 | RUN groupadd --force -g $WWWGROUP sail 48 | RUN useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u 1337 sail 49 | 50 | COPY start-container /usr/local/bin/start-container 51 | COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf 52 | COPY php.ini /etc/php/7.4/cli/conf.d/99-sail.ini 53 | RUN chmod +x /usr/local/bin/start-container 54 | 55 | EXPOSE 8000 56 | 57 | ENTRYPOINT ["start-container"] 58 | -------------------------------------------------------------------------------- /docker/8.1/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:22.04 2 | 3 | LABEL maintainer="Taylor Otwell" 4 | 5 | ARG WWWGROUP 6 | ARG NODE_VERSION=18 7 | ARG POSTGRES_VERSION=14 8 | 9 | WORKDIR /var/www/html 10 | 11 | ENV DEBIAN_FRONTEND noninteractive 12 | ENV TZ=UTC 13 | 14 | RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone 15 | 16 | RUN apt-get update \ 17 | && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 dnsutils \ 18 | && curl -sS 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c' | gpg --dearmor | tee /usr/share/keyrings/ppa_ondrej_php.gpg > /dev/null \ 19 | && echo "deb [signed-by=/usr/share/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \ 20 | && apt-get update \ 21 | && apt-get install -y php8.1-cli php8.1-dev \ 22 | php8.1-pgsql php8.1-sqlite3 php8.1-gd \ 23 | php8.1-curl \ 24 | php8.1-imap php8.1-mysql php8.1-mbstring \ 25 | php8.1-xml php8.1-zip php8.1-bcmath php8.1-soap \ 26 | php8.1-intl php8.1-readline \ 27 | php8.1-ldap \ 28 | php8.1-msgpack php8.1-igbinary php8.1-redis php8.1-swoole \ 29 | php8.1-memcached php8.1-pcov php8.1-xdebug \ 30 | && php -r "readfile('https://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \ 31 | && curl -sLS https://deb.nodesource.com/setup_$NODE_VERSION.x | bash - \ 32 | && apt-get install -y nodejs \ 33 | && npm install -g npm \ 34 | && curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | tee /usr/share/keyrings/yarn.gpg >/dev/null \ 35 | && echo "deb [signed-by=/usr/share/keyrings/yarn.gpg] https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \ 36 | && curl -sS https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /usr/share/keyrings/pgdg.gpg >/dev/null \ 37 | && echo "deb [signed-by=/usr/share/keyrings/pgdg.gpg] http://apt.postgresql.org/pub/repos/apt jammy-pgdg main" > /etc/apt/sources.list.d/pgdg.list \ 38 | && apt-get update \ 39 | && apt-get install -y yarn \ 40 | && apt-get install -y mysql-client \ 41 | && apt-get install -y postgresql-client-$POSTGRES_VERSION \ 42 | && apt-get -y autoremove \ 43 | && apt-get clean \ 44 | && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 45 | 46 | RUN setcap "cap_net_bind_service=+ep" /usr/bin/php8.1 47 | 48 | RUN groupadd --force -g $WWWGROUP sail 49 | RUN useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u 1337 sail 50 | 51 | COPY start-container /usr/local/bin/start-container 52 | COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf 53 | COPY php.ini /etc/php/8.1/cli/conf.d/99-sail.ini 54 | RUN chmod +x /usr/local/bin/start-container 55 | 56 | EXPOSE 8000 57 | 58 | ENTRYPOINT ["start-container"] 59 | -------------------------------------------------------------------------------- /docker/8.2/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:22.04 2 | 3 | LABEL maintainer="Taylor Otwell" 4 | 5 | ARG WWWGROUP 6 | ARG NODE_VERSION=18 7 | ARG POSTGRES_VERSION=14 8 | 9 | WORKDIR /var/www/html 10 | 11 | ENV DEBIAN_FRONTEND noninteractive 12 | ENV TZ=UTC 13 | 14 | RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone 15 | 16 | RUN apt-get update \ 17 | && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 dnsutils \ 18 | && curl -sS 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c' | gpg --dearmor | tee /usr/share/keyrings/ppa_ondrej_php.gpg > /dev/null \ 19 | && echo "deb [signed-by=/usr/share/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \ 20 | && apt-get update \ 21 | && apt-get install -y php8.2-cli php8.2-dev \ 22 | php8.2-pgsql php8.2-sqlite3 php8.2-gd \ 23 | php8.2-curl \ 24 | php8.2-imap php8.2-mysql php8.2-mbstring \ 25 | php8.2-xml php8.2-zip php8.2-bcmath php8.2-soap \ 26 | php8.2-intl php8.2-readline \ 27 | php8.2-ldap \ 28 | php8.2-msgpack php8.2-igbinary php8.2-redis php8.2-swoole \ 29 | php8.2-memcached php8.2-pcov php8.2-xdebug \ 30 | && php -r "readfile('https://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \ 31 | && curl -sLS https://deb.nodesource.com/setup_$NODE_VERSION.x | bash - \ 32 | && apt-get install -y nodejs \ 33 | && npm install -g npm \ 34 | && curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | tee /usr/share/keyrings/yarn.gpg >/dev/null \ 35 | && echo "deb [signed-by=/usr/share/keyrings/yarn.gpg] https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \ 36 | && curl -sS https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /usr/share/keyrings/pgdg.gpg >/dev/null \ 37 | && echo "deb [signed-by=/usr/share/keyrings/pgdg.gpg] http://apt.postgresql.org/pub/repos/apt jammy-pgdg main" > /etc/apt/sources.list.d/pgdg.list \ 38 | && apt-get update \ 39 | && apt-get install -y yarn \ 40 | && apt-get install -y mysql-client \ 41 | && apt-get install -y postgresql-client-$POSTGRES_VERSION \ 42 | && apt-get -y autoremove \ 43 | && apt-get clean \ 44 | && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 45 | 46 | RUN setcap "cap_net_bind_service=+ep" /usr/bin/php8.2 47 | 48 | RUN groupadd --force -g $WWWGROUP sail 49 | RUN useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u 1337 sail 50 | 51 | COPY start-container /usr/local/bin/start-container 52 | COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf 53 | COPY php.ini /etc/php/8.2/cli/conf.d/99-sail.ini 54 | RUN chmod +x /usr/local/bin/start-container 55 | 56 | EXPOSE 8000 57 | 58 | ENTRYPOINT ["start-container"] 59 | -------------------------------------------------------------------------------- /docker/8.0/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 2 | 3 | LABEL maintainer="Taylor Otwell" 4 | 5 | ARG WWWGROUP 6 | ARG NODE_VERSION=16 7 | ARG POSTGRES_VERSION=13 8 | 9 | WORKDIR /var/www/html 10 | 11 | ENV DEBIAN_FRONTEND noninteractive 12 | ENV TZ=UTC 13 | 14 | RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone 15 | 16 | RUN apt-get update \ 17 | && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 dnsutils \ 18 | && curl -sS 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c' | gpg --dearmor | tee /usr/share/keyrings/ppa_ondrej_php.gpg > /dev/null \ 19 | && echo "deb [signed-by=/usr/share/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu focal main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \ 20 | && apt-get update \ 21 | && apt-get install -y php8.0-cli php8.0-dev \ 22 | php8.0-pgsql php8.0-sqlite3 php8.0-gd \ 23 | php8.0-curl php8.0-memcached \ 24 | php8.0-imap php8.0-mysql php8.0-mbstring \ 25 | php8.0-xml php8.0-zip php8.0-bcmath php8.0-soap \ 26 | php8.0-intl php8.0-readline php8.0-pcov \ 27 | php8.0-msgpack php8.0-igbinary php8.0-ldap \ 28 | php8.0-redis php8.0-swoole php8.0-xdebug \ 29 | && php -r "readfile('https://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \ 30 | && curl -sLS https://deb.nodesource.com/setup_$NODE_VERSION.x | bash - \ 31 | && apt-get install -y nodejs \ 32 | && npm install -g npm \ 33 | && curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | tee /usr/share/keyrings/yarnkey.gpg >/dev/null \ 34 | && echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \ 35 | && curl -sS https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /usr/share/keyrings/pgdg.gpg >/dev/null \ 36 | && echo "deb [signed-by=/usr/share/keyrings/pgdg.gpg] http://apt.postgresql.org/pub/repos/apt focal-pgdg main" > /etc/apt/sources.list.d/pgdg.list \ 37 | && apt-get update \ 38 | && apt-get install -y yarn \ 39 | && apt-get install -y mysql-client \ 40 | && apt-get install -y postgresql-client-$POSTGRES_VERSION \ 41 | && apt-get -y autoremove \ 42 | && apt-get clean \ 43 | && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 44 | 45 | RUN update-alternatives --set php /usr/bin/php8.0 46 | 47 | RUN setcap "cap_net_bind_service=+ep" /usr/bin/php8.0 48 | 49 | RUN groupadd --force -g $WWWGROUP sail 50 | RUN useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u 1337 sail 51 | 52 | COPY start-container /usr/local/bin/start-container 53 | COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf 54 | COPY php.ini /etc/php/8.0/cli/conf.d/99-sail.ini 55 | RUN chmod +x /usr/local/bin/start-container 56 | 57 | EXPOSE 8000 58 | 59 | ENTRYPOINT ["start-container"] 60 | -------------------------------------------------------------------------------- /app/Actions/Jetstream/AddTeamMember.php: -------------------------------------------------------------------------------- 1 | authorize('addTeamMember', $team); 24 | 25 | $this->validate($team, $email, $role); 26 | 27 | $newTeamMember = Jetstream::findUserByEmailOrFail($email); 28 | 29 | AddingTeamMember::dispatch($team, $newTeamMember); 30 | 31 | $team->users()->attach( 32 | $newTeamMember, ['role' => $role] 33 | ); 34 | 35 | TeamMemberAdded::dispatch($team, $newTeamMember); 36 | if($user->subscribed('default')) { 37 | $user->newSubscription('default', 'orikul-monthly-team-user')->add(); 38 | } else { 39 | $user->newSubscription('default', ['orikul-monthly','orikul-monthly-team-user'])->add(); 40 | } 41 | 42 | } 43 | 44 | /** 45 | * Validate the add member operation. 46 | */ 47 | protected function validate(Team $team, string $email, ?string $role): void 48 | { 49 | Validator::make([ 50 | 'email' => $email, 51 | 'role' => $role, 52 | ], $this->rules(), [ 53 | 'email.exists' => __('We were unable to find a registered user with this email address.'), 54 | ])->after( 55 | $this->ensureUserIsNotAlreadyOnTeam($team, $email) 56 | )->validateWithBag('addTeamMember'); 57 | } 58 | 59 | /** 60 | * Get the validation rules for adding a team member. 61 | * 62 | * @return array 63 | */ 64 | protected function rules(): array 65 | { 66 | return array_filter([ 67 | 'email' => ['required', 'email', 'exists:users'], 68 | 'role' => Jetstream::hasRoles() 69 | ? ['required', 'string', new Role] 70 | : null, 71 | ]); 72 | } 73 | 74 | /** 75 | * Ensure that the user is not already on the team. 76 | */ 77 | protected function ensureUserIsNotAlreadyOnTeam(Team $team, string $email): Closure 78 | { 79 | return function ($validator) use ($team, $email) { 80 | $validator->errors()->addIf( 81 | $team->hasUserWithEmail($email), 82 | 'email', 83 | __('This user already belongs to the team.') 84 | ); 85 | }; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /config/jetstream.php: -------------------------------------------------------------------------------- 1 | 'inertia', 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Jetstream Route Middleware 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Here you may specify which middleware Jetstream will assign to the routes 27 | | that it registers with the application. When necessary, you may modify 28 | | these middleware; however, this default value is usually sufficient. 29 | | 30 | */ 31 | 32 | 'middleware' => ['web'], 33 | 34 | 'auth_session' => AuthenticateSession::class, 35 | 36 | /* 37 | |-------------------------------------------------------------------------- 38 | | Jetstream Guard 39 | |-------------------------------------------------------------------------- 40 | | 41 | | Here you may specify the authentication guard Jetstream will use while 42 | | authenticating users. This value should correspond with one of your 43 | | guards that is already present in your "auth" configuration file. 44 | | 45 | */ 46 | 47 | 'guard' => 'sanctum', 48 | 49 | /* 50 | |-------------------------------------------------------------------------- 51 | | Features 52 | |-------------------------------------------------------------------------- 53 | | 54 | | Some of Jetstream's features are optional. You may disable the features 55 | | by removing them from this array. You're free to only remove some of 56 | | these features or you can even remove all of these if you need to. 57 | | 58 | */ 59 | 60 | 'features' => [ 61 | Features::termsAndPrivacyPolicy(), 62 | Features::profilePhotos(), 63 | Features::api(), 64 | // Features::teams(['invitations' => true]), 65 | Features::accountDeletion(), 66 | ], 67 | 68 | /* 69 | |-------------------------------------------------------------------------- 70 | | Profile Photo Disk 71 | |-------------------------------------------------------------------------- 72 | | 73 | | This configuration value determines the default disk that will be used 74 | | when storing profile photos for your application's users. Typically 75 | | this will be the "public" disk but you may adjust this if needed. 76 | | 77 | */ 78 | 79 | 'profile_photo_disk' => 'public', 80 | 81 | ]; 82 | -------------------------------------------------------------------------------- /app/Actions/Jetstream/InviteTeamMember.php: -------------------------------------------------------------------------------- 1 | authorize('addTeamMember', $team); 27 | 28 | $this->validate($team, $email, $role); 29 | 30 | InvitingTeamMember::dispatch($team, $email, $role); 31 | 32 | $invitation = $team->teamInvitations()->create([ 33 | 'email' => $email, 34 | 'role' => $role, 35 | ]); 36 | 37 | Mail::to($email)->send(new TeamInvitation($invitation)); 38 | } 39 | 40 | /** 41 | * Validate the invite member operation. 42 | */ 43 | protected function validate(Team $team, string $email, ?string $role): void 44 | { 45 | Validator::make([ 46 | 'email' => $email, 47 | 'role' => $role, 48 | ], $this->rules($team), [ 49 | 'email.unique' => __('This user has already been invited to the team.'), 50 | ])->after( 51 | $this->ensureUserIsNotAlreadyOnTeam($team, $email) 52 | )->validateWithBag('addTeamMember'); 53 | } 54 | 55 | /** 56 | * Get the validation rules for inviting a team member. 57 | * 58 | * @return array 59 | */ 60 | protected function rules(Team $team): array 61 | { 62 | return array_filter([ 63 | 'email' => [ 64 | 'required', 'email', 65 | Rule::unique('team_invitations')->where(function (Builder $query) use ($team) { 66 | $query->where('team_id', $team->id); 67 | }), 68 | ], 69 | 'role' => Jetstream::hasRoles() 70 | ? ['required', 'string', new Role] 71 | : null, 72 | ]); 73 | } 74 | 75 | /** 76 | * Ensure that the user is not already on the team. 77 | */ 78 | protected function ensureUserIsNotAlreadyOnTeam(Team $team, string $email): Closure 79 | { 80 | return function ($validator) use ($team, $email) { 81 | $validator->errors()->addIf( 82 | $team->hasUserWithEmail($email), 83 | 'email', 84 | __('This user already belongs to the team.') 85 | ); 86 | }; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /resources/js/Components/Banner.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | 53 | -------------------------------------------------------------------------------- /resources/js/Pages/Auth/ResetPassword.vue: -------------------------------------------------------------------------------- 1 | 28 | 29 | 86 | --------------------------------------------------------------------------------