trypost/app/Http/Controllers/App
Paulo Castellano 6ae48f014f fix: persist morph map alias on AI-generated Media rows
Both PostAiCreateController::createMediaItem and
PostTemplateController::createMediaItem were doing:

    $media = new Media([...]);
    $media->mediable_type = Workspace::class;   // ← FQCN literal
    $media->mediable_id = $workspace->id;
    $media->save();

Assigning Workspace::class directly bypasses the morphMap configured in
AppServiceProvider, so rows ended up with mediable_type =
'App\\Models\\Workspace' instead of the alias 'workspace'. Other queries
that pivot through the morphMap (e.g. $workspace->media) lose those
records on hosts where the FQCN doesn't match the alias.

Switch both to the relationship form:

    $media = $workspace->media()->create([...]);

Laravel fills mediable_type via the morphMap, producing 'workspace'.
This is the same pattern AssetController and the HasMedia trait already
use; these two AI controllers were the only outliers (`grep -rn
'mediable_type =' app/` confirms).

Added tests/Unit/MediaPolymorphTest as a regression — asserts the
created row's mediable_type is the alias and that the relationship
resolves back to the workspace.
2026-05-04 14:14:14 -03:00
..
Settings feat: transition AI usage from feature-based limits to a centralized monthly credit system with token tracking. 2026-05-03 19:36:26 -03:00
AnalyticsController.php feat: add YouTube Analytics with 7 channel metrics 2026-04-14 13:10:27 -03:00
ApiKeyController.php feat: migrate custom API token implementation to Laravel Passport for authentication and token management 2026-05-03 18:38:17 -03:00
AssetController.php feat: media gallery picker, custom emoji picker, preview tabs, real platform logos 2026-05-01 14:53:49 -03:00
BillingController.php refactor: reorganize billing language keys and implement AccountPolicy for subscription management 2026-05-03 17:26:55 -03:00
Controller.php refactor: restructure to Actions, subdomain routes (app/api), API tokens 2026-03-29 19:24:28 -03:00
GiphyController.php feat: complete AI assistant with custom services and brand config 2026-04-16 09:25:08 -03:00
NotificationController.php refactor: code review fixes — policies, enums, data_get, tests 2026-03-31 00:40:18 -03:00
PostAiCreateController.php fix: persist morph map alias on AI-generated Media rows 2026-05-04 14:14:14 -03:00
PostAiGenerateController.php feat: transition AI usage from feature-based limits to a centralized monthly credit system with token tracking. 2026-05-03 19:36:26 -03:00
PostAiReviewController.php feat: transition AI usage from feature-based limits to a centralized monthly credit system with token tracking. 2026-05-03 19:36:26 -03:00
PostCommentController.php feat: @mentions in comments, AI Action layer + MCP tools, settings tabs 2026-05-01 20:59:03 -03:00
PostController.php refactor: move workspace tenancy check on Post into PostPolicy 2026-05-04 13:20:52 -03:00
PostTemplateController.php fix: persist morph map alias on AI-generated Media rows 2026-05-04 14:14:14 -03:00
PresenceController.php feat: @mentions in comments, AI Action layer + MCP tools, settings tabs 2026-05-01 20:59:03 -03:00
UnsplashController.php feat: complete AI assistant with custom services and brand config 2026-04-16 09:25:08 -03:00
WorkspaceController.php feat: transition AI usage from feature-based limits to a centralized monthly credit system with token tracking. 2026-05-03 19:36:26 -03:00
WorkspaceInviteController.php refactor: reorganize settings UI, migrate post templates to a file-based registry, and remove legacy video generation features 2026-05-03 13:44:13 -03:00
WorkspaceLabelController.php refactor: code review fixes — policies, enums, data_get, tests 2026-03-31 00:40:18 -03:00
WorkspaceSignatureController.php chore: remove deprecated localization files 2026-05-03 15:23:25 -03:00