├── .env.example ├── .gitattributes ├── .gitignore ├── .jshintrc ├── .scss-lint.yml ├── Homestead.yaml.example ├── LICENSE ├── Vagrantfile ├── app ├── Console │ ├── Commands │ │ └── Inspire.php │ └── Kernel.php ├── Course.php ├── Events │ └── Event.php ├── Exceptions │ └── Handler.php ├── Http │ ├── Controllers │ │ ├── Auth │ │ │ ├── AuthController.php │ │ │ └── PasswordController.php │ │ ├── Controller.php │ │ ├── ControllerImageUploaderInterface.php │ │ ├── CoursesController.php │ │ ├── HomeController.php │ │ ├── LessonFilesController.php │ │ ├── LessonsController.php │ │ └── UserController.php │ ├── Kernel.php │ ├── Middleware │ │ ├── Authenticate.php │ │ ├── EncryptCookies.php │ │ ├── IsAdministrator.php │ │ ├── RedirectIfAuthenticated.php │ │ └── VerifyCsrfToken.php │ ├── Requests │ │ └── Request.php │ └── routes.php ├── Jobs │ └── Job.php ├── Lecturer.php ├── Lesson.php ├── LessonFile.php ├── Listeners │ └── .gitkeep ├── Policies │ ├── .gitkeep │ ├── CoursePolicy.php │ └── UserPolicy.php ├── Providers │ ├── AppServiceProvider.php │ ├── AuthServiceProvider.php │ ├── EventServiceProvider.php │ └── RouteServiceProvider.php ├── Role.php ├── Student.php ├── Uploaders │ ├── AvatarUploader.php │ ├── CourseImageUploader.php │ └── ImageUploader.php ├── User.php └── helpers.php ├── artisan ├── bootstrap ├── app.php ├── autoload.php └── cache │ └── .gitignore ├── composer.json ├── composer.lock ├── config ├── app.php ├── auth.php ├── broadcasting.php ├── cache.php ├── compile.php ├── constants.php ├── database.php ├── filesystems.php ├── mail.php ├── queue.php ├── services.php ├── session.php └── view.php ├── database ├── .gitignore ├── factories │ └── ModelFactory.php ├── migrations │ ├── .gitkeep │ ├── 2014_10_12_100000_create_password_resets_table.php │ ├── 2016_05_17_082113_create_courses_table.php │ ├── 2016_05_17_090322_create_lessons_table.php │ ├── 2016_05_17_111743_create_lesson_files_table.php │ ├── 2016_05_23_114206_create_roles_table.php │ ├── 2016_05_23_122620_create_users_table.php │ ├── 2016_05_23_122621_create_user_role_table.php │ ├── 2016_05_24_045028_create_students_table.php │ ├── 2016_05_24_045029_create_course_student_table.php │ ├── 2016_05_24_092415_create_lecturers_table.php │ ├── 2016_05_24_092744_create_course_lecturer_table.php │ ├── 2016_05_28_202808_add_published_to_lessons_table.php │ ├── 2016_06_06_075208_add_image_to_courses_table.php │ ├── 2016_06_14_065038_add_avatar_to_users.php │ └── 2016_06_19_060821_add_company_to_users.php └── seeds │ ├── .gitkeep │ ├── CoursesTableSeeder.php │ ├── DatabaseSeeder.php │ ├── RolesTableSeeder.php │ └── UsersTableSeeder.php ├── gulp ├── config.js └── tasks │ ├── js-hint.js │ └── scss-lint.js ├── gulpfile.js ├── package.json ├── phpunit.xml ├── public ├── .htaccess ├── build │ ├── css │ │ ├── app-1e9ab7fbcf.css │ │ └── app.css.map │ ├── js │ │ ├── app-d3533d7945.js │ │ └── app.js.map │ └── rev-manifest.json ├── css │ ├── app.css │ └── app.css.map ├── favicon.ico ├── img │ ├── bg │ │ ├── all_courses.jpg │ │ ├── home.jpg │ │ └── users.jpg │ └── icons │ │ ├── cancel.svg │ │ ├── courses.svg │ │ ├── create_avatar.svg │ │ ├── create_course.svg │ │ ├── create_user.svg │ │ ├── delete.svg │ │ ├── file.svg │ │ ├── home.svg │ │ ├── lecturers.svg │ │ ├── pencil.svg │ │ ├── save.svg │ │ ├── settings.svg │ │ └── students.svg ├── index.php ├── js │ ├── app.js │ ├── app.js.map │ ├── main.js │ └── main.js.map ├── robots.txt ├── uploads │ └── .gitkeep └── web.config ├── readme.md ├── resources ├── assets │ ├── js │ │ ├── course.js │ │ ├── custom-event.js │ │ ├── editable-object.js │ │ ├── editor.js │ │ ├── helper.js │ │ ├── highlighter.js │ │ ├── img-uploader.js │ │ ├── lesson.js │ │ ├── main.js │ │ ├── notifications.js │ │ ├── tabs.js │ │ ├── user.js │ │ ├── vendor │ │ │ └── highlight.pack.js │ │ └── xhr.js │ └── sass │ │ ├── abstracts │ │ ├── _flexbox.scss │ │ ├── _mixins.scss │ │ ├── _placeholders.scss │ │ └── _variables.scss │ │ ├── app.scss │ │ ├── base │ │ ├── _animations.scss │ │ ├── _base.scss │ │ └── _helpers.scss │ │ ├── components │ │ ├── _alert.scss │ │ ├── _button.scss │ │ ├── _button_group.scss │ │ ├── _card.scss │ │ ├── _content_wrapper.scss │ │ ├── _editor.scss │ │ ├── _form.scss │ │ ├── _hero.scss │ │ ├── _icon.scss │ │ ├── _lesson.scss │ │ ├── _link.scss │ │ ├── _list.scss │ │ ├── _notification.scss │ │ ├── _panel.scss │ │ ├── _progress.scss │ │ ├── _tab.scss │ │ ├── _table.scss │ │ └── _toggle.scss │ │ ├── layout │ │ ├── _container.scss │ │ ├── _flex.scss │ │ ├── _grid.scss │ │ ├── _sidebar.scss │ │ └── _topbar.scss │ │ ├── pages │ │ ├── _course.scss │ │ ├── _courses.scss │ │ ├── _lesson.scss │ │ ├── _login.scss │ │ ├── _user.scss │ │ └── _users.scss │ │ └── vendors │ │ ├── _highlight.scss │ │ ├── _medium-editor-insert-plugin-frontend.scss │ │ ├── _medium-editor-insert-plugin.scss │ │ └── _medium_editor_beagle_theme.scss ├── lang │ └── en │ │ ├── auth.php │ │ ├── pagination.php │ │ ├── passwords.php │ │ └── validation.php └── views │ ├── auth │ ├── emails │ │ └── password.blade.php │ ├── login.blade.php │ ├── passwords │ │ ├── email.blade.php │ │ └── reset.blade.php │ └── register.blade.php │ ├── courses │ ├── create.blade.php │ ├── hero-sub.blade.php │ ├── index.blade.php │ └── show.blade.php │ ├── errors │ └── 503.blade.php │ ├── flash.blade.php │ ├── home.blade.php │ ├── layouts │ ├── master.blade.php │ ├── no-sidebar.blade.php │ └── with-sidebar.blade.php │ ├── lessonfiles │ └── edit.blade.php │ ├── lessons │ ├── create.blade.php │ └── show.blade.php │ ├── noscript.blade.php │ ├── shared │ ├── card-grid-item.blade.php │ ├── hero.blade.php │ ├── sidebar.blade.php │ └── topbar.blade.php │ ├── svg │ ├── courses.blade.php │ ├── courses_black.blade.php │ ├── hammer.blade.php │ ├── home.blade.php │ ├── settings.blade.php │ ├── star.blade.php │ ├── user.blade.php │ └── users.blade.php │ ├── users │ ├── create.blade.php │ ├── hero-sub.blade.php │ ├── index.blade.php │ └── show.blade.php │ └── vendor │ └── .gitkeep ├── server.php ├── storage ├── app │ ├── .gitignore │ └── public │ │ └── .gitignore ├── framework │ ├── .gitignore │ ├── cache │ │ └── .gitignore │ ├── sessions │ │ └── .gitignore │ └── views │ │ └── .gitignore └── logs │ └── .gitignore └── tests ├── ExampleTest.php └── TestCase.php /.env.example: -------------------------------------------------------------------------------- 1 | APP_ENV=local 2 | APP_DEBUG=true 3 | APP_KEY=SomeRandomString 4 | APP_URL=http://localhost 5 | 6 | DB_CONNECTION=mysql 7 | DB_HOST=127.0.0.1 8 | DB_PORT=3306 9 | DB_DATABASE=homestead 10 | DB_USERNAME=homestead 11 | DB_PASSWORD=secret 12 | 13 | CACHE_DRIVER=file 14 | SESSION_DRIVER=file 15 | QUEUE_DRIVER=sync 16 | 17 | REDIS_HOST=127.0.0.1 18 | REDIS_PASSWORD=null 19 | REDIS_PORT=6379 20 | 21 | MAIL_DRIVER=smtp 22 | MAIL_HOST=mailtrap.io 23 | MAIL_PORT=2525 24 | MAIL_USERNAME=null 25 | MAIL_PASSWORD=null 26 | MAIL_ENCRYPTION=null 27 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.css linguist-vendored 3 | *.scss linguist-vendored 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | /node_modules 3 | /public/storage 4 | Homestead.yaml 5 | Homestead.json 6 | .env 7 | .DS_STORE 8 | /src 9 | .vagrant 10 | /public/uploads/* 11 | !/public/uploads/.gitkeep -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "predef": ["window", "document"] 4 | } -------------------------------------------------------------------------------- /.scss-lint.yml: -------------------------------------------------------------------------------- 1 | --- 2 | exclude: 'resources/assets/sass/vendors/**' 3 | 4 | linters: 5 | ColorKeyword: 6 | enabled: true 7 | ColorVariable: 8 | enabled: true 9 | EmptyRule: 10 | enabled: true 11 | FinalNewline: 12 | enabled: true 13 | IdSelector: 14 | enabled: true 15 | ImportPath: 16 | enabled: true 17 | Indentation: 18 | enabled: false 19 | LeadingZero: 20 | enabled: true 21 | PropertySortOrder: 22 | enabled: true 23 | SpaceAfterComma: 24 | enabled: true 25 | SelectorFormat: 26 | convention: hyphenated_BEM 27 | StringQuotes: 28 | enabled: true 29 | TrailingSemicolon: 30 | enabled: true 31 | UnnecessaryMantissa: 32 | enabled: true -------------------------------------------------------------------------------- /Homestead.yaml.example: -------------------------------------------------------------------------------- 1 | --- 2 | ip: "192.168.10.10" 3 | memory: 2048 4 | cpus: 1 5 | hostname: lms 6 | name: lms 7 | provider: virtualbox 8 | mariadb: true 9 | 10 | authorize: ~/.ssh/id_rsa.pub 11 | 12 | keys: 13 | - ~/.ssh/id_rsa 14 | 15 | folders: 16 | - map: "/Users/jasonhee/Projects/lms" 17 | to: "/home/vagrant/lms" 18 | type: "nfs" 19 | 20 | sites: 21 | - map: homestead.app 22 | to: "/home/vagrant/lms/public" 23 | 24 | databases: 25 | - homestead 26 | 27 | # blackfire: 28 | # - id: foo 29 | # token: bar 30 | # client-id: foo 31 | # client-token: bar 32 | 33 | # ports: 34 | # - send: 50000 35 | # to: 5000 36 | # - send: 7777 37 | # to: 777 38 | # protocol: udp 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Jason Hee 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. -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | require 'json' 2 | require 'yaml' 3 | 4 | VAGRANTFILE_API_VERSION ||= "2" 5 | confDir = $confDir ||= File.expand_path("vendor/laravel/homestead", File.dirname(__FILE__)) 6 | 7 | homesteadYamlPath = "Homestead.yaml" 8 | homesteadJsonPath = "Homestead.json" 9 | afterScriptPath = "after.sh" 10 | aliasesPath = "aliases" 11 | 12 | require File.expand_path(confDir + '/scripts/homestead.rb') 13 | 14 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 15 | if File.exists? aliasesPath then 16 | config.vm.provision "file", source: aliasesPath, destination: "~/.bash_aliases" 17 | end 18 | 19 | if File.exists? homesteadYamlPath then 20 | Homestead.configure(config, YAML::load(File.read(homesteadYamlPath))) 21 | elsif File.exists? homesteadJsonPath then 22 | Homestead.configure(config, JSON.parse(File.read(homesteadJsonPath))) 23 | end 24 | 25 | if File.exists? afterScriptPath then 26 | config.vm.provision "shell", path: afterScriptPath 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /app/Console/Commands/Inspire.php: -------------------------------------------------------------------------------- 1 | comment(PHP_EOL.Inspiring::quote().PHP_EOL); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/Console/Kernel.php: -------------------------------------------------------------------------------- 1 | command('inspire') 28 | // ->hourly(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/Course.php: -------------------------------------------------------------------------------- 1 | hasMany(Lesson::class); 12 | } 13 | 14 | public function students() 15 | { 16 | return $this->belongsToMany(Student::class, 'course_student'); 17 | } 18 | 19 | public function lecturers() 20 | { 21 | return $this->belongsToMany(Lecturer::class, 'course_lecturer'); 22 | } 23 | 24 | public function addLesson(Lesson $lesson) 25 | { 26 | return $this->lessons()->save($lesson); 27 | } 28 | 29 | public function setImage($imgFile) 30 | { 31 | $this->image = $imgFile; 32 | $this->save(); 33 | } 34 | 35 | public function getLecturers() 36 | { 37 | return $this->getUsersCollection($this->lecturers); 38 | } 39 | 40 | public function addLecturer($user_id) 41 | { 42 | $lecturer = new Lecturer(); 43 | $lecturer->user_id = $user_id; 44 | $lecturer->course_id = $this->id; 45 | $lecturer->save(); 46 | $lecturer->courses()->save($this); 47 | } 48 | 49 | public function removeLecturer($user_id) 50 | { 51 | $lecturer = Lecturer::where(['user_id' => $user_id, 'course_id' => $this->id])->first(); 52 | $lecturer->delete(); 53 | } 54 | 55 | public function getStudents() 56 | { 57 | return $this->getUsersCollection($this->students); 58 | } 59 | 60 | public function addStudent($user_id) 61 | { 62 | $student = new Student(); 63 | $student->user_id = $user_id; 64 | $student->course_id = $this->id; 65 | $student->save(); 66 | $student->courses()->save($this); 67 | } 68 | 69 | public function removeStudent($user_id) 70 | { 71 | $student = Student::where(['user_id' => $user_id, 'course_id' => $this->id])->first(); 72 | $student->delete(); 73 | } 74 | 75 | public function deleteImage() 76 | { 77 | if ($this->image) { 78 | $imageFile = public_path(config('constants.upload_dir.courses')) . getSubstrAfterLastSlash($this->image); 79 | $imageThumb = generateThumbnailImagePath($imageFile); 80 | 81 | if (\File::exists($imageFile)) { 82 | \File::delete($imageFile); 83 | } 84 | 85 | if (\File::exists($imageThumb)) { 86 | \File::delete($imageThumb); 87 | } 88 | } 89 | } 90 | 91 | /** 92 | * Helper function to get a collection of User models (Lecturers/Students) 93 | * @param [Model] $collection - Collection of models with user_id attribute 94 | * @return [Array] array of User models 95 | */ 96 | private function getUsersCollection($collection) { 97 | $users_collection = []; 98 | foreach ($collection as $item) { 99 | $user = User::find($item->user_id); 100 | $users_collection[] = $user; 101 | } 102 | 103 | return $users_collection; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /app/Events/Event.php: -------------------------------------------------------------------------------- 1 | middleware($this->guestMiddleware(), ['except' => 'logout']); 41 | } 42 | 43 | /** 44 | * Get a validator for an incoming registration request. 45 | * 46 | * @param array $data 47 | * @return \Illuminate\Contracts\Validation\Validator 48 | */ 49 | protected function validator(array $data) 50 | { 51 | return Validator::make($data, [ 52 | 'name' => 'required|max:255', 53 | 'email' => 'required|email|max:255|unique:users', 54 | 'password' => 'required|min:6|confirmed', 55 | ]); 56 | } 57 | 58 | /** 59 | * Create a new user instance after a valid registration. 60 | * 61 | * @param array $data 62 | * @return User 63 | */ 64 | protected function create(array $data) 65 | { 66 | return User::create([ 67 | 'name' => $data['name'], 68 | 'email' => $data['email'], 69 | 'password' => bcrypt($data['password']), 70 | ]); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /app/Http/Controllers/Auth/PasswordController.php: -------------------------------------------------------------------------------- 1 | middleware('guest'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Http/Controllers/Controller.php: -------------------------------------------------------------------------------- 1 | ajax()) { 24 | return response()->json(['response' => $message], 401); 25 | } else { 26 | if (strlen($message)) { 27 | flash($message, 'danger'); 28 | } 29 | } 30 | 31 | return $redirect; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/Http/Controllers/ControllerImageUploaderInterface.php: -------------------------------------------------------------------------------- 1 | middleware('auth'); 19 | } 20 | 21 | /** 22 | * Show the application dashboard. 23 | * 24 | * @return \Illuminate\Http\Response 25 | */ 26 | public function index() 27 | { 28 | $user = \Auth::user(); 29 | 30 | return view('home', [ 31 | 'instructing' => $user->getAllInstructors(), 32 | 'studying' => $user->getAllStudents() 33 | ]); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/Http/Controllers/LessonFilesController.php: -------------------------------------------------------------------------------- 1 | middleware('edit.course'); 16 | } 17 | 18 | /** 19 | * Adds a new LessonFile to the Lesson 20 | * @param Request $request 21 | * @param Lesson $lesson 22 | */ 23 | public function store(Request $request, Lesson $lesson) 24 | { 25 | $this->validate($request, [ 26 | 'filename' => 'required', 27 | 'url' => 'required' 28 | ]); 29 | 30 | $file = new LessonFile; 31 | $file->name = $request->filename; 32 | $file->url = $request->url; 33 | 34 | if ($request->has('description')) { 35 | $file->description = $request->description; 36 | } 37 | 38 | $lesson->addFile($file); 39 | flash('File(s) added', 'success'); 40 | 41 | return back(); 42 | } 43 | 44 | public function edit(LessonFile $lesson_file) 45 | { 46 | return view('lessonfiles.edit', [ 47 | 'file' => $lesson_file 48 | ]); 49 | } 50 | 51 | public function update(Request $request, LessonFile $lesson_file) 52 | { 53 | $this->validate($request, [ 54 | 'filename' => 'required', 55 | 'url' => 'required' 56 | ]); 57 | 58 | if ($request->has('description')) { 59 | $lesson_file->update([ 60 | 'name' => $request->filename, 61 | 'url' => $request->url, 62 | 'description' => $request->description 63 | ]); 64 | } else { 65 | $lesson_file->update([ 66 | 'name' => $request->filename, 67 | 'url' => $request->url 68 | ]); 69 | } 70 | 71 | return redirect()->route('lesson', [$lesson_file->lesson]); 72 | } 73 | 74 | public function destroy(Request $request, LessonFile $lesson_file) 75 | { 76 | $lesson_file->delete(); 77 | 78 | flash('File deleted', 'success'); 79 | 80 | return back(); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /app/Http/Kernel.php: -------------------------------------------------------------------------------- 1 | [ 27 | \App\Http\Middleware\EncryptCookies::class, 28 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, 29 | \Illuminate\Session\Middleware\StartSession::class, 30 | \Illuminate\View\Middleware\ShareErrorsFromSession::class, 31 | \App\Http\Middleware\VerifyCsrfToken::class, 32 | ], 33 | 34 | 'api' => [ 35 | 'throttle:60,1', 36 | ], 37 | ]; 38 | 39 | /** 40 | * The application's route middleware. 41 | * 42 | * These middleware may be assigned to groups or used individually. 43 | * 44 | * @var array 45 | */ 46 | protected $routeMiddleware = [ 47 | 'auth' => \App\Http\Middleware\Authenticate::class, 48 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 49 | 'can' => \Illuminate\Foundation\Http\Middleware\Authorize::class, 50 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 51 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class 52 | ]; 53 | } 54 | -------------------------------------------------------------------------------- /app/Http/Middleware/Authenticate.php: -------------------------------------------------------------------------------- 1 | guest()) { 21 | if ($request->ajax() || $request->wantsJson()) { 22 | return response('Unauthorized.', 401); 23 | } else { 24 | return redirect()->guest('login'); 25 | } 26 | } 27 | 28 | return $next($request); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/Http/Middleware/EncryptCookies.php: -------------------------------------------------------------------------------- 1 | user()->is('admin') || $request->user()->is('superadmin')) { 19 | return $next($request); 20 | } 21 | 22 | flash('You do not have access to this page!', 'danger'); 23 | return back(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/Http/Middleware/RedirectIfAuthenticated.php: -------------------------------------------------------------------------------- 1 | check()) { 21 | return redirect('/'); 22 | } 23 | 24 | return $next($request); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/Http/Middleware/VerifyCsrfToken.php: -------------------------------------------------------------------------------- 1 | 'home', 'uses' => 'HomeController@index']); 21 | 22 | Route::group(['middleware' => 'auth'], function () { 23 | // hack to avoid flash messages being cached by browser. 24 | // without using ajax, the flash message will display when user presses back button 25 | // TODO: find a more elegant solution 26 | Route::get('/flash', function() { 27 | echo json_encode(['message' => session()->pull('flash_message'), 'message_level' => session()->pull('flash_message_level')]); 28 | }); 29 | 30 | // Route::get('/courses', ['as' => 'courses', 'uses' => 'CoursesController@index']); 31 | // Route::post('/courses', 'CoursesController@store'); 32 | // Route::get('/courses/create', 'CoursesController@create'); 33 | // Route::get('/courses/{course}', ['as' => 'course', 'uses' => 'CoursesController@show']); 34 | // Route::patch('/courses/{course}', 'CoursesController@update'); 35 | Route::patch('/courses/{course}/lecturers', 'CoursesController@updateLecturers'); 36 | Route::patch('/courses/{course}/students', 'CoursesController@updateStudents'); 37 | Route::any('/courses/{course_id}/upload', 'CoursesController@upload'); 38 | // Route::delete('/courses/{course}', 'CoursesController@destroy'); 39 | 40 | Route::resource('courses', 'CoursesController', [ 41 | 'parameters' => 'singular', 42 | 'except' => ['edit'] 43 | ]); 44 | 45 | // Route::resource('courses', 'CoursesController', ['names' => [ 46 | // 'show' => 'course' 47 | // ]]); 48 | Route::post('/lessons', 'LessonsController@store'); 49 | Route::get('/lessons/create', 'LessonsController@create'); 50 | Route::get('/lessons/{lesson}', ['as' => 'lesson', 'uses' => 'LessonsController@show']); 51 | Route::patch('/lessons/{lesson}', 'LessonsController@update'); 52 | Route::patch('/lessons/{lesson}/publish', 'LessonsController@setPublishedStatus'); 53 | Route::delete('/lessons/{lesson}', 'LessonsController@destroy'); 54 | 55 | Route::post('/lessons/{lesson}/files', 'LessonFilesController@store'); 56 | // Route::resource('files', 'LessonFilesController', ['except' => [ 57 | // 'index', 'create', 'show', 'store' 58 | // ]]); 59 | 60 | Route::patch('/files/{lesson_file}', 'LessonFilesController@update'); 61 | Route::delete('/files/{lesson_file}', 'LessonFilesController@destroy'); 62 | Route::get('/files/{lesson_file}/edit', 'LessonFilesController@edit'); 63 | 64 | // Medium editor image upload path 65 | Route::any('/lessons/{lesson_id}/upload', 'LessonsController@upload'); 66 | Route::any('/lessons/{lesson_id}/removeUpload', 'LessonsController@removeUpload'); 67 | 68 | Route::patch('users/{user}/setadmin', 'UserController@setAdminStatus'); 69 | Route::any('users/{user_id}/upload', 'UserController@upload'); 70 | Route::resource('users', 'UserController', [ 71 | 'parameters' => 'singular', 72 | 'except' => ['edit'] 73 | ]); 74 | }); 75 | -------------------------------------------------------------------------------- /app/Jobs/Job.php: -------------------------------------------------------------------------------- 1 | belongsToMany(Course::class, 'course_lecturer'); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/Lesson.php: -------------------------------------------------------------------------------- 1 | belongsTo(Course::class); 12 | } 13 | 14 | public function files() 15 | { 16 | return $this->hasMany(LessonFile::class); 17 | } 18 | 19 | public function addFile(LessonFile $file) 20 | { 21 | return $this->files()->save($file); 22 | } 23 | 24 | public function publish() 25 | { 26 | $this->published = true; 27 | $this->save(); 28 | } 29 | 30 | public function unpublish() 31 | { 32 | $this->published = false; 33 | $this->save(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/LessonFile.php: -------------------------------------------------------------------------------- 1 | belongsTo(Lesson::class); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/Listeners/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/Policies/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/Policies/CoursePolicy.php: -------------------------------------------------------------------------------- 1 | is('admin') || $user->isLecturerIn($course) || $user->isStudentIn($course); 23 | } 24 | 25 | /** 26 | * Determine if the current user can create a new course. 27 | * @param \App\User $user 28 | * @return boolean 29 | */ 30 | public function createAny(User $user) 31 | { 32 | return $user->is('admin'); 33 | } 34 | 35 | /** 36 | * Determine if the given course can be updated by the user. 37 | * 38 | * @param \App\User $user 39 | * @param \App\Course $course 40 | * @return boolean 41 | */ 42 | public function update(User $user, Course $course) 43 | { 44 | return $user->is('admin') || $user->isLecturerIn($course); 45 | } 46 | 47 | /** 48 | * Determine if the given course can be deleted by the user 49 | * 50 | * @param \App\User $user 51 | * @param \App\Course $course 52 | * @return boolean 53 | */ 54 | public function destroy(User $user, Course $course) 55 | { 56 | return $user->is('admin') || $user->isLecturerIn($course); 57 | } 58 | 59 | /** 60 | * Intercept all checks for superadmin user 61 | * @param \App\User $user [description] 62 | * @return boolean 63 | */ 64 | public function before(User $user, $ability) 65 | { 66 | if ($user->is('superadmin')) { 67 | return true; 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /app/Policies/UserPolicy.php: -------------------------------------------------------------------------------- 1 | is('admin'); 20 | } 21 | 22 | /** 23 | * Determine if the given user can be seen by the current user. 24 | * 25 | * @param \App\User $current_user 26 | * @param \App\User $user 27 | * @return boolean 28 | */ 29 | public function show(User $current_user, User $user) 30 | { 31 | return $current_user->id == $user->id; 32 | } 33 | 34 | /** 35 | * Determine if the current user can create a new user. 36 | * 37 | * @param \App\User $user 38 | * @return boolean 39 | */ 40 | public function createAny(User $current_user) 41 | { 42 | return $current_user->is('admin'); 43 | } 44 | 45 | /** 46 | * Determine if the given user can be updated by the current user. 47 | * 48 | * @param \App\User $user 49 | * @param \App\Post $post 50 | * @return boolean 51 | */ 52 | public function update(User $current_user, User $user) 53 | { 54 | return $current_user->is('admin'); 55 | } 56 | 57 | /** 58 | * Determine if the given user can be delete users 59 | * 60 | * @param \App\User $user 61 | * @param \App\Post $post 62 | * @return boolean 63 | */ 64 | public function destroy(User $current_user, User $user) 65 | { 66 | return $current_user->is('superadmin'); 67 | } 68 | 69 | /** 70 | * Determine if the given user can update admin status of a user 71 | * 72 | * @param \App\User $user 73 | * @param \App\Post $post 74 | * @return boolean 75 | */ 76 | public function setAdminStatus(User $current_user, User $user) 77 | { 78 | return $current_user->is('superadmin'); 79 | } 80 | 81 | /** 82 | * Intercept all checks for superadmin user 83 | * @param \App\User $user [description] 84 | * @return boolean 85 | */ 86 | public function before(User $user, $ability) 87 | { 88 | if ($user->is('superadmin')) { 89 | return true; 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /app/Providers/AppServiceProvider.php: -------------------------------------------------------------------------------- 1 | "; 20 | }); 21 | } 22 | 23 | /** 24 | * Register any application services. 25 | * 26 | * @return void 27 | */ 28 | public function register() 29 | { 30 | // 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/Providers/AuthServiceProvider.php: -------------------------------------------------------------------------------- 1 | 'App\Policies\ModelPolicy', 17 | 'App\User' => 'App\Policies\UserPolicy', 18 | 'App\Course' => 'App\Policies\CoursePolicy' 19 | ]; 20 | 21 | /** 22 | * Register any application authentication / authorization services. 23 | * 24 | * @param \Illuminate\Contracts\Auth\Access\Gate $gate 25 | * @return void 26 | */ 27 | public function boot(GateContract $gate) 28 | { 29 | $this->registerPolicies($gate); 30 | 31 | // 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/Providers/EventServiceProvider.php: -------------------------------------------------------------------------------- 1 | [ 17 | 'App\Listeners\EventListener', 18 | ], 19 | ]; 20 | 21 | /** 22 | * Register any other events for your application. 23 | * 24 | * @param \Illuminate\Contracts\Events\Dispatcher $events 25 | * @return void 26 | */ 27 | public function boot(DispatcherContract $events) 28 | { 29 | parent::boot($events); 30 | 31 | // 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/Providers/RouteServiceProvider.php: -------------------------------------------------------------------------------- 1 | mapWebRoutes($router); 41 | 42 | // 43 | } 44 | 45 | /** 46 | * Define the "web" routes for the application. 47 | * 48 | * These routes all receive session state, CSRF protection, etc. 49 | * 50 | * @param \Illuminate\Routing\Router $router 51 | * @return void 52 | */ 53 | protected function mapWebRoutes(Router $router) 54 | { 55 | $router->group([ 56 | 'namespace' => $this->namespace, 'middleware' => 'web', 57 | ], function ($router) { 58 | require app_path('Http/routes.php'); 59 | }); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /app/Role.php: -------------------------------------------------------------------------------- 1 | belongsToMany(User::class, 'user_role'); 12 | } 13 | 14 | public static function getAdminRole() { 15 | return Role::where('name', 'admin')->first(); 16 | } 17 | 18 | public static function getSuperAdminRole() 19 | { 20 | return Role::where('name', 'superadmin')->first(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/Student.php: -------------------------------------------------------------------------------- 1 | belongsToMany(Course::class, 'course_student'); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/Uploaders/AvatarUploader.php: -------------------------------------------------------------------------------- 1 | generateThumbnail($fileName, $destination, $force_png); 31 | 32 | return $uploadedFile; 33 | } 34 | 35 | return false; 36 | } 37 | 38 | private function generateThumbnail($filename, $destination, $force_png = false) 39 | { 40 | $new_filename = parent::getNewFilename($filename, $force_png, config('constants.thumbnail_suffix')); 41 | $thumbnail = parent::resize(self::THUMBNAIL_SIZE, self::THUMBNAIL_SIZE); 42 | $thumbnail->save($destination . $new_filename); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/Uploaders/CourseImageUploader.php: -------------------------------------------------------------------------------- 1 | generateThumbnail($fileName, $destination, $force_png); 33 | 34 | return $uploadedFile; 35 | } 36 | 37 | return false; 38 | } 39 | 40 | private function generateThumbnail($filename, $destination, $force_png = false) 41 | { 42 | $new_filename = parent::getNewFilename($filename, $force_png, config('constants.thumbnail_suffix')); 43 | $thumbnail = parent::resize(self::THUMBNAIL_WIDTH, self::THUMBNAIL_HEIGHT); 44 | $thumbnail->save($destination . $new_filename); 45 | } 46 | 47 | /** 48 | * Retrieves the image file extension and make sure it's a valid one. 49 | * Defaults to the value 'jpg' 50 | * @param string $imageFilename 51 | * @return string 52 | */ 53 | private function getImageExtension($imageFilename) { 54 | $dotPos = strrpos($imageFilename, '.'); 55 | $substr = $dotPos === false ? $str : substr($str, $dotPos + 1); 56 | 57 | if (preg_match('/^.*\.(jpg|jpeg|png|gif)$/i', $substr)) { 58 | return $substr; 59 | } 60 | 61 | return 'jpg'; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /app/helpers.php: -------------------------------------------------------------------------------- 1 | put('flash_message', $message); 11 | session()->put('flash_message_level', $level); 12 | } 13 | 14 | /** 15 | * Generate a random string with a specified number of characters 16 | * @param string $no_of_chars no of characters in random string 17 | * @return string a random string 18 | */ 19 | function generate_random_str($no_of_chars) 20 | { 21 | return substr(md5(microtime()),rand(0,26),$no_of_chars); 22 | } 23 | 24 | /** 25 | * Checks if the authenticated user can perform one of the abilities listed 26 | * @param array $abilities list of abilities (e.g. show, update, destroy) 27 | * @return boolean 28 | */ 29 | function canAny($abilities, $model) 30 | { 31 | foreach ($abilities as $ability) { 32 | if (\Gate::allows($ability, $model)) { 33 | return true; 34 | } 35 | } 36 | 37 | return false; 38 | } 39 | 40 | /** 41 | * Return a substring containing the characters after the last slash character 42 | * If there is no slash character, returns the entire string 43 | * @param string $str 44 | * @return string 45 | */ 46 | function getSubstrAfterLastSlash($str) 47 | { 48 | $slashPos = strrpos($str, '/'); 49 | $substr = $slashPos === false ? $str : substr($str, $slashPos + 1); 50 | 51 | return $substr; 52 | } 53 | 54 | /** 55 | * Generate file path to thumbnail version of image 56 | * @param string $imagePath 57 | * @return string 58 | */ 59 | function generateThumbnailImagePath($imagePath) 60 | { 61 | $path_parts = pathinfo($imagePath); 62 | 63 | if (array_key_exists('extension', $path_parts)) { 64 | return $path_parts['dirname'] . '/' .$path_parts['filename'] . 65 | config('constants.thumbnail_suffix') . '.' . $path_parts['extension']; 66 | } 67 | 68 | return $path_parts['dirname'] . '/' .$path_parts['filename'] . 69 | config('constants.thumbnail_suffix'); 70 | } -------------------------------------------------------------------------------- /artisan: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env php 2 | make(Illuminate\Contracts\Console\Kernel::class); 32 | 33 | $status = $kernel->handle( 34 | $input = new Symfony\Component\Console\Input\ArgvInput, 35 | new Symfony\Component\Console\Output\ConsoleOutput 36 | ); 37 | 38 | /* 39 | |-------------------------------------------------------------------------- 40 | | Shutdown The Application 41 | |-------------------------------------------------------------------------- 42 | | 43 | | Once Artisan has finished running. We will fire off the shutdown events 44 | | so that any final work may be done by the application before we shut 45 | | down the process. This is the last thing to happen to the request. 46 | | 47 | */ 48 | 49 | $kernel->terminate($input, $status); 50 | 51 | exit($status); 52 | -------------------------------------------------------------------------------- /bootstrap/app.php: -------------------------------------------------------------------------------- 1 | singleton( 30 | Illuminate\Contracts\Http\Kernel::class, 31 | App\Http\Kernel::class 32 | ); 33 | 34 | $app->singleton( 35 | Illuminate\Contracts\Console\Kernel::class, 36 | App\Console\Kernel::class 37 | ); 38 | 39 | $app->singleton( 40 | Illuminate\Contracts\Debug\ExceptionHandler::class, 41 | App\Exceptions\Handler::class 42 | ); 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Return The Application 47 | |-------------------------------------------------------------------------- 48 | | 49 | | This script returns the application instance. The instance is given to 50 | | the calling script so we can separate the building of the instances 51 | | from the actual running of the application and sending responses. 52 | | 53 | */ 54 | 55 | return $app; 56 | -------------------------------------------------------------------------------- /bootstrap/autoload.php: -------------------------------------------------------------------------------- 1 | =5.5.9", 9 | "laravel/framework": "5.2.*", 10 | "intervention/image": "^2.3" 11 | }, 12 | "require-dev": { 13 | "fzaninotto/faker": "~1.4", 14 | "mockery/mockery": "0.9.*", 15 | "phpunit/phpunit": "~4.0", 16 | "symfony/css-selector": "2.8.*|3.0.*", 17 | "symfony/dom-crawler": "2.8.*|3.0.*", 18 | "laravel/homestead": "^3.0" 19 | }, 20 | "autoload": { 21 | "classmap": [ 22 | "database" 23 | ], 24 | "psr-4": { 25 | "App\\": "app/", 26 | "App\\Uploaders\\" : "app/Uploaders/" 27 | }, 28 | "files": [ 29 | "app/helpers.php" 30 | ] 31 | }, 32 | "autoload-dev": { 33 | "classmap": [ 34 | "tests/TestCase.php" 35 | ] 36 | }, 37 | "scripts": { 38 | "post-root-package-install": [ 39 | "php -r \"copy('.env.example', '.env');\"" 40 | ], 41 | "post-create-project-cmd": [ 42 | "php artisan key:generate" 43 | ], 44 | "post-install-cmd": [ 45 | "Illuminate\\Foundation\\ComposerScripts::postInstall", 46 | "php artisan optimize" 47 | ], 48 | "post-update-cmd": [ 49 | "Illuminate\\Foundation\\ComposerScripts::postUpdate", 50 | "php artisan optimize" 51 | ] 52 | }, 53 | "config": { 54 | "preferred-install": "dist" 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /config/broadcasting.php: -------------------------------------------------------------------------------- 1 | env('BROADCAST_DRIVER', 'pusher'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Broadcast Connections 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may define all of the broadcast connections that will be used 24 | | to broadcast events to other systems or over websockets. Samples of 25 | | each available type of connection are provided inside this array. 26 | | 27 | */ 28 | 29 | 'connections' => [ 30 | 31 | 'pusher' => [ 32 | 'driver' => 'pusher', 33 | 'key' => env('PUSHER_KEY'), 34 | 'secret' => env('PUSHER_SECRET'), 35 | 'app_id' => env('PUSHER_APP_ID'), 36 | 'options' => [ 37 | // 38 | ], 39 | ], 40 | 41 | 'redis' => [ 42 | 'driver' => 'redis', 43 | 'connection' => 'default', 44 | ], 45 | 46 | 'log' => [ 47 | 'driver' => 'log', 48 | ], 49 | 50 | ], 51 | 52 | ]; 53 | -------------------------------------------------------------------------------- /config/cache.php: -------------------------------------------------------------------------------- 1 | env('CACHE_DRIVER', 'file'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Cache Stores 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Here you may define all of the cache "stores" for your application as 24 | | well as their drivers. You may even define multiple stores for the 25 | | same cache driver to group types of items stored in your caches. 26 | | 27 | */ 28 | 29 | 'stores' => [ 30 | 31 | 'apc' => [ 32 | 'driver' => 'apc', 33 | ], 34 | 35 | 'array' => [ 36 | 'driver' => 'array', 37 | ], 38 | 39 | 'database' => [ 40 | 'driver' => 'database', 41 | 'table' => 'cache', 42 | 'connection' => null, 43 | ], 44 | 45 | 'file' => [ 46 | 'driver' => 'file', 47 | 'path' => storage_path('framework/cache'), 48 | ], 49 | 50 | 'memcached' => [ 51 | 'driver' => 'memcached', 52 | 'servers' => [ 53 | [ 54 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 55 | 'port' => env('MEMCACHED_PORT', 11211), 56 | 'weight' => 100, 57 | ], 58 | ], 59 | ], 60 | 61 | 'redis' => [ 62 | 'driver' => 'redis', 63 | 'connection' => 'default', 64 | ], 65 | 66 | ], 67 | 68 | /* 69 | |-------------------------------------------------------------------------- 70 | | Cache Key Prefix 71 | |-------------------------------------------------------------------------- 72 | | 73 | | When utilizing a RAM based store such as APC or Memcached, there might 74 | | be other applications utilizing the same cache. So, we'll specify a 75 | | value to get prefixed to all our keys so we can avoid collisions. 76 | | 77 | */ 78 | 79 | 'prefix' => 'laravel', 80 | 81 | ]; 82 | -------------------------------------------------------------------------------- /config/compile.php: -------------------------------------------------------------------------------- 1 | [ 17 | // 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Compiled File Providers 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may list service providers which define a "compiles" function 26 | | that returns additional files that should be compiled, providing an 27 | | easy way to get common files from any packages you are utilizing. 28 | | 29 | */ 30 | 31 | 'providers' => [ 32 | // 33 | ], 34 | 35 | ]; 36 | -------------------------------------------------------------------------------- /config/constants.php: -------------------------------------------------------------------------------- 1 | [ 5 | 'courses' => '/uploads/courses/', 6 | 'users' => '/uploads/users/', 7 | 'tmp' => '/uploads/tmp/' 8 | ], 9 | 'thumbnail_suffix' => '_thumb' 10 | ]; 11 | -------------------------------------------------------------------------------- /config/filesystems.php: -------------------------------------------------------------------------------- 1 | 'local', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Default Cloud Filesystem Disk 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Many applications store files both locally and in the cloud. For this 26 | | reason, you may specify a default "cloud" driver here. This driver 27 | | will be bound as the Cloud disk implementation in the container. 28 | | 29 | */ 30 | 31 | 'cloud' => 's3', 32 | 33 | /* 34 | |-------------------------------------------------------------------------- 35 | | Filesystem Disks 36 | |-------------------------------------------------------------------------- 37 | | 38 | | Here you may configure as many filesystem "disks" as you wish, and you 39 | | may even configure multiple disks of the same driver. Defaults have 40 | | been setup for each driver as an example of the required options. 41 | | 42 | */ 43 | 44 | 'disks' => [ 45 | 46 | 'local' => [ 47 | 'driver' => 'local', 48 | 'root' => storage_path('app'), 49 | ], 50 | 51 | 'public' => [ 52 | 'driver' => 'local', 53 | 'root' => storage_path('app/public'), 54 | 'visibility' => 'public', 55 | ], 56 | 57 | 's3' => [ 58 | 'driver' => 's3', 59 | 'key' => 'your-key', 60 | 'secret' => 'your-secret', 61 | 'region' => 'your-region', 62 | 'bucket' => 'your-bucket', 63 | ], 64 | 65 | ], 66 | 67 | ]; 68 | -------------------------------------------------------------------------------- /config/queue.php: -------------------------------------------------------------------------------- 1 | env('QUEUE_DRIVER', 'sync'), 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Queue Connections 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Here you may configure the connection information for each server that 26 | | is used by your application. A default configuration has been added 27 | | for each back-end shipped with Laravel. You are free to add more. 28 | | 29 | */ 30 | 31 | 'connections' => [ 32 | 33 | 'sync' => [ 34 | 'driver' => 'sync', 35 | ], 36 | 37 | 'database' => [ 38 | 'driver' => 'database', 39 | 'table' => 'jobs', 40 | 'queue' => 'default', 41 | 'expire' => 60, 42 | ], 43 | 44 | 'beanstalkd' => [ 45 | 'driver' => 'beanstalkd', 46 | 'host' => 'localhost', 47 | 'queue' => 'default', 48 | 'ttr' => 60, 49 | ], 50 | 51 | 'sqs' => [ 52 | 'driver' => 'sqs', 53 | 'key' => 'your-public-key', 54 | 'secret' => 'your-secret-key', 55 | 'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id', 56 | 'queue' => 'your-queue-name', 57 | 'region' => 'us-east-1', 58 | ], 59 | 60 | 'redis' => [ 61 | 'driver' => 'redis', 62 | 'connection' => 'default', 63 | 'queue' => 'default', 64 | 'expire' => 60, 65 | ], 66 | 67 | ], 68 | 69 | /* 70 | |-------------------------------------------------------------------------- 71 | | Failed Queue Jobs 72 | |-------------------------------------------------------------------------- 73 | | 74 | | These options configure the behavior of failed queue job logging so you 75 | | can control which database and table are used to store the jobs that 76 | | have failed. You may change them to any database / table you wish. 77 | | 78 | */ 79 | 80 | 'failed' => [ 81 | 'database' => env('DB_CONNECTION', 'mysql'), 82 | 'table' => 'failed_jobs', 83 | ], 84 | 85 | ]; 86 | -------------------------------------------------------------------------------- /config/services.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'domain' => env('MAILGUN_DOMAIN'), 19 | 'secret' => env('MAILGUN_SECRET'), 20 | ], 21 | 22 | 'ses' => [ 23 | 'key' => env('SES_KEY'), 24 | 'secret' => env('SES_SECRET'), 25 | 'region' => 'us-east-1', 26 | ], 27 | 28 | 'sparkpost' => [ 29 | 'secret' => env('SPARKPOST_SECRET'), 30 | ], 31 | 32 | 'stripe' => [ 33 | 'model' => App\User::class, 34 | 'key' => env('STRIPE_KEY'), 35 | 'secret' => env('STRIPE_SECRET'), 36 | ], 37 | 38 | ]; 39 | -------------------------------------------------------------------------------- /config/view.php: -------------------------------------------------------------------------------- 1 | [ 17 | realpath(base_path('resources/views')), 18 | ], 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Compiled View Path 23 | |-------------------------------------------------------------------------- 24 | | 25 | | This option determines where all the compiled Blade templates will be 26 | | stored for your application. Typically, this is within the storage 27 | | directory. However, as usual, you are free to change this value. 28 | | 29 | */ 30 | 31 | 'compiled' => realpath(storage_path('framework/views')), 32 | 33 | ]; 34 | -------------------------------------------------------------------------------- /database/.gitignore: -------------------------------------------------------------------------------- 1 | *.sqlite 2 | -------------------------------------------------------------------------------- /database/factories/ModelFactory.php: -------------------------------------------------------------------------------- 1 | define(App\User::class, function (Faker\Generator $faker) { 15 | $name = $faker->name; 16 | return [ 17 | 'name' => $name, 18 | 'email' => $faker->safeEmail, 19 | 'password' => bcrypt(str_random(10)), 20 | 'remember_token' => str_random(10), 21 | 'avatar' => 'http://api.adorable.io/avatars/150/' . urlencode($name), 22 | 'company' => $faker->company 23 | ]; 24 | }); 25 | 26 | $factory->defineAs(App\User::class, 'superadmin', function (Faker\Generator $faker) use ($factory) { 27 | $user = $factory->raw(App\User::class); 28 | 29 | return $user; 30 | }); 31 | 32 | $factory->define(App\Course::class, function (Faker\Generator $faker) { 33 | return [ 34 | 'title' => $faker->sentence(5), 35 | 'image' => 'http://placehold.it/1500x550' 36 | ]; 37 | }); 38 | 39 | $factory->define(App\Lesson::class, function (Faker\Generator $faker) { 40 | return [ 41 | 'title' => $faker->sentence(5), 42 | 'body' => '
' . $faker->text() .'
' 43 | ]; 44 | }); 45 | 46 | $factory->define(App\LessonFile::class, function (Faker\Generator $faker) { 47 | return [ 48 | 'name' => $faker->sentence(3), 49 | 'url' => $faker->sentence(12), 50 | 'description' => $faker->text() 51 | ]; 52 | }); 53 | -------------------------------------------------------------------------------- /database/migrations/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /database/migrations/2014_10_12_100000_create_password_resets_table.php: -------------------------------------------------------------------------------- 1 | string('email')->index(); 17 | $table->string('token')->index(); 18 | $table->timestamp('created_at'); 19 | }); 20 | } 21 | 22 | /** 23 | * Reverse the migrations. 24 | * 25 | * @return void 26 | */ 27 | public function down() 28 | { 29 | Schema::drop('password_resets'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /database/migrations/2016_05_17_082113_create_courses_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->string('title'); 18 | $table->timestamps(); 19 | }); 20 | } 21 | 22 | /** 23 | * Reverse the migrations. 24 | * 25 | * @return void 26 | */ 27 | public function down() 28 | { 29 | Schema::drop('courses'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /database/migrations/2016_05_17_090322_create_lessons_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->string('title'); 18 | $table->text('body'); 19 | $table->integer('course_id')->unsigned()->index(); 20 | $table ->foreign('course_id') 21 | ->references('id')->on('courses') 22 | ->onDelete('cascade'); 23 | $table->timestamps(); 24 | }); 25 | } 26 | 27 | /** 28 | * Reverse the migrations. 29 | * 30 | * @return void 31 | */ 32 | public function down() 33 | { 34 | Schema::drop('lessons'); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /database/migrations/2016_05_17_111743_create_lesson_files_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->string('name'); 18 | $table->string('url'); 19 | $table->text('description')->nullable(); 20 | $table->integer('lesson_id')->unsigned()->index(); 21 | $table->timestamps(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | * 28 | * @return void 29 | */ 30 | public function down() 31 | { 32 | Schema::drop('lesson_files'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /database/migrations/2016_05_23_114206_create_roles_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->string('name'); 18 | $table->timestamps(); 19 | }); 20 | } 21 | 22 | /** 23 | * Reverse the migrations. 24 | * 25 | * @return void 26 | */ 27 | public function down() 28 | { 29 | Schema::drop('roles'); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /database/migrations/2016_05_23_122620_create_users_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->string('name'); 18 | $table->string('email')->unique(); 19 | $table->string('password'); 20 | $table->rememberToken(); 21 | $table->timestamps(); 22 | }); 23 | } 24 | 25 | /** 26 | * Reverse the migrations. 27 | * 28 | * @return void 29 | */ 30 | public function down() 31 | { 32 | Schema::drop('users'); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /database/migrations/2016_05_23_122621_create_user_role_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->integer('user_id')->unsigned()->index(); 18 | $table ->foreign('user_id') 19 | ->references('id')->on('users') 20 | ->onDelete('cascade'); 21 | $table->integer('role_id')->unsigned()->index(); 22 | $table ->foreign('role_id') 23 | ->references('id')->on('roles') 24 | ->onDelete('cascade'); 25 | $table->timestamps(); 26 | }); 27 | } 28 | 29 | /** 30 | * Reverse the migrations. 31 | * 32 | * @return void 33 | */ 34 | public function down() 35 | { 36 | Schema::drop('user_role'); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /database/migrations/2016_05_24_045028_create_students_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->integer('user_id')->unsigned()->index(); 18 | $table ->foreign('user_id') 19 | ->references('id')->on('users') 20 | ->onDelete('cascade'); 21 | $table->integer('course_id')->unsigned()->index(); 22 | $table ->foreign('course_id') 23 | ->references('id')->on('courses') 24 | ->onDelete('cascade'); 25 | $table->timestamps(); 26 | }); 27 | } 28 | 29 | /** 30 | * Reverse the migrations. 31 | * 32 | * @return void 33 | */ 34 | public function down() 35 | { 36 | Schema::drop('students'); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /database/migrations/2016_05_24_045029_create_course_student_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->integer('course_id')->unsigned()->index(); 18 | $table ->foreign('course_id') 19 | ->references('id')->on('courses') 20 | ->onDelete('cascade'); 21 | $table->integer('student_id')->unsigned()->index(); 22 | $table ->foreign('student_id') 23 | ->references('id')->on('students') 24 | ->onDelete('cascade'); 25 | $table->timestamps(); 26 | }); 27 | } 28 | 29 | /** 30 | * Reverse the migrations. 31 | * 32 | * @return void 33 | */ 34 | public function down() 35 | { 36 | Schema::drop('course_student'); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /database/migrations/2016_05_24_092415_create_lecturers_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->integer('user_id')->unsigned()->index(); 18 | $table ->foreign('user_id') 19 | ->references('id')->on('users') 20 | ->onDelete('cascade'); 21 | $table->integer('course_id')->unsigned()->index(); 22 | $table ->foreign('course_id') 23 | ->references('id')->on('courses') 24 | ->onDelete('cascade'); 25 | $table->timestamps(); 26 | }); 27 | } 28 | 29 | /** 30 | * Reverse the migrations. 31 | * 32 | * @return void 33 | */ 34 | public function down() 35 | { 36 | Schema::drop('lecturers'); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /database/migrations/2016_05_24_092744_create_course_lecturer_table.php: -------------------------------------------------------------------------------- 1 | increments('id'); 17 | $table->integer('course_id')->unsigned()->index(); 18 | $table ->foreign('course_id') 19 | ->references('id')->on('courses') 20 | ->onDelete('cascade'); 21 | $table->integer('lecturer_id')->unsigned()->index(); 22 | $table ->foreign('lecturer_id') 23 | ->references('id')->on('lecturers') 24 | ->onDelete('cascade'); 25 | $table->timestamps(); 26 | }); 27 | } 28 | 29 | /** 30 | * Reverse the migrations. 31 | * 32 | * @return void 33 | */ 34 | public function down() 35 | { 36 | Schema::drop('course_lecturer'); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /database/migrations/2016_05_28_202808_add_published_to_lessons_table.php: -------------------------------------------------------------------------------- 1 | boolean('published')->nullable()->default(true); 17 | }); 18 | } 19 | 20 | /** 21 | * Reverse the migrations. 22 | * 23 | * @return void 24 | */ 25 | public function down() 26 | { 27 | Schema::table('lessons', function (Blueprint $table) { 28 | $table->dropColumn('published'); 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /database/migrations/2016_06_06_075208_add_image_to_courses_table.php: -------------------------------------------------------------------------------- 1 | string('image')->nullable(); 17 | }); 18 | } 19 | 20 | /** 21 | * Reverse the migrations. 22 | * 23 | * @return void 24 | */ 25 | public function down() 26 | { 27 | Schema::table('courses', function (Blueprint $table) { 28 | $table->dropColumn('image'); 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /database/migrations/2016_06_14_065038_add_avatar_to_users.php: -------------------------------------------------------------------------------- 1 | string('avatar')->nullable(); 17 | }); 18 | } 19 | 20 | /** 21 | * Reverse the migrations. 22 | * 23 | * @return void 24 | */ 25 | public function down() 26 | { 27 | Schema::table('users', function (Blueprint $table) { 28 | $table->dropColumn('avatar'); 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /database/migrations/2016_06_19_060821_add_company_to_users.php: -------------------------------------------------------------------------------- 1 | string('company')->nullable(); 17 | }); 18 | } 19 | 20 | /** 21 | * Reverse the migrations. 22 | * 23 | * @return void 24 | */ 25 | public function down() 26 | { 27 | Schema::table('users', function (Blueprint $table) { 28 | $table->dropColumn('company'); 29 | }); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /database/seeds/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /database/seeds/CoursesTableSeeder.php: -------------------------------------------------------------------------------- 1 | create()->each(function($course) { 15 | $course->lessons()->saveMany(factory(App\Lesson::class, 10)->make()); 16 | }); 17 | 18 | // Add dummy file to one lesson 19 | $lesson = App\Lesson::first(); 20 | $files = factory(App\LessonFile::class, 2)->create(); 21 | $lesson->files()->saveMany($files); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /database/seeds/DatabaseSeeder.php: -------------------------------------------------------------------------------- 1 | call(CoursesTableSeeder::class); 15 | $this->call(RolesTableSeeder::class); 16 | $this->call(UsersTableSeeder::class); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /database/seeds/RolesTableSeeder.php: -------------------------------------------------------------------------------- 1 | insert([ 15 | ['name' => 'user'], 16 | ['name' => 'admin'], 17 | ['name' => 'superadmin'] 18 | ]); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /gulp/config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Config file used for gulp tasks 3 | */ 4 | var assets = './resources/assets/'; 5 | 6 | module.exports = { 7 | scsslint: { 8 | src: [ 9 | assets + '/sass/**/*.{sass,scss}', 10 | '!' + assets + '/scss/_sprites.scss', //ignore generated sprites 11 | '!' + assets + '/scss/_sprites_jpg.scss' 12 | ], 13 | options: { 14 | bundleExec: false 15 | } 16 | }, 17 | jshint: { 18 | src: assets + '/js/*.js' 19 | } 20 | }; -------------------------------------------------------------------------------- /gulp/tasks/js-hint.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Use jshint to check syntax of js files 3 | * Dependencies: 4 | * - gulp-jshint 5 | * - jshint-stylish 6 | */ 7 | 8 | var gulp = require('gulp'); 9 | var jshint = require('gulp-jshint'); 10 | var stylish = require('jshint-stylish'); 11 | var config = require('../config').jshint; 12 | 13 | gulp.task('jshint', function() { 14 | return gulp.src(config.src) 15 | .pipe(jshint()) 16 | .pipe(jshint.reporter(stylish)); 17 | }); -------------------------------------------------------------------------------- /gulp/tasks/scss-lint.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Lint SCSS files 3 | * Dependencies: 4 | * - scss-lint ruby gem 5 | * - gulp-scss-lint 6 | */ 7 | 8 | var gulp = require('gulp'); 9 | var scsslint = require('gulp-scss-lint'); 10 | var config = require('../config').scsslint; 11 | 12 | gulp.task('scsslint', function() { 13 | return gulp.src(config.src) 14 | .pipe(scsslint(config.options)); 15 | }); -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | var elixir = require('laravel-elixir'); 2 | var requireDir = require('require-dir'); 3 | 4 | // load in extra gulp tasks in gulp folder 5 | requireDir('./gulp/tasks', {recurse:true}); 6 | 7 | /* 8 | |-------------------------------------------------------------------------- 9 | | Elixir Asset Management 10 | |-------------------------------------------------------------------------- 11 | | 12 | | Elixir provides a clean, fluent API for defining some basic Gulp tasks 13 | | for your Laravel application. By default, we are compiling the Sass 14 | | file for our application, as well as publishing vendor resources. 15 | | 16 | */ 17 | 18 | elixir(function(mix) { 19 | mix.task('scsslint', 'resources/assets/sass/**/*.{sass,scss}'); 20 | mix.task('jshint', 'resources/assets/js/*.js'); 21 | mix.sass('app.scss'); 22 | mix.browserify('main.js', 'public/js/app.js'); 23 | 24 | if(elixir.config.production) { // only run this tasks when production flag is present 25 | mix.version(['css/app.css', 'js/app.js']); 26 | } 27 | 28 | mix.browserSync({ 29 | proxy: '192.168.10.10' 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "prod": "gulp --production", 5 | "dev": "gulp watch" 6 | }, 7 | "devDependencies": { 8 | "bootstrap-sass": "^3.3.0", 9 | "browserify-shim": "^3.8.12", 10 | "gulp": "^3.9.1", 11 | "gulp-jshint": "^2.0.1", 12 | "gulp-scss-lint": "^0.3.9", 13 | "jquery": "^2.2.4", 14 | "jshint": "^2.9.2", 15 | "jshint-stylish": "^2.2.0", 16 | "laravel-elixir": "^5.0.0", 17 | "lodash": "^4.13.1", 18 | "medium-editor-insert-plugin": "^2.3.2", 19 | "rangy": "^1.3.0", 20 | "require-dir": "^0.3.0" 21 | }, 22 | "browserify": { 23 | "transform": [ 24 | "browserify-shim" 25 | ] 26 | }, 27 | "browserify-shim": {}, 28 | "browser": { 29 | "highlight": "./resources/assets/js/vendor/highlight.pack.js" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 |