- Extract business logic from controllers into Action classes: Post/, Workspace/, Hashtag/, Label/, Invite/, ApiKey/ - Create subdomain routing: app.trypost.test (Inertia dashboard), api.trypost.test (REST API with token auth) - Add ApiToken model with tp_ prefix, token_lookup/hash auth - Add AuthenticateApiToken middleware for API authentication - Create Api controllers with JSON Resources for all entities - Create App controllers that use Actions + Inertia responses - Organize Form Requests into Api/ and App/ directories - Add api_tokens migration - Update all route names with app. prefix - Update all tests to use new route names (684 passing)
26 lines
667 B
PHP
26 lines
667 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Actions\Invite;
|
|
|
|
use App\Enums\UserWorkspace\Role as WorkspaceRole;
|
|
use App\Mail\WorkspaceInvite as WorkspaceInviteMail;
|
|
use App\Models\Workspace;
|
|
use App\Models\WorkspaceInvite;
|
|
use Illuminate\Support\Facades\Mail;
|
|
|
|
class CreateInvite
|
|
{
|
|
public static function execute(Workspace $workspace, array $data): WorkspaceInvite
|
|
{
|
|
$invite = $workspace->invites()->create([
|
|
'email' => data_get($data, 'email'),
|
|
'role' => data_get($data, 'role', WorkspaceRole::Member),
|
|
]);
|
|
|
|
Mail::to($invite->email)->send(new WorkspaceInviteMail($invite));
|
|
|
|
return $invite;
|
|
}
|
|
}
|