trypost/app/Actions/Fortify/CreateNewUser.php
Paulo Castellano adfba2755e feat: Add Pinterest integration and user language preferences
Pinterest Integration:
- Add Pinterest OAuth controller and routes
- Add PinterestPublisher service with support for pins, video pins, and carousels
- Add PinterestPreview component with board selector and content type options
- Add Pinterest content types enum (Pin, VideoPin, Carousel)
- Add Pinterest to Platform enum with proper configuration
- Support sandbox mode via PINTEREST_SANDBOX env variable
- Pass platform-specific data (boards) through PlatformPreview

Language Feature:
- Add languages table with migration
- Add Language model and seeder (en-US, pt-BR)
- Add LanguageCombobox component for profile settings
- Set default language (en-US) on user registration
- Add language_id foreign key to users table

UI Improvements:
- Refactor PlatformPreview to support contentTypeOptions, meta, and platformData props
- Move content type and board selectors into platform-specific preview components

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 13:10:01 -03:00

57 lines
1.6 KiB
PHP

<?php
namespace App\Actions\Fortify;
use App\Concerns\ProfileValidationRules;
use App\Enums\User\Setup;
use App\Models\Language;
use App\Models\User;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rules\Password;
use Laravel\Fortify\Contracts\CreatesNewUsers;
class CreateNewUser implements CreatesNewUsers
{
use ProfileValidationRules;
/**
* Validate and create a newly registered user.
*
* @param array<string, string> $input
*/
public function create(array $input): User
{
Validator::make($input, [
'name' => $this->nameRules(),
'email' => $this->emailRules(),
'password' => ['required', 'string', Password::default()],
])->validate();
return DB::transaction(function () use ($input) {
$defaultLanguage = Language::where('code', 'en-US')->first();
$user = User::create([
'name' => $input['name'],
'email' => $input['email'],
'password' => $input['password'],
'setup' => Setup::Role,
'language_id' => $defaultLanguage?->id,
]);
// Create default workspace for new user
$workspace = $user->workspaces()->create([
'name' => 'My Workspace',
'timezone' => 'UTC',
]);
// Add user as owner member
$workspace->members()->attach($user->id, ['role' => 'owner']);
// Set as current workspace
$user->update(['current_workspace_id' => $workspace->id]);
return $user;
});
}
}