Simple learning management system with managing courses and lessons, and viewing them from the student panel.
The project has 3 main parts:
description
has a rich text editorlesson_text
has a rich text editorMy Courses
pageLesson pages have HasParentResource
trait:
app/Filament/Traits/HasParentResource.php
namespace App\Filament\Traits; use Exception;use Illuminate\Database\Eloquent\Builder;use Illuminate\Database\Eloquent\Model;use Illuminate\Database\Eloquent\ModelNotFoundException; trait HasParentResource{ public Model|int|string|null $parent = null; public function bootHasParentResource(): void { if ($parent = (request()->route('parent') ?? request()->input('parent'))) { $parentResource = $this->getParentResource(); $this->parent = $parentResource::resolveRecordRouteBinding($parent); if (! $this->parent) { throw new ModelNotFoundException(); } } } public function getParentResource(): string { if (! isset(static::$parentResource)) { throw new Exception('Parent resource is not set for ' . static::class); } return static::$parentResource; } protected function applyFiltersToTableQuery(Builder $query): Builder { return $query->where(str($this->parent?->getTable())->singular()->append('_id'), $this->parent->getKey()); } public function getBreadcrumbs(): array { $resource = $this->getResource(); $parentResource = $this->getParentResource(); $breadcrumbs = [ $parentResource::getUrl() => $parentResource::getBreadCrumb(), '#parent' => $parentResource::getRecordTitle($this->parent), ]; // Breadcrumb to child.index or parent.view $childIndex = $resource::getPluralModelLabel() . '.index'; $parentView = 'view'; if ($parentResource::hasPage($childIndex)) { $url = $parentResource::getUrl($childIndex, ['parent' => $this->parent]); $breadcrumbs[$url] = $resource::getBreadCrumb(); } elseif ($parentResource::hasPage($parentView)) { $url = $parentResource::getUrl($parentView, ['record' => $this->parent]); $breadcrumbs[$url] = $resource::getBreadCrumb(); } if (isset($this->record)) { $breadcrumbs['#'] = $resource::getRecordTitle($this->record); } $breadcrumbs[] = $this->getBreadCrumb(); return $breadcrumbs; }}
Course resource has custom action to manage lessons and has routes for...