├── Config ├── .gitkeep └── config.php ├── Database ├── Migrations │ ├── .gitkeep │ ├── 2015_08_28_222414_create_courses_table.php │ ├── 2015_08_28_233909_create_modules_table.php │ ├── 2015_08_28_234514_create_lessons_table.php │ ├── 2015_08_30_154023_create_lesson_user_table.php │ └── 2015_08_30_195138_create_comments_lesson_table.php └── Seeders │ ├── .gitkeep │ └── CourseTableSeeder.php ├── Entities ├── .gitkeep ├── Comment.php ├── Course.php ├── Lesson.php └── Module.php ├── Http ├── Controllers │ ├── .gitkeep │ ├── Admin │ │ └── CourseController.php │ └── Learning │ │ ├── CommentController.php │ │ ├── CourseController.php │ │ └── LessonController.php ├── Middleware │ └── .gitkeep ├── Requests │ ├── .gitkeep │ └── Learning │ │ └── CommentRequest.php └── routes.php ├── LICENSE ├── Providers ├── .gitkeep └── CourseServiceProvider.php ├── README.md ├── Repositories ├── .gitkeep ├── CommentRepository.php ├── CourseRepository.php ├── LessonRepository.php └── ModuleRepository.php ├── Resources └── lang │ ├── .gitkeep │ ├── en │ ├── index.php │ ├── lesson │ │ └── show.php │ └── show.php │ └── es │ ├── index.php │ ├── lesson │ └── show.php │ └── show.php ├── composer.json ├── module.json └── start.php /Config/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LMS-Laravel/Course/576ca41c88dc8331af71c6aee921f98d56947a9c/Config/.gitkeep -------------------------------------------------------------------------------- /Config/config.php: -------------------------------------------------------------------------------- 1 | 'Course' 5 | ]; -------------------------------------------------------------------------------- /Database/Migrations/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LMS-Laravel/Course/576ca41c88dc8331af71c6aee921f98d56947a9c/Database/Migrations/.gitkeep -------------------------------------------------------------------------------- /Database/Migrations/2015_08_28_222414_create_courses_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | 19 | $table->string('name'); 20 | $table->string('description'); 21 | $table->enum('level', [1, 2, 3]); 22 | $table->boolean('type')->default(0); 23 | $table->integer('teacher_id')->unsigned(); 24 | $table->string('slug')->unique(); 25 | //foreign keys 26 | $table->foreign('teacher_id')->references('id')->on('users'); 27 | 28 | $table->timestamps(); 29 | $table->softDeletes(); 30 | }); 31 | } 32 | 33 | /** 34 | * Reverse the migrations. 35 | * 36 | * @return void 37 | */ 38 | public function down() 39 | { 40 | Schema::drop('courses'); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Database/Migrations/2015_08_28_233909_create_modules_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | 19 | $table->string('name'); 20 | $table->string('description'); 21 | $table->integer('course_id')->unsigned(); 22 | $table->string('slug')->unique(); 23 | $table->foreign('course_id')->references('id')->on('courses'); 24 | 25 | $table->timestamps(); 26 | $table->softDeletes(); 27 | }); 28 | } 29 | 30 | /** 31 | * Reverse the migrations. 32 | * 33 | * @return void 34 | */ 35 | public function down() 36 | { 37 | Schema::drop('modules'); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /Database/Migrations/2015_08_28_234514_create_lessons_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | 19 | $table->string('title'); 20 | $table->longText('content'); 21 | $table->string('resource')->nullable(); //is video then id video 22 | $table->string('download')->nullable(); //file for download 23 | // 1 is video 24 | $table->boolean('type')->default(1); //type lessons 1 is video, 0 is letter 25 | $table->integer('module_id')->unsigned(); 26 | $table->integer('teacher_id')->unsigned();; 27 | $table->string('slug')->unique(); 28 | 29 | //foreign key 30 | $table->foreign('module_id')->references('id')->on('modules'); 31 | $table->foreign('teacher_id')->references('id')->on('users'); 32 | 33 | $table->timestamps(); 34 | $table->softDeletes(); 35 | }); 36 | } 37 | 38 | /** 39 | * Reverse the migrations. 40 | * 41 | * @return void 42 | */ 43 | public function down() 44 | { 45 | Schema::drop('lessons'); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /Database/Migrations/2015_08_30_154023_create_lesson_user_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | 19 | $table->integer('user_id')->unsigned(); 20 | $table->integer('lesson_id')->unsigned(); 21 | 22 | $table->foreign('lesson_id')->references('id')->on('lessons'); 23 | $table->foreign('user_id')->references('id')->on('users'); 24 | 25 | $table->timestamps(); 26 | $table->softDeletes(); 27 | }); 28 | } 29 | 30 | /** 31 | * Reverse the migrations. 32 | * 33 | * @return void 34 | */ 35 | public function down() 36 | { 37 | Schema::drop('lesson_user'); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /Database/Migrations/2015_08_30_195138_create_comments_lesson_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 18 | 19 | $table->text('comment'); 20 | $table->integer('lesson_id')->unsigned(); 21 | $table->integer('user_id')->unsigned(); 22 | 23 | $table->foreign('user_id')->references('id')->on('users'); 24 | $table->foreign('lesson_id')->references('id')->on('lessons'); 25 | 26 | $table->timestamps(); 27 | $table->softDeletes(); 28 | }); 29 | } 30 | 31 | /** 32 | * Reverse the migrations. 33 | * 34 | * @return void 35 | */ 36 | public function down() 37 | { 38 | Schema::drop('comments_lesson'); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /Database/Seeders/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LMS-Laravel/Course/576ca41c88dc8331af71c6aee921f98d56947a9c/Database/Seeders/.gitkeep -------------------------------------------------------------------------------- /Database/Seeders/CourseTableSeeder.php: -------------------------------------------------------------------------------- 1 | courseSeeder(); 25 | $this->moduleSeeder(); 26 | $this->lessonSeeder(); 27 | } 28 | 29 | private function courseSeeder() 30 | { 31 | $faker = Faker::create(); 32 | 33 | foreach(range(1, 5) as $index) 34 | { 35 | Course::create([ 36 | 'name'=> $faker->text(20), 37 | 'description'=> $faker->text(300), 38 | 'level'=> $faker->numberBetween(1, 3), 39 | 'type' => $faker->numberBetween(0, 1), 40 | 'teacher_id'=>1, 41 | ]); 42 | } 43 | 44 | } 45 | 46 | private function moduleSeeder() 47 | { 48 | $faker = Faker::create(); 49 | 50 | foreach(range(1, 20) as $index) 51 | { 52 | Module::create([ 53 | 'name' => $faker->text(20), 54 | 'description' => $faker->text(100), 55 | 'course_id' => $faker->numberBetween(1, 5) 56 | ]); 57 | } 58 | } 59 | 60 | private function lessonSeeder() 61 | { 62 | $faker = Faker::create(); 63 | 64 | foreach(range(1, 100) as $index) 65 | { 66 | Lesson::create([ 67 | 'title' => $faker->text(20), 68 | 'content' => $faker->text(1000), 69 | 'resource' => '06olHmcJjS0', 70 | 'download' => $faker->url, 71 | 'type' => $faker->numberBetween(0,1), 72 | 'module_id' => $faker->numberBetween(1, 20), 73 | 'teacher_id' => 1 74 | ]); 75 | } 76 | } 77 | 78 | } -------------------------------------------------------------------------------- /Entities/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LMS-Laravel/Course/576ca41c88dc8331af71c6aee921f98d56947a9c/Entities/.gitkeep -------------------------------------------------------------------------------- /Entities/Comment.php: -------------------------------------------------------------------------------- 1 | belongsTo(User::class); 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /Entities/Course.php: -------------------------------------------------------------------------------- 1 | 'name', 16 | 'save_to' => 'slug', 17 | ]; 18 | 19 | public function modules() 20 | { 21 | return $this->hasMany(Module::class); 22 | } 23 | 24 | public function teacher() 25 | { 26 | return $this->hasOne(User::class, 'id', 'teacher_id'); 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /Entities/Lesson.php: -------------------------------------------------------------------------------- 1 | 'title', 17 | 'save_to' => 'slug', 18 | ]; 19 | 20 | public function module() 21 | { 22 | return $this->belongsTo(Module::class); 23 | } 24 | 25 | public function teacher() 26 | { 27 | return $this->belongsTo(User::class); 28 | } 29 | 30 | public function students() 31 | { 32 | return $this->belongsToMany(User::class)->withTimestamps(); 33 | } 34 | 35 | public function comments() 36 | { 37 | return $this->hasMany(Comment::class); 38 | } 39 | 40 | public function getViewAttribute() 41 | { 42 | $status = $this::whereHas('students', function($q) 43 | { 44 | $q->where('user_id', '=', \Auth::user()->id); 45 | $q->where('lesson_id', '=', $this->id); 46 | 47 | })->get(); 48 | 49 | if($status->isEmpty()) return false; 50 | 51 | return true; 52 | } 53 | 54 | } -------------------------------------------------------------------------------- /Entities/Module.php: -------------------------------------------------------------------------------- 1 | 'name', 16 | 'save_to' => 'slug', 17 | ]; 18 | 19 | public function lessons() 20 | { 21 | return $this->hasMany(Lesson::class); 22 | } 23 | 24 | public function course() 25 | { 26 | return $this->belongsTo(Course::class); 27 | } 28 | } -------------------------------------------------------------------------------- /Http/Controllers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LMS-Laravel/Course/576ca41c88dc8331af71c6aee921f98d56947a9c/Http/Controllers/.gitkeep -------------------------------------------------------------------------------- /Http/Controllers/Admin/CourseController.php: -------------------------------------------------------------------------------- 1 | comment = $comment; 17 | } 18 | 19 | public function store(CommentRequest $request) 20 | { 21 | $lesson = $request->only(['lesson_id']); 22 | $this->comment->create($request->all()); 23 | 24 | return redirect(route('learning.lesson.show', $lesson->slug)); 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /Http/Controllers/Learning/CourseController.php: -------------------------------------------------------------------------------- 1 | course = $course; 17 | } 18 | 19 | public function index() 20 | { 21 | $courses = $this->course->all(); 22 | return \Theme::view('courses/learning/index', compact('courses')); 23 | } 24 | 25 | public function show($id) 26 | { 27 | $course = $this->course->with(['modules'])->findBySlugOrIdOrFail($id); 28 | $modules = $course->modules; 29 | $courses = $this->course->all(); 30 | $sharer = \Share::load(route('learning.course.show', $course->slug), trans('course::show.messages.sharer', ['name'=>$course->name]))->services('facebook', 'gplus', 'twitter'); 31 | 32 | return \Theme::view('courses/learning/show', compact('course', 'modules', 'sharer', 'courses')); 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /Http/Controllers/Learning/LessonController.php: -------------------------------------------------------------------------------- 1 | lesson = $lesson; 22 | $this->course = $course; 23 | } 24 | 25 | public function show($id) 26 | { 27 | $lesson = $this->lesson->findBySlugOrIdOrFail($id); 28 | $courses = $this->course->all(); 29 | 30 | if(!$lesson->view) 31 | { 32 | \Auth::user()->lessons()->attach($lesson->id); 33 | \Auth::user()->points += 10; 34 | \Auth::user()->save(); 35 | }; 36 | 37 | if($lesson->type == 1){ 38 | $video = $lesson->resource; 39 | return \Theme::view('lessons/learning/video', compact('lesson', 'courses', 'video')); 40 | } 41 | else{ 42 | return \Theme::view('lessons/learning/letter', compact('lesson', 'courses')); 43 | } 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /Http/Middleware/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LMS-Laravel/Course/576ca41c88dc8331af71c6aee921f98d56947a9c/Http/Middleware/.gitkeep -------------------------------------------------------------------------------- /Http/Requests/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LMS-Laravel/Course/576ca41c88dc8331af71c6aee921f98d56947a9c/Http/Requests/.gitkeep -------------------------------------------------------------------------------- /Http/Requests/Learning/CommentRequest.php: -------------------------------------------------------------------------------- 1 | method()) 25 | { 26 | case 'POST': 27 | { 28 | return $this->post(); 29 | } 30 | case 'PATCH': 31 | { 32 | return $this->patch(); 33 | } 34 | default: return []; 35 | } 36 | } 37 | 38 | private function post() 39 | { 40 | return [ 41 | 'comment' => 'required', 42 | 'lesson_id' => 'required|exists:lessons,id', 43 | 'user_id' => 'required|exists:users,id' 44 | ]; 45 | } 46 | 47 | private function patch() 48 | { 49 | return [ 50 | 'comment' => 'required', 51 | ]; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /Http/routes.php: -------------------------------------------------------------------------------- 1 | 'admin', 'namespace' => 'Modules\Course\Http\Controllers\Admin'], function(){ 4 | 5 | Route::resource('course', 'CourseController', 6 | ['except' => ['create', 'store', 'update', 'destroy']] 7 | ); 8 | 9 | }); 10 | 11 | Route::group(['prefix' => 'learning', 'namespace' => 'Modules\Course\Http\Controllers\Learning', 'middleware' => 'auth'], function(){ 12 | 13 | Route::resource('course', 'CourseController', 14 | ['only' => ['index', 'show']] 15 | ); 16 | 17 | Route::resource('lesson', 'LessonController', 18 | ['only' => ['index', 'show']] 19 | ); 20 | 21 | Route::resource('comment', 'CommentController', 22 | ['only' => ['store']] 23 | ); 24 | 25 | }); 26 | 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 LMS Laravel 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Providers/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LMS-Laravel/Course/576ca41c88dc8331af71c6aee921f98d56947a9c/Providers/.gitkeep -------------------------------------------------------------------------------- /Providers/CourseServiceProvider.php: -------------------------------------------------------------------------------- 1 | registerConfig(); 22 | $this->registerTranslations(); 23 | $this->registerViews(); 24 | } 25 | 26 | /** 27 | * Register the service provider. 28 | * 29 | * @return void 30 | */ 31 | public function register() 32 | { 33 | // 34 | } 35 | 36 | /** 37 | * Register config. 38 | * 39 | * @return void 40 | */ 41 | protected function registerConfig() 42 | { 43 | $this->publishes([ 44 | __DIR__.'/../Config/config.php' => config_path('course.php'), 45 | ]); 46 | $this->mergeConfigFrom( 47 | __DIR__.'/../Config/config.php', 'course' 48 | ); 49 | } 50 | 51 | /** 52 | * Register views. 53 | * 54 | * @return void 55 | */ 56 | public function registerViews() 57 | { 58 | $viewPath = base_path('resources/views/modules/course'); 59 | 60 | $sourcePath = __DIR__.'/../Resources/views'; 61 | 62 | $this->publishes([ 63 | $sourcePath => $viewPath 64 | ]); 65 | 66 | $this->loadViewsFrom([$viewPath, $sourcePath], 'course'); 67 | } 68 | 69 | /** 70 | * Register translations. 71 | * 72 | * @return void 73 | */ 74 | public function registerTranslations() 75 | { 76 | $langPath = base_path('resources/lang/modules/course'); 77 | 78 | if (is_dir($langPath)) { 79 | $this->loadTranslationsFrom($langPath, 'course'); 80 | } else { 81 | $this->loadTranslationsFrom(__DIR__ .'/../Resources/lang', 'course'); 82 | } 83 | } 84 | 85 | /** 86 | * Get the services provided by the provider. 87 | * 88 | * @return array 89 | */ 90 | public function provides() 91 | { 92 | return array(); 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Course 2 | Module Course for LMS Laravel 3 | -------------------------------------------------------------------------------- /Repositories/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LMS-Laravel/Course/576ca41c88dc8331af71c6aee921f98d56947a9c/Repositories/.gitkeep -------------------------------------------------------------------------------- /Repositories/CommentRepository.php: -------------------------------------------------------------------------------- 1 | [ 5 | 'welcome' => 'Welcome to ', 6 | 'description' => 'Catalogue courses' 7 | ], 8 | 9 | 'btn' =>[ 10 | 'module' => 'Modules', 11 | 'favorite' => 'Favorites', 12 | ], 13 | ]; -------------------------------------------------------------------------------- /Resources/lang/en/lesson/show.php: -------------------------------------------------------------------------------- 1 | [ 5 | 'welcome' => 'Welcome to lesson ', 6 | 'course' => 'Course', 7 | 'teacher' => 'Teacher', 8 | 'comments' => 'Comments', 9 | ], 10 | 11 | 'btn' =>[ 12 | 'module' => 'Modules', 13 | 'favorite' => 'Favorites', 14 | 'go-course' => 'Go to course', 15 | 'comment' => 'Comment', 16 | 'download' => 'Donwload archive', 17 | ], 18 | 19 | 'textbox' =>[ 20 | 'comment' => 'You comment' 21 | ] 22 | ]; -------------------------------------------------------------------------------- /Resources/lang/en/show.php: -------------------------------------------------------------------------------- 1 | [ 5 | 'sharer' => 'Recomiendo el curso :name de PVA via @academyphp', 6 | 'welcome' => 'Welcome to ', 7 | 'modules' => 'Modules', 8 | 'teacher' => 'Teacher' 9 | ], 10 | 11 | 'btn' =>[ 12 | 'module' => 'Modules', 13 | 'favorite' => 'Favorite', 14 | 'video' => 'Is Video', 15 | 'note' => 'Is Note', 16 | 'view' => 'Viewed' 17 | ], 18 | ]; -------------------------------------------------------------------------------- /Resources/lang/es/index.php: -------------------------------------------------------------------------------- 1 | [ 5 | 'welcome' => 'Bienvenido a ', 6 | 'description' => 'Catalogo de cursos' 7 | ], 8 | 9 | 'btn' =>[ 10 | 'module' => 'Modulos', 11 | 'favorite' => 'Favorito', 12 | ], 13 | ]; -------------------------------------------------------------------------------- /Resources/lang/es/lesson/show.php: -------------------------------------------------------------------------------- 1 | [ 5 | 'welcome' => 'Bienvenido a la clase ', 6 | 'course' => 'Curso', 7 | 'teacher' => 'Profesor', 8 | 'comments' => 'Comentarios', 9 | ], 10 | 11 | 'btn' =>[ 12 | 'module' => 'Modulos', 13 | 'favorite' => 'Favorito', 14 | 'go-course' => 'Ir al curso', 15 | 'comment' => 'Comentar', 16 | 'download' => 'Descargar archivos', 17 | ], 18 | 19 | 'textbox' =>[ 20 | 'comment' => 'Tu comentario' 21 | ] 22 | ]; -------------------------------------------------------------------------------- /Resources/lang/es/show.php: -------------------------------------------------------------------------------- 1 | [ 5 | 'sharer' => 'Recomiendo el curso :name de PVA via @academyphp', 6 | 'welcome' => 'Welocome to ', 7 | 'modules' => 'Modulos', 8 | 'teacher' => 'Profesor' 9 | ], 10 | 11 | 'btn' =>[ 12 | 'module' => 'Modulos', 13 | 'favorite' => 'Favorito', 14 | 'video' => 'Es video', 15 | 'note' => 'Es nota', 16 | 'view' => 'Ya la viste' 17 | ], 18 | ]; -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lms-laravel/course", 3 | "type": "asgard-module", 4 | "description": "Module Course for LMS Laravel", 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "Angel Kurten", 9 | "email": "angelkurten@gmail.com" 10 | } 11 | ], 12 | "require": { 13 | "composer/installers": "~1.0" 14 | }, 15 | "autoload": { 16 | "psr-4": { 17 | "Modules\\Course\\": "" 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /module.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Course", 3 | "alias": "course", 4 | "description": "Module for courses LMS-Laravel", 5 | "keywords": [], 6 | "active": 1, 7 | "order": 2, 8 | "providers": [ 9 | "Modules\\Course\\Providers\\CourseServiceProvider" 10 | ], 11 | "aliases":{}, 12 | "files": [ 13 | "start.php" 14 | ] 15 | } -------------------------------------------------------------------------------- /start.php: -------------------------------------------------------------------------------- 1 |