### Example Certificate Configuration Source: https://github.com/tappnetwork/filament-lms/blob/4.x/README.md A comprehensive example demonstrating how to configure various certificate-related settings within the `config/filament-lms.php` file, including branding and specific certificate options. ```php return [ // General branding 'brand_name' => 'Acme Learning Academy', 'brand_logo' => 'images/brand-logo.png', // Certificate-specific settings 'certificate_logo' => 'images/certificate-seal.png', // Use a different logo for certificates 'certificate_show_signatures' => true, // Include signature lines 'certificate_show_id' => true, // Include unique certificate ID // Other settings... ]; ``` -------------------------------- ### User Model Setup for Filament LMS Source: https://context7.com/tappnetwork/filament-lms/llms.txt Implements the FilamentLmsUser trait in your User model to integrate LMS functionalities. This enables course assignments, progress tracking, and step access control. It also shows examples of custom access control methods. ```php courses()->get(); // Get all completed steps // $user->completedSteps()->get(); // Check if user completed a course // $user->hasCompletedCourse($course); // returns bool // Get progress percentage for a course // $user->getCourseProgress($course); // returns float 0-100 // Override to customize step access control public function canAccessStep(Step $step): bool { // Allow admins to access all steps regardless of progress if ($this->hasRole('admin')) { return true; } // Default: check if previous steps are completed return $step->checkPreviousStepsCompleted(); } // Override to control step editing permissions public function canEditStep(Step $step): bool { return $this->hasRole('admin') || $this->hasRole('instructor'); } // Override to implement custom admin logic public function isLmsAdmin(): bool { return $this->hasAnyRole(['admin', 'super_admin']); } // Override course visibility logic public function isCourseVisibleForUser($course): bool { if ($this->hasRole('admin')) { return true; } return $course->users->contains('id', $this->id); } } ``` -------------------------------- ### Clone Filament LMS for Local Development Source: https://github.com/tappnetwork/filament-lms/blob/4.x/README.md This guide suggests cloning the Filament LMS repository into a local 'packages' directory within your project. This is a common practice for local development and testing of package modifications. ```bash mkdir {project}/packages cd {project}/packages git clone https://github.com/tappnetwork/filament-lms ``` -------------------------------- ### Customize Step Access Control in User Model (PHP) Source: https://github.com/tappnetwork/filament-lms/blob/4.x/README.md Provides an example of overriding the `canAccessStep` method in the User model to implement custom logic for controlling user access to course steps. It demonstrates allowing admins full access and falling back to default sequential completion. ```php use Tapp\FilamentLms\Traits\FilamentLmsUser; class User extends Authenticatable { use FilamentLmsUser; // ... public function canAccessStep(Step $step): bool { // Allow admins to access all steps if ($this->hasRole('admin')) { return true; } // Fall back to default behavior (sequential step completion) return parent::canAccessStep($step); } } ``` -------------------------------- ### Install Filament LMS Plugin via Composer Source: https://github.com/tappnetwork/filament-lms/blob/4.x/README.md This command installs the Filament LMS plugin version 4.0 or higher using Composer. Ensure you have added the necessary repositories to your composer.json file beforehand. ```bash composer require tapp/filament-lms:"^4.0" ``` -------------------------------- ### Filament LMS Events Handling - PHP Source: https://context7.com/tappnetwork/filament-lms/llms.txt Shows how to listen to and handle events dispatched by the Filament LMS package for user actions like starting, completing courses, or completing steps. Requires setting up listeners in `EventServiceProvider`. Events include `CourseStarted`, `CourseCompleted`, and `StepCompleted`. ```php [ SendCourseStartedNotification::class, ], CourseCompleted::class => [ SendCompletionCertificate::class, UpdateHubSpotContact::class, ], StepCompleted::class => [ TrackAnalytics::class, ], ]; // CourseStarted listener example class SendCourseStartedNotification { public function handle(CourseStarted $event): void { $user = $event->user; $course = $event->course; // Send welcome email, update CRM, etc. Mail::to($user)->send(new CourseWelcome($course)); } } // CourseCompleted listener example class UpdateHubSpotContact { public function handle(CourseCompleted $event): void { $user = $event->user; $course = $event->course; // Update external system with completion data HubSpot::contacts()->update($user->hubspot_id, [ 'course_progress' => $user->lmsCourseProgress(), ]); } } ``` -------------------------------- ### Customize Step Edit Permissions in User Model (PHP) Source: https://github.com/tappnetwork/filament-lms/blob/4.x/README.md Illustrates how to override the `canEditStep` method in the User model to define custom permissions for editing course steps. This example allows admins and instructors (for their own courses) to edit steps. ```php use Tapp\FilamentLms\Traits\FilamentLmsUser; class User extends Authenticatable { use FilamentLmsUser; // ... public function canEditStep(Step $step): bool { // Allow admins to edit all steps if ($this->hasRole('admin') || $this->hasRole('super_admin')) { return true; } // Allow course creators to edit their own courses if ($this->hasRole('instructor') && $step->lesson->course->created_by === $this->id) { return true; } // No edit permissions for other users return false; } } ``` -------------------------------- ### Publish Filament LMS Migrations Source: https://github.com/tappnetwork/filament-lms/blob/4.x/README.md This Artisan command publishes the migration files for the Filament LMS plugin. It's crucial to run this after installing the plugin and ensuring any dependencies like Filament Form Builder migrations are also published. ```bash php artisan vendor:publish --provider="Tapp\FilamentLms\FilamentLmsServiceProvider" ``` -------------------------------- ### Manually Get Signed Media URL - PHP Source: https://github.com/tappnetwork/filament-lms/blob/4.x/docs/SIGNED_URLS.md Demonstrates how to manually retrieve signed URLs for media from a specific collection or a particular conversion using the getMediaUrl method. ```php // Get signed URL for a specific collection $url = $model->getMediaUrl('images'); // Get signed URL for a specific conversion $url = $model->getMediaUrl('images', 'thumb'); ``` -------------------------------- ### Configure Tailwind CSS v4 for Filament LMS Source: https://github.com/tappnetwork/filament-lms/blob/4.x/README.md This configuration shows how to set up Tailwind CSS v4 with the Filament LMS plugin. It involves installing the necessary Vite plugin, importing the package's CSS, and building your project's assets. ```bash npm install -D @tailwindcss/vite@next ``` ```css @import "tailwindcss"; /* Import the LMS package styles */ @import '../../vendor/tapp/filament-lms/dist/filament-lms.css'; ``` ```bash npm run build ``` -------------------------------- ### Add Composer Repository for Filament LMS Source: https://github.com/tappnetwork/filament-lms/blob/4.x/README.md This JSON configuration adds the Filament LMS plugin and its dependency, Filament Form Builder, as VCS repositories in your composer.json file. This is necessary for installing the plugin directly from its GitHub repository. ```json { "repositories": { "tapp/filament-lms": { "type": "vcs", "url": "https://github.com/tappnetwork/filament-lms" }, "tapp/filament-form-builder": { "type": "vcs", "url": "https://github.com/tappnetwork/filament-form-builder" } } } ``` ```json { "repositories": [ { "type": "vcs", "url": "https://github.com/tappnetwork/filament-lms" }, { "type": "vcs", "url": "https://github.com/TappNetwork/Filament-Form-Builder" } ] } ``` -------------------------------- ### Override Course Image URL Attribute - PHP Source: https://github.com/tappnetwork/filament-lms/blob/4.x/docs/SIGNED_URLS.md Provides an example of how to override the default `getImageUrlAttribute` method in a Course model to implement custom logic for determining the image URL, potentially using signed URLs conditionally. ```php public function getImageUrlAttribute() { // Your custom logic here if ($this->isPremiumContent()) { return $this->getMediaUrl('courses'); } return 'https://picsum.photos/200'; } ``` -------------------------------- ### Retrieve Signed Media URL for Models with HasMediaUrl Trait Source: https://github.com/tappnetwork/filament-lms/blob/4.x/docs/TESTING_SIGNED_URLS.md This PHP code shows how to get a signed URL for media associated with any model that uses the 'HasMediaUrl' trait. It retrieves a document by ID and calls the 'getMediaUrl' method for a specific media collection ('preview'). ```php // For any model using the HasMediaUrl trait $document = Document::find(1); $mediaUrl = $document->getMediaUrl('preview'); // Returns signed URL if enabled, regular URL if disabled echo $mediaUrl; ``` -------------------------------- ### Course Model API: Querying, Relationships, Progress, and Creation Source: https://context7.com/tappnetwork/filament-lms/llms.txt Demonstrates how to query courses, access related lessons and steps, track user progress, and create new course entries. It covers methods for visibility, user accessibility, completion percentages, and test scoring. ```php get(); // Public courses with steps $userCourses = Course::accessibleTo($user)->get(); // Courses user can access // Get course by slug $course = Course::where('slug', 'intro-to-laravel')->firstOrFail(); // Access relationships $lessons = $course->lessons; // Ordered collection of Lesson models $steps = $course->steps; // All steps across all lessons (HasManyThrough) $assignedUsers = $course->users; // Users assigned to this course // Progress tracking $course->loadProgress(); // Eager load progress data for authenticated user $percentage = $course->getCompletionPercentageForUser($userId); // 0-100 $completedAt = $course->completedByUserAt($userId); // DateTime or null $allDone = $course->allStepsCompletedByUser($userId); // bool // Navigation helpers $currentStep = $course->currentStep($user); // First incomplete step $firstStep = $course->firstStep(); // First step in first lesson $resumeUrl = $course->linkToCurrentStep(); // URL to resume course $certUrl = $course->certificateUrl(); // URL to certificate page // Test/Quiz scoring (when course has required_test_percentage) $overallScore = $course->getOverallTestPercentageForUser($userId); // 0-100 $failedStep = $course->getFirstTestStepBelowPerfectForUser($userId); $retryUrl = $course->getUrlToFirstTestStepBelowPerfectForUser($userId); // Access control $canAccess = $course->canBeAccessedBy($user); // Check private/assignment status // Create a new course $course = Course::create([ 'name' => 'Introduction to Laravel', 'slug' => 'intro-to-laravel', 'external_id' => 'intro_to_laravel', // For external integrations 'description' => 'Learn Laravel fundamentals', 'is_private' => false, // Public course 'award' => 'default', // Certificate template 'required_test_percentage' => 80, // Minimum passing score (optional) ]); ``` -------------------------------- ### Lesson Model API: Accessing, Relationships, Progress, and Creation Source: https://context7.com/tappnetwork/filament-lms/llms.txt Details how to access lessons from a course, manage relationships with courses and steps, track lesson progress, and create new lesson entries. It includes methods for checking active status and sorting. ```php lessons()->where('slug', 'getting-started')->first(); // Relationships $course = $lesson->course; $steps = $lesson->steps; // Ordered collection of Step models // Progress $lesson->loadProgress(); // Load step progress for current user $completedAt = $lesson->completed_at; // DateTime when all steps completed // Check if lesson is currently active (user is on a step in this lesson) $isActive = $lesson->isActive(); // Create a lesson $lesson = Lesson::create([ 'course_id' => $course->id, 'name' => 'Getting Started', 'slug' => 'getting-started', 'order' => 1, // Sortable order within course ]); ``` -------------------------------- ### Add Navigation Items to LMS Panel Source: https://github.com/tappnetwork/filament-lms/blob/4.x/README.md Register new navigation items within the LMS panel by utilizing the `boot()` method in your `AppPanelProvider.php` file. This allows for custom links and icons. ```php use Tapp\FilamentLms\LmsNavigation; use Filament\Navigation\NavigationItem; public function boot(): void { LmsNavigation::addNavigation('lms', NavigationItem::make('Home') ->icon('heroicon-o-home') ->url(fn (): string => '/'), ); } ``` -------------------------------- ### Lesson Model API Source: https://context7.com/tappnetwork/filament-lms/llms.txt Lessons serve as ordered containers within a course, grouping related steps and supporting sortable ordering. ```APIDOC ## Lesson Model API ### Description Lessons are ordered containers within a course. They group related steps together and support sortable ordering. ### Methods - **Accessing a Lesson** - `$course->lessons()->where('slug', $slug)->first()`: Retrieves a specific lesson from a course by its slug. - **Accessing Relationships** - `course`: Returns the parent Course model. - `steps`: Returns an ordered collection of Step models associated with the lesson. - **Progress** - `loadProgress()`: Loads step progress for the current user. - `completed_at`: Returns the completion timestamp (DateTime) when all steps in the lesson are completed. - **Status** - `isActive()`: Returns a boolean indicating if the lesson is currently active (user is on a step within this lesson). - **Creating a Lesson** - `create([...])`: Creates a new lesson with the provided attributes. - `course_id` (integer, required): The ID of the parent course. - `name` (string, required): The name of the lesson. - `slug` (string, required): The unique slug for the lesson. - `order` (integer, optional): The sortable order of the lesson within the course. ### Request Example ```php // Access lesson from course $lesson = $course->lessons()->where('slug', 'getting-started')->first(); // Relationships $course = $lesson->course; $steps = $lesson->steps; // Progress $lesson->loadProgress(); $completedAt = $lesson->completed_at; // Check if lesson is currently active $isActive = $lesson->isActive(); // Create a lesson $lesson = Lesson::create([ 'course_id' => $course->id, 'name' => 'Getting Started', 'slug' => 'getting-started', 'order' => 1, ]); ``` ``` -------------------------------- ### Manage Certificate Routes in PHP Source: https://context7.com/tappnetwork/filament-lms/llms.txt Provides routes for viewing and downloading certificates. Supports signed URLs for temporary sharing and requires authentication for downloads. Routes are automatically defined by the package. ```php $course->id, 'user' => $user->id]); // Download certificate as PDF (requires authentication) // GET /lms/certificates/{course}/download route('filament-lms::certificates.download', ['course' => $course]); // Generate a temporary signed URL for certificate sharing use IlluminateSupportFacadesURL; $signedUrl = URL::temporarySignedRoute( 'filament-lms::certificates.show', now()->addDays(7), ['course' => $course->id, 'user' => $user->id] ); ``` -------------------------------- ### Filament LMS Step Model API - PHP Source: https://context7.com/tappnetwork/filament-lms/llms.txt Demonstrates how to interact with the Step Model in Filament LMS. Covers accessing steps, relationships, navigation, progress tracking, and creating different types of steps like video and test. Requires Tapp\FilamentLms\Models\Step and related material models. ```php steps()->where('slug', 'watch-intro-video')->first(); // Relationships $lesson = $step->lesson; $course = $step->lesson->course; $material = $step->material; // Polymorphic: Video, Document, Link, Image, Form, or Test // Navigation $nextStep = $step->next_step; // Next step in lesson or first step of next lesson $isFirst = $step->first_step; // Is first step in course $isLast = $step->last_step; // Is last step in course $url = $step->url; // Full URL to step page // Progress tracking $completedAt = $step->completed_at; // When current user completed $isAvailable = $step->available; // Can current user access this step $seconds = $step->seconds; // Video playback position // Complete a step (tracks progress, fires events) $nextStep = $step->complete($user); // Returns next step or null // Video progress tracking $step->videoProgress(120); // Save video position at 120 seconds // Check if step can be accessed $canAccess = $step->checkPreviousStepsCompleted(); // Create a video step $video = Video::create([ 'name' => 'Introduction Video', 'url' => 'https://vimeo.com/123456789', ]); $step = Step::create([ 'lesson_id' => $lesson->id, 'name' => 'Watch Introduction', 'slug' => 'watch-introduction', 'order' => 1, 'material_type' => 'video', 'material_id' => $video->id, 'is_optional' => false, ]); // Create a test step with retry settings $step = Step::create([ 'lesson_id' => $lesson->id, 'name' => 'Final Quiz', 'slug' => 'final-quiz', 'order' => 5, 'material_type' => 'test', 'material_id' => $test->id, 'require_perfect_score' => true, 'retry_step_id' => $reviewStep->id, // Step to redirect to on failure ]); ``` -------------------------------- ### Configure Tenancy for Filament LMS Source: https://github.com/tappnetwork/filament-lms/blob/4.x/README.md This configuration enables multi-tenancy for the LMS, allowing data to be scoped to different teams or organizations. It requires specifying the tenant model and its relationship name. ```php [ 'enabled' => true, 'model' => \App\Models\Team::class, 'relationship_name' => 'team', // optional 'column' => 'team_id', // optional ], // ... other config ]; ``` -------------------------------- ### Configure Multi-Tenancy for Filament LMS in PHP Source: https://context7.com/tappnetwork/filament-lms/llms.txt Enables multi-tenancy to scope LMS courses and content to specific organizations or teams. This involves configuring the `filament-lms.php` file and ensuring the User model implements the `HasTenants` contract, and the Team model implements `HasName`. ```php // config/filament-lms.php return [ 'tenancy' => [ 'enabled' => true, 'model' => \App\Models\Team::class, 'relationship_name' => 'team', // Optional, defaults to snake_case of model 'column' => 'team_id', // Optional, defaults to relationship_name + '_id' 'slug_attribute' => 'slug', // URL routing attribute ], ]; // User model must implement HasTenants contract use Filament\Models\Contracts\FilamentUser; use Filament\Models\Contracts\HasTenants; use Illuminate\Support\Collection; class User extends Authenticatable implements FilamentUser, HasTenants { public function teams(): BelongsToMany { return $this->belongsToMany(Team::class); } public function getTenants(Panel $panel): Collection { return $this->teams; } public function canAccessTenant(Model $tenant): bool { return $this->teams()->whereKey($tenant)->exists(); } public function canAccessPanel(Panel $panel): bool { return true; } } // Team model must implement HasName use Filament\Models\Contracts\HasName; class Team extends Model implements HasName { public function getFilamentName(): string { return $this->name; } } // Bypass tenant scoping for admin operations $allCourses = Course::withoutTenantScope()->get(); $teamCourses = Course::forTenant($teamId)->get(); ``` -------------------------------- ### Customize Filament LMS Configuration Options in PHP Source: https://context7.com/tappnetwork/filament-lms/llms.txt Allows customization of the LMS appearance and behavior through the `config/filament-lms.php` configuration file. Options include branding, navigation, certificate settings, course visibility, user model configuration, and media handling. ```php 'default', 'font' => 'Poppins', 'brand_name' => 'My Learning Platform', 'brand_logo' => 'images/logo.png', // Path relative to public 'brand_logo_height' => '50px', 'home_url' => '/lms', 'colors' => [ 'primary' => '#3b82f6', ], // Navigation 'top_navigation' => false, // Use sidebar navigation on dashboard 'show_exit_lms_link' => true, // Show "Exit LMS" in user menu // Certificates 'certificate_logo' => 'images/certificate-seal.png', 'certificate_show_signatures' => true, 'certificate_show_id' => true, 'awards' => [ 'default' => 'Default Certificate', 'honors' => 'Honors Certificate', ], // Course visibility 'restrict_course_visibility' => true, // Only show assigned courses // User model configuration 'user_model' => \App\Models\User::class, 'user_search_columns' => ['first_name', 'last_name', 'email'], // Media/file handling (for private storage) 'media' => [ 'use_signed_urls' => true, // Use signed URLs for S3 'signed_url_expiration' => 60, // Minutes ], ]; ``` -------------------------------- ### Configure Certificate Logo Source: https://github.com/tappnetwork/filament-lms/blob/4.x/README.md Set a custom logo for certificates. If not provided, it defaults to the `brand_logo`. Recommended dimensions are a maximum height of 90px. The path can be relative to the public directory or a full URL. ```php 'certificate_logo' => 'images/certificate-logo.png', ``` -------------------------------- ### Implement HasName Contract on Tenant Model Source: https://github.com/tappnetwork/filament-lms/blob/4.x/README.md Implement the HasName contract on the Tenant model (e.g., Team model) to provide a displayable name for the tenant. This is used in various parts of the Filament UI to identify the tenant. ```php use Filament\Models\Contracts\HasName; class Team extends Model implements HasName { public function getFilamentName(): string { return $this->name; } } ``` -------------------------------- ### Course Model API Source: https://context7.com/tappnetwork/filament-lms/llms.txt The Course model serves as the primary container for learning content. It facilitates tracking completion and progress, and provides access to associated lessons and steps. ```APIDOC ## Course Model API ### Description The Course model is the top-level container for learning content. It provides methods for tracking completion, progress, and accessing related lessons and steps. ### Methods - **Querying Courses** - `visible()`: Retrieves all publicly visible courses. - `accessibleTo($user)`: Retrieves courses accessible to a specific user. - **Retrieving a Course** - `where('slug', $slug)->firstOrFail()`: Retrieves a course by its slug. - **Accessing Relationships** - `lessons`: Returns an ordered collection of Lesson models associated with the course. - `steps`: Returns all steps across all lessons (using HasManyThrough). - `users`: Returns users assigned to this course. - **Progress Tracking** - `loadProgress()`: Eager loads progress data for the authenticated user. - `getCompletionPercentageForUser($userId)`: Returns the completion percentage (0-100) for a given user. - `completedByUserAt($userId)`: Returns the completion timestamp (DateTime or null) for a given user. - `allStepsCompletedByUser($userId)`: Returns a boolean indicating if all steps are completed by the user. - **Navigation Helpers** - `currentStep($user)`: Returns the first incomplete step for a given user. - `firstStep()`: Returns the first step in the first lesson. - `linkToCurrentStep()`: Generates a URL to resume the course at the current step. - `certificateUrl()`: Generates a URL to the certificate page for the course. - **Test/Quiz Scoring** - `getOverallTestPercentageForUser($userId)`: Returns the overall test score (0-100) for a given user. - `getFirstTestStepBelowPerfectForUser($userId)`: Identifies the first test step where the user scored below perfect. - `getUrlToFirstTestStepBelowPerfectForUser($userId)`: Generates a URL to the first test step where the user scored below perfect. - **Access Control** - `canBeAccessedBy($user)`: Checks if the course can be accessed by a given user (considering private/assignment status). - **Creating a Course** - `create([...])`: Creates a new course with the provided attributes. - `name` (string, required): The name of the course. - `slug` (string, required): The unique slug for the course. - `external_id` (string, optional): An ID for external integrations. - `description` (string, optional): A description of the course. - `is_private` (boolean, optional): Whether the course is private (defaults to false). - `award` (string, optional): The certificate template to use. - `required_test_percentage` (integer, optional): The minimum passing score for tests (0-100). ### Request Example ```php // Query courses $publicCourses = Course::visible()->get(); $userCourses = Course::accessibleTo($user)->get(); // Get course by slug $course = Course::where('slug', 'intro-to-laravel')->firstOrFail(); // Access relationships $lessons = $course->lessons; $steps = $course->steps; $assignedUsers = $course->users; // Progress tracking $course->loadProgress(); $percentage = $course->getCompletionPercentageForUser($userId); $completedAt = $course->completedByUserAt($userId); $allDone = $course->allStepsCompletedByUser($userId); // Navigation helpers $currentStep = $course->currentStep($user); $firstStep = $course->firstStep(); $resumeUrl = $course->linkToCurrentStep(); $certUrl = $course->certificateUrl(); // Test/Quiz scoring $overallScore = $course->getOverallTestPercentageForUser($userId); $failedStep = $course->getFirstTestStepBelowPerfectForUser($userId); $retryUrl = $course->getUrlToFirstTestStepBelowPerfectForUser($userId); // Access control $canAccess = $course->canBeAccessedBy($user); // Create a new course $course = Course::create([ 'name' => 'Introduction to Laravel', 'slug' => 'intro-to-laravel', 'external_id' => 'intro_to_laravel', 'description' => 'Learn Laravel fundamentals', 'is_private' => false, 'award' => 'default', 'required_test_percentage' => 80, ]); ``` ``` -------------------------------- ### Integrate Course Management with User Resource in PHP Source: https://context7.com/tappnetwork/filament-lms/llms.txt Adds course management capabilities to the User resource in Filament. This includes integrating a relation manager to display assigned courses and a bulk action for assigning multiple courses to selected users. ```php columns([ // ... your columns ]) ->bulkActions([ // Add bulk action to assign multiple courses to selected users AssignCoursesBulkAction::make(), ]); } } ``` -------------------------------- ### Implement User Model Contracts for LMS Tenancy Source: https://github.com/tappnetwork/filament-lms/blob/4.x/README.md Implement the FilamentUser and HasTenants contracts on the User model to manage access to the LMS panel and tenants. This involves defining methods for panel access, tenant relationships, and tenant access checks. ```php use Filament\Models\Contracts\FilamentUser; use Filament\Models\Contracts\HasTenants; use Filament\Panel; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Collection; class User extends Authenticatable implements FilamentUser, HasTenants { // Allow users to access the LMS panel public function canAccessPanel(Panel $panel): bool { return true; // Or add custom logic } // Define the teams relationship public function teams(): BelongsToMany { return $this->belongsToMany(Team::class); } // Return all teams the user can access public function getTenants(Panel $panel): Collection { return $this->teams; } // Check if user can access a specific team public function canAccessTenant(Model $tenant): bool { return $this->teams()->whereKey($tenant)->exists(); } } ``` -------------------------------- ### Filament LMS Custom Navigation - PHP Source: https://context7.com/tappnetwork/filament-lms/llms.txt Illustrates how to add custom navigation items to the Filament LMS panel using `LmsNavigation::addNavigation`. This allows for the inclusion of additional pages or external links. Requires `FilamentNavigationNavigationItem` and `TappFilamentLmsLmsNavigation`. ```php icon('heroicon-o-home') ->url(fn (): string => '/'), ); LmsNavigation::addNavigation('lms', NavigationItem::make('Support') ->icon('heroicon-o-question-mark-circle') ->url('https://support.example.com') ->openUrlInNewTab(), ); // Add navigation using a callback for dynamic URLs LmsNavigation::addNavigation('lms', function () { return NavigationItem::make('My Profile') ->icon('heroicon-o-user') ->url(route('profile.show')); }); } } ``` -------------------------------- ### Configure AWS S3 Private Bucket - PHP Source: https://github.com/tappnetwork/filament-lms/blob/4.x/docs/SIGNED_URLS.md Sets up the AWS S3 filesystem driver for private bucket access. The 'visibility' must be set to 'private' for signed URLs to function correctly. ```php 's3' => [ 'driver' => 's3', 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'region' => env('AWS_DEFAULT_REGION'), 'bucket' => env('AWS_BUCKET'), 'url' => env('AWS_URL'), 'endpoint' => env('AWS_ENDPOINT'), 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), 'throw' => false, 'visibility' => 'private', // Important: Set to private ], ``` -------------------------------- ### Import Filament LMS Styles in CSS Source: https://context7.com/tappnetwork/filament-lms/llms.txt Imports base, component, and utility styles from Tailwind CSS, followed by the specific CSS file for the Filament LMS package. This ensures the package's styles are correctly applied within the application's CSS. ```css /* resources/css/app.css */ @import 'tailwindcss/base'; @import 'tailwindcss/components'; @import 'tailwindcss/utilities'; /* Import LMS package styles */ @import '../../vendor/tapp/filament-lms/dist/filament-lms.css'; ``` -------------------------------- ### Configure Local Storage for Private Access - PHP Source: https://github.com/tappnetwork/filament-lms/blob/4.x/docs/SIGNED_URLS.md Configures the local filesystem driver with private file permissions. This allows signed URLs to be generated even for locally stored files, providing temporary secure access. ```php 'local' => [ 'driver' => 'local', 'root' => storage_path('app'), 'permissions' => [ 'file' => [ 'public' => 0644, 'private' => 0600, ], 'dir' => [ 'public' => 0755, 'private' => 0700, ], ], 'visibility' => 'private', // Set to private for signed URLs ], ``` -------------------------------- ### Integrate User-Course Management in Filament User Resource Source: https://github.com/tappnetwork/filament-lms/blob/4.x/README.md Incorporate the `CoursesRelationManager` and `AssignCoursesBulkAction` into your Filament User resource to manage user-course assignments. This involves importing the necessary classes and registering them within the resource's `getRelations()` and `table()` methods. ```php use Tapp\FilamentLms\RelationManagers\CoursesRelationManager; use Tapp\FilamentLms\Actions\AssignCoursesBulkAction; // In your UserResource.php public static function getRelations(): array { return [ CoursesRelationManager::class, // ... other relation managers ... ]; } public static function table(Table $table): Table { return $table // ... ->bulkActions([ AssignCoursesBulkAction::make(), // ... other bulk actions ... ]); } ``` -------------------------------- ### Default Filament LMS Configuration Source: https://github.com/tappnetwork/filament-lms/blob/4.x/README.md This is the default configuration file for the Filament LMS package. It allows customization of theme, fonts, URLs, branding, and certificate appearance. ```php 'default', 'font' => 'Poppins', 'home_url' => '/lms', 'brand_name' => 'LMS', 'brand_logo' => '', 'brand_logo_height' => null, // Certificate customization 'certificate_logo' => '', // Falls back to brand_logo if not set 'certificate_show_signatures' => true, // Show signature lines on certificates 'certificate_show_id' => true, // Show unique certificate ID 'vite_theme' => '', 'colors' => [], 'awards' => [ 'Default' => 'default', ], 'top_navigation' => false, 'show_exit_lms_link' => true, ]; ``` -------------------------------- ### Configure Tailwind CSS v3 for Filament LMS Source: https://github.com/tappnetwork/filament-lms/blob/4.x/README.md This configuration updates your `tailwind.config.js` to include the views from Filament LMS and Filament Form Builder. It also shows how to import the package's CSS into your main CSS file and build your assets. ```javascript module.exports = { content: [ // ... your existing content paths './vendor/tapp/filament-lms/resources/views/**/*.blade.php', './vendor/tapp/filament-form-builder/resources/views/**/*.blade.php', ], // ... rest of your config } ``` ```css @import 'tailwindcss/base'; @import 'tailwindcss/components'; @import 'tailwindcss/utilities'; /* Import the LMS package styles */ @import '../../vendor/tapp/filament-lms/dist/filament-lms.css'; ``` ```bash npm run build ``` -------------------------------- ### Grade Test Entries with PHP Source: https://context7.com/tappnetwork/filament-lms/llms.txt Allows creation and grading of tests using the Test model with rubric-based scoring. It links tests to Filament forms and grades user entries, returning a score or an exception for errors. Detailed grading information can also be retrieved. ```php 'Laravel Basics Quiz', 'schema' => [...], // Form field definitions ]); $test = Test::create([ 'filament_form_id' => $form->id, 'filament_form_user_id' => $rubricEntry->id, // Answer key entry ]); // Grade a user's entry $userEntry = FilamentFormUser::where('user_id', $userId) ->where('filament_form_id', $form->id) ->first(); $score = $test->gradeEntry($userEntry); // Returns float 0-100 or Exception if ($score instanceof Exception) { // Handle grading error (rubric mismatch, etc.) Log::error($score->getMessage()); } else { echo "Score: {$score}%"; } // Get detailed grading with correct answers $detailed = $test->gradedKeyValueEntry($userEntry); // Returns: ['question_field' => ['answer' => 'user answer', 'correct' => bool, 'correct_answer' => '...']] ``` -------------------------------- ### Configure Tailwind CSS for Filament LMS in JavaScript Source: https://context7.com/tappnetwork/filament-lms/llms.txt Sets up Tailwind CSS v3 to include the package's view styles by specifying paths to the package's Blade views in the `content` configuration. This ensures that the package's styles are processed by Tailwind. ```javascript // tailwind.config.js (Tailwind v3) module.exports = { content: [ './resources/views/**/*.blade.php', './vendor/tapp/filament-lms/resources/views/**/*.blade.php', './vendor/tapp/filament-form-builder/resources/views/**/*.blade.php', ], // ... } ``` -------------------------------- ### Enable Signed URLs in Filament LMS Configuration Source: https://github.com/tappnetwork/filament-lms/blob/4.x/docs/TESTING_SIGNED_URLS.md This snippet shows how to enable and configure signed URLs for media in the Filament LMS configuration file. It involves setting the 'use_signed_urls' option to true and defining the 'signed_url_expiration' in minutes. ```php // In your project's config/filament-lms.php 'media' => [ 'use_signed_urls' => true, 'signed_url_expiration' => 60, ], ``` -------------------------------- ### Control Certificate ID Display Source: https://github.com/tappnetwork/filament-lms/blob/4.x/README.md Manage the visibility of the unique certificate ID on certificates. The default setting is `true`. Displaying the ID aids in verification and tracking of issued certificates. ```php 'certificate_show_id' => true, // Show unique certificate ID 'certificate_show_id' => false, // Hide certificate ID ``` -------------------------------- ### Configure Private Storage for S3 in Laravel Source: https://github.com/tappnetwork/filament-lms/blob/4.x/docs/TESTING_SIGNED_URLS.md This PHP code configures the 's3' filesystem disk in Laravel's 'filesystems.php' to use private visibility. This is a crucial step for signed URLs to work correctly with AWS S3, ensuring media is not publicly accessible. ```php // In config/filesystems.php 's3' => [ 'driver' => 's3', 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'region' => env('AWS_DEFAULT_REGION'), 'bucket' => env('AWS_BUCKET'), 'visibility' => 'private', // Important: Set to private ], ``` -------------------------------- ### Override Course Visibility Logic in User Model (PHP) Source: https://github.com/tappnetwork/filament-lms/blob/4.x/README.md Demonstrates how to override the `isCourseVisibleForUser` method from the `FilamentLmsUser` trait to implement custom logic for determining course visibility. It shows how to alias the original trait method for conditional calls. ```php use Tapp\FilamentLms\Traits\FilamentLmsUser; class User extends Authenticatable { use FilamentLmsUser { FilamentLmsUser::isCourseVisibleForUser as filamentLmsIsCourseVisibleForUser; } // ... public function isCourseVisibleForUser($course): bool { if ($this->hasAnyRole('admin', 'super_admin')) { return true; } // Call the trait's original method return $this->filamentLmsIsCourseVisibleForUser($course); } } ``` -------------------------------- ### Register Filament LMS Plugin in Admin Panel Source: https://context7.com/tappnetwork/filament-lms/llms.txt Registers the Filament LMS plugin within your Filament admin panel configuration. This makes the LMS resources (Courses, Lessons, Steps, etc.) available in the admin interface. ```php default() ->id('admin') ->path('admin') ->plugins([ // Register the LMS plugin - adds Course, Lesson, Step, Video, // Document, Link, Test, and Image resources to admin panel Lms::make(), ]); } } ``` -------------------------------- ### Configure Signed URLs for Media - PHP Source: https://github.com/tappnetwork/filament-lms/blob/4.x/docs/SIGNED_URLS.md Enables signed URLs for private storage and sets the expiration time in minutes. This configuration is crucial for secure media access. ```php 'media' => [ // Enable signed URLs for private storage 'use_signed_urls' => true, // Expiration time in minutes (default: 60) 'signed_url_expiration' => 60, ] ``` -------------------------------- ### Control Certificate Signature Display Source: https://github.com/tappnetwork/filament-lms/blob/4.x/README.md Determine whether signature lines are shown on certificates. The default value is `true`. When enabled, lines for an authorized signature and the learner's signature will appear. ```php 'certificate_show_signatures' => true, // Show signature lines 'certificate_show_signatures' => false, // Hide signature lines ``` -------------------------------- ### Define Authorization Gates in PHP Source: https://context7.com/tappnetwork/filament-lms/llms.txt Defines authorization gates to control access to specific features within the LMS, such as the reporting page. This involves using the Gate facade to create new authorization rules based on user roles or permissions. ```php hasRole('admin') || $user->hasPermission('view-lms-reporting'); }); } } ``` -------------------------------- ### Use HasMediaUrl Trait for Model Media - PHP Source: https://github.com/tappnetwork/filament-lms/blob/4.x/docs/SIGNED_URLS.md Applies the HasMediaUrl trait to Eloquent models to automatically handle signed URLs for media collections. Requires the HasMedia interface. ```php use Tapp\FilamentLms\Traits\HasMediaUrl; class YourModel extends Model implements HasMedia { use HasMediaUrl; public function getImageUrlAttribute() { return $this->getMediaUrl('your-collection'); } } ``` -------------------------------- ### Define LMS Reporting Authorization Gate Source: https://github.com/tappnetwork/filament-lms/blob/4.x/README.md Implement authorization for the LMS reporting page by defining a 'viewLmsReporting' Gate in your application's `AuthServiceProvider`. This controls user access based on roles or permissions. ```php use Illuminate\Support\Facades\Gate; class AuthServiceProvider extends ServiceProvider { public function boot() { Gate::define('viewLmsReporting', function ($user) { // Customize this based on your application's needs return $user->hasRole('admin') || $user->hasPermission('view-lms-reporting'); }); } } ``` -------------------------------- ### Add Filament LMS Plugin to Admin Panel Source: https://github.com/tappnetwork/filament-lms/blob/4.x/README.md This PHP code snippet demonstrates how to register the Filament LMS plugin within your Filament Admin Panel configuration. It's typically added to the `panel()` method of your `AdminPanelProvider` class. ```php use Filament\Panel; use Filament\PanelProvider; class AdminPanelProvider extends PanelProvider { public function panel(Panel $panel): Panel { return $panel ->plugins([ \Tapp\FilamentLms\Lms::make(), ]) } } ``` -------------------------------- ### Retrieve Signed URL for Course Image Source: https://github.com/tappnetwork/filament-lms/blob/4.x/docs/TESTING_SIGNED_URLS.md This PHP snippet demonstrates how to retrieve a signed URL for a course image after enabling signed URLs. It finds a course by ID and accesses its 'image_url' property, which should now contain AWS signature parameters. ```php $course = Course::find(1); $imageUrl = $course->image_url; // Should return a signed URL with AWS signature parameters echo $imageUrl; // Contains X-Amz-Signature, X-Amz-Credential, etc. ```