2026-01-15 01:13:44 +00:00
|
|
|
<?php
|
|
|
|
|
|
refactor: settings redesign, Spanish translations, language system, strict_types
Settings pages:
- Redesign layout to match Sendkit (max-w-4xl, space-y-12, Separator sections)
- Merge Members page into Workspace settings with Table, invite Dialog, ConfirmDeleteModal
- Add workspace logo upload/delete routes and controller methods
- Translate all hardcoded strings in Workspace.vue modals
Language system:
- Drop languages table, replace language_id FK with locale string column on users
- Create config/languages.php for available languages and default locale
- Add Spanish (es) translations (13 files)
- Simplify HandleInertiaRequests, ProfileController, RegisteredUserController
Code quality:
- Add declare(strict_types=1) to all PHP files
- Fix MastodonPublisher using wrong attribute (filename -> original_filename)
- Fix HasMediaTest for new has_photo/photo_url accessors
- Fix PublishToSocialPlatformTest type error revealed by strict_types
- Remove orphaned Language model from AppServiceProvider morph map
- Update User TypeScript interface (has_photo, photo_url, locale)
- Eager load media relation on workspaces to prevent N+1
- Add 8 new tests for workspace logo upload/delete
- Update workspace settings test to assert members/invitations props
All 710 tests passing.
2026-03-30 03:20:43 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2026-01-15 01:13:44 +00:00
|
|
|
namespace App\Models;
|
|
|
|
|
|
2026-01-17 02:46:30 +00:00
|
|
|
use App\Enums\User\Persona;
|
|
|
|
|
use App\Enums\User\Setup;
|
2026-01-17 17:44:37 +00:00
|
|
|
use App\Models\Traits\HasMedia;
|
2026-01-19 00:49:13 +00:00
|
|
|
use App\Models\Traits\HasWorkspace;
|
2026-03-29 22:24:28 +00:00
|
|
|
use Database\Factories\UserFactory;
|
2026-01-17 17:44:37 +00:00
|
|
|
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
2026-01-15 01:13:44 +00:00
|
|
|
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
feat: notification system with SendNotification job, dialog UI, tests
Backend:
- Create notifications table (user_id, workspace_id, type, channel,
title, body, data JSON, read_at, archived_at)
- Create Notification model with Type enum (post_failed,
account_disconnected, invite_received, member_joined, member_removed)
and Channel enum (email, in_app, both)
- Create SendNotification job: isolated from publish flow, handles
saving in-app notification and sending email independently
- NotificationController: index (excludes archived, scoped to workspace),
markAsRead, markAllAsRead, archiveAll
- Integrate with PublishToSocialPlatform (post failed/partial)
- Integrate with VerifyWorkspaceConnections (batch disconnection)
- Integrate with SocialAccount::markAsDisconnected (single disconnection)
- All use SendNotification::dispatch() instead of direct Mail::to()
Frontend:
- NotificationBell component in sidebar footer with unread badge
- Dialog with notification list, mark as read, mark all read, archive all
- Click navigates to relevant page (post edit, accounts)
- i18n for notifications UI (en, es, pt-BR)
Tests:
- 8 tests for NotificationController (auth, CRUD, workspace scoping)
- 4 tests for SendNotification job (channels, email, data storage)
All 745 tests passing.
2026-03-30 19:47:03 +00:00
|
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
refactor: notification preferences, header slots, calendar layout, UI polish
Notification preferences:
- Create notification_preferences table (post_published, post_failed,
account_disconnected booleans per user)
- NotificationPreferenceController with firstOrCreate on first visit
- SendNotification job respects email preferences before sending
- Settings page with toggle switches, i18n in 3 languages
- 8 new tests for preferences (controller + wantsEmailFor + job integration)
Post published notification:
- PostPublished mail + maizzle template
- Notify owner on successful publish via SendNotification job
- PostPublished type added to notification enum
Header & Layout:
- Rename AppSidebarHeader to AppHeader with left/center/right slots
- showSidebarTrigger prop to hide sidebar toggle
- Calendar: controls in header (left: nav, center: date, right: tabs + new post)
- Fixed header with scrollable content (flex h-screen pattern)
- fullWidth pages use overflow-y-auto (fixes month view scroll)
UI improvements:
- Action buttons moved to header-right: posts, hashtags, labels
- Settings breadcrumbs: "Settings > Profile" pattern
- Calendar: remove duplicate New Post button from day view
- Remove size="sm" from Schedule/Publish buttons
- Remove bg-background from header (inherits from SidebarInset)
- Add Cancel button to labels and hashtags create/edit dialogs
- Add common.cancel i18n key
- Clean up orphaned Calendar breadcrumbs
- Fix SocialAccountsGrid buttons to use shadcn Button ghost
All 753 tests passing.
2026-03-30 21:18:17 +00:00
|
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
2026-01-15 01:13:44 +00:00
|
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
|
|
|
use Illuminate\Notifications\Notifiable;
|
|
|
|
|
use Laravel\Cashier\Billable;
|
|
|
|
|
|
2026-01-17 17:44:37 +00:00
|
|
|
class User extends Authenticatable implements MustVerifyEmail
|
2026-01-15 01:13:44 +00:00
|
|
|
{
|
2026-03-29 22:24:28 +00:00
|
|
|
/** @use HasFactory<UserFactory> */
|
2026-01-20 19:53:54 +00:00
|
|
|
use Billable, HasFactory, HasMedia, HasUuids, HasWorkspace, Notifiable;
|
2026-01-15 01:13:44 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The attributes that are mass assignable.
|
|
|
|
|
*
|
|
|
|
|
* @var list<string>
|
|
|
|
|
*/
|
|
|
|
|
protected $fillable = [
|
|
|
|
|
'name',
|
|
|
|
|
'email',
|
|
|
|
|
'password',
|
2026-01-17 02:46:30 +00:00
|
|
|
'setup',
|
|
|
|
|
'persona',
|
|
|
|
|
'current_workspace_id',
|
2026-01-20 19:53:54 +00:00
|
|
|
'email_verified_at',
|
2026-01-15 01:13:44 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The attributes that should be hidden for serialization.
|
|
|
|
|
*
|
|
|
|
|
* @var list<string>
|
|
|
|
|
*/
|
|
|
|
|
protected $hidden = [
|
|
|
|
|
'password',
|
|
|
|
|
'two_factor_secret',
|
|
|
|
|
'two_factor_recovery_codes',
|
|
|
|
|
'remember_token',
|
|
|
|
|
];
|
|
|
|
|
|
2026-03-30 02:01:08 +00:00
|
|
|
protected $appends = [
|
|
|
|
|
'has_photo',
|
|
|
|
|
'photo_url',
|
|
|
|
|
];
|
2026-01-17 17:44:37 +00:00
|
|
|
|
2026-03-30 02:01:08 +00:00
|
|
|
public function getHasPhotoAttribute(): bool
|
2026-01-17 17:44:37 +00:00
|
|
|
{
|
2026-03-30 02:01:08 +00:00
|
|
|
return $this->getFirstMedia('avatar') !== null;
|
|
|
|
|
}
|
2026-01-17 17:44:37 +00:00
|
|
|
|
2026-03-30 02:01:08 +00:00
|
|
|
public function getPhotoUrlAttribute(): ?string
|
|
|
|
|
{
|
|
|
|
|
return $this->getFirstMediaUrl('avatar');
|
2026-01-17 17:44:37 +00:00
|
|
|
}
|
|
|
|
|
|
2026-01-15 01:13:44 +00:00
|
|
|
/**
|
|
|
|
|
* Get the attributes that should be cast.
|
|
|
|
|
*
|
|
|
|
|
* @return array<string, string>
|
|
|
|
|
*/
|
|
|
|
|
protected function casts(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'email_verified_at' => 'datetime',
|
|
|
|
|
'password' => 'hashed',
|
|
|
|
|
'two_factor_confirmed_at' => 'datetime',
|
2026-01-17 02:46:30 +00:00
|
|
|
'setup' => Setup::class,
|
|
|
|
|
'persona' => Persona::class,
|
2026-01-15 01:13:44 +00:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
feat: notification system with SendNotification job, dialog UI, tests
Backend:
- Create notifications table (user_id, workspace_id, type, channel,
title, body, data JSON, read_at, archived_at)
- Create Notification model with Type enum (post_failed,
account_disconnected, invite_received, member_joined, member_removed)
and Channel enum (email, in_app, both)
- Create SendNotification job: isolated from publish flow, handles
saving in-app notification and sending email independently
- NotificationController: index (excludes archived, scoped to workspace),
markAsRead, markAllAsRead, archiveAll
- Integrate with PublishToSocialPlatform (post failed/partial)
- Integrate with VerifyWorkspaceConnections (batch disconnection)
- Integrate with SocialAccount::markAsDisconnected (single disconnection)
- All use SendNotification::dispatch() instead of direct Mail::to()
Frontend:
- NotificationBell component in sidebar footer with unread badge
- Dialog with notification list, mark as read, mark all read, archive all
- Click navigates to relevant page (post edit, accounts)
- i18n for notifications UI (en, es, pt-BR)
Tests:
- 8 tests for NotificationController (auth, CRUD, workspace scoping)
- 4 tests for SendNotification job (channels, email, data storage)
All 745 tests passing.
2026-03-30 19:47:03 +00:00
|
|
|
/**
|
|
|
|
|
* @return HasMany<Notification, $this>
|
|
|
|
|
*/
|
|
|
|
|
public function notifications(): HasMany
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(Notification::class);
|
|
|
|
|
}
|
|
|
|
|
|
refactor: notification preferences, header slots, calendar layout, UI polish
Notification preferences:
- Create notification_preferences table (post_published, post_failed,
account_disconnected booleans per user)
- NotificationPreferenceController with firstOrCreate on first visit
- SendNotification job respects email preferences before sending
- Settings page with toggle switches, i18n in 3 languages
- 8 new tests for preferences (controller + wantsEmailFor + job integration)
Post published notification:
- PostPublished mail + maizzle template
- Notify owner on successful publish via SendNotification job
- PostPublished type added to notification enum
Header & Layout:
- Rename AppSidebarHeader to AppHeader with left/center/right slots
- showSidebarTrigger prop to hide sidebar toggle
- Calendar: controls in header (left: nav, center: date, right: tabs + new post)
- Fixed header with scrollable content (flex h-screen pattern)
- fullWidth pages use overflow-y-auto (fixes month view scroll)
UI improvements:
- Action buttons moved to header-right: posts, hashtags, labels
- Settings breadcrumbs: "Settings > Profile" pattern
- Calendar: remove duplicate New Post button from day view
- Remove size="sm" from Schedule/Publish buttons
- Remove bg-background from header (inherits from SidebarInset)
- Add Cancel button to labels and hashtags create/edit dialogs
- Add common.cancel i18n key
- Clean up orphaned Calendar breadcrumbs
- Fix SocialAccountsGrid buttons to use shadcn Button ghost
All 753 tests passing.
2026-03-30 21:18:17 +00:00
|
|
|
public function notificationPreference(): HasOne
|
|
|
|
|
{
|
|
|
|
|
return $this->hasOne(NotificationPreference::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function wantsEmailFor(string $type): bool
|
|
|
|
|
{
|
|
|
|
|
$preference = $this->notificationPreference;
|
|
|
|
|
|
|
|
|
|
if (! $preference) {
|
|
|
|
|
return true; // Default: all enabled
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return match ($type) {
|
|
|
|
|
'post_published' => $preference->post_published,
|
|
|
|
|
'post_failed', 'post_partially_published' => $preference->post_failed,
|
|
|
|
|
'account_disconnected' => $preference->account_disconnected,
|
|
|
|
|
default => true,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-15 01:13:44 +00:00
|
|
|
/**
|
|
|
|
|
* Check if user has an active subscription.
|
2026-01-26 15:01:53 +00:00
|
|
|
* In self-hosted mode, always returns true (no subscription required).
|
2026-01-15 01:13:44 +00:00
|
|
|
*/
|
|
|
|
|
public function hasActiveSubscription(): bool
|
|
|
|
|
{
|
2026-01-26 15:01:53 +00:00
|
|
|
if (config('trypost.self_hosted')) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-15 01:13:44 +00:00
|
|
|
return $this->subscribed('default');
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-17 02:46:30 +00:00
|
|
|
/**
|
|
|
|
|
* Check if user has ever had a subscription (for trial eligibility).
|
|
|
|
|
*/
|
|
|
|
|
public function hasEverSubscribed(): bool
|
|
|
|
|
{
|
|
|
|
|
return $this->subscriptions()->exists();
|
|
|
|
|
}
|
2026-01-15 01:13:44 +00:00
|
|
|
}
|