diff --git a/app/Models/Notification.php b/app/Models/Notification.php new file mode 100644 index 00000000..25ea883b --- /dev/null +++ b/app/Models/Notification.php @@ -0,0 +1,11 @@ +withTimestamps() ->as('membership'); } + + /** + * @return MorphMany + */ + public function notifications(): MorphMany + { + return $this->morphMany(Notification::class, 'notifiable')->latest(); + } } diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index e7a414c9..2cb4e969 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -5,6 +5,7 @@ namespace App\Providers; use App\Models\Organization; +use App\Models\Token; use App\Policies\OrganizationPolicy; use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; use Laravel\Jetstream\Jetstream; @@ -47,5 +48,7 @@ public function boot(): void // use passport scopes for jetstream token permissions Jetstream::permissions(Passport::scopeIds()); + + Passport::useTokenModel(Token::class); } } diff --git a/resources/js/types/models.ts b/resources/js/types/models.ts index 08fa5d7e..889a62db 100644 --- a/resources/js/types/models.ts +++ b/resources/js/types/models.ts @@ -19,6 +19,11 @@ export interface Membership { updated_at: string | null; } +export interface Notification { + // relations + notifiable: Notification; +} + export interface Organization { // columns id: string; @@ -106,6 +111,22 @@ export interface TimeEntry { task: Task; } +export interface Token { + // columns + id: string; + user_id: string | null; + client_id: string; + name: string | null; + scopes: string[] | null; + revoked: boolean; + created_at: string | null; + updated_at: string | null; + expires_at: string | null; + // relations + client: Client; + user: User; +} + export interface User { // columns id: string; @@ -125,7 +146,9 @@ export interface User { profile_photo_url: string; // relations organizations: Organization[]; + notifications: Notification[]; clients: Client[]; + tokens: Token[]; current_team: Organization; owned_teams: Organization[]; teams: Organization[];