├── .editorconfig
├── .env.example
├── .gitattributes
├── .gitignore
├── .styleci.yml
├── README.md
├── app
├── Category.php
├── Console
│ └── Kernel.php
├── Exceptions
│ └── Handler.php
├── Http
│ ├── Controllers
│ │ ├── Admin
│ │ │ ├── CategoriesController.php
│ │ │ ├── HomeController.php
│ │ │ ├── OptionsController.php
│ │ │ ├── PermissionsController.php
│ │ │ ├── QuestionsController.php
│ │ │ ├── ResultsController.php
│ │ │ ├── RolesController.php
│ │ │ └── UsersController.php
│ │ ├── Api
│ │ │ └── V1
│ │ │ │ └── Admin
│ │ │ │ ├── CategoriesApiController.php
│ │ │ │ ├── OptionsApiController.php
│ │ │ │ ├── PermissionsApiController.php
│ │ │ │ ├── QuestionsApiController.php
│ │ │ │ ├── ResultsApiController.php
│ │ │ │ ├── RolesApiController.php
│ │ │ │ └── UsersApiController.php
│ │ ├── Auth
│ │ │ ├── ConfirmPasswordController.php
│ │ │ ├── ForgotPasswordController.php
│ │ │ ├── LoginController.php
│ │ │ ├── RegisterController.php
│ │ │ ├── ResetPasswordController.php
│ │ │ └── VerificationController.php
│ │ ├── ChangePasswordController.php
│ │ ├── Controller.php
│ │ ├── HomeController.php
│ │ ├── ResultsController.php
│ │ └── TestsController.php
│ ├── Kernel.php
│ ├── Middleware
│ │ ├── AuthGates.php
│ │ ├── Authenticate.php
│ │ ├── CheckForMaintenanceMode.php
│ │ ├── CheckIfAdmin.php
│ │ ├── EncryptCookies.php
│ │ ├── RedirectIfAuthenticated.php
│ │ ├── SetLocale.php
│ │ ├── TrimStrings.php
│ │ ├── TrustProxies.php
│ │ └── VerifyCsrfToken.php
│ ├── Requests
│ │ ├── MassDestroyCategoryRequest.php
│ │ ├── MassDestroyOptionRequest.php
│ │ ├── MassDestroyPermissionRequest.php
│ │ ├── MassDestroyQuestionRequest.php
│ │ ├── MassDestroyResultRequest.php
│ │ ├── MassDestroyRoleRequest.php
│ │ ├── MassDestroyUserRequest.php
│ │ ├── StoreCategoryRequest.php
│ │ ├── StoreOptionRequest.php
│ │ ├── StorePermissionRequest.php
│ │ ├── StoreQuestionRequest.php
│ │ ├── StoreResultRequest.php
│ │ ├── StoreRoleRequest.php
│ │ ├── StoreTestRequest.php
│ │ ├── StoreUserRequest.php
│ │ ├── UpdateCategoryRequest.php
│ │ ├── UpdateOptionRequest.php
│ │ ├── UpdatePermissionRequest.php
│ │ ├── UpdateQuestionRequest.php
│ │ ├── UpdateResultRequest.php
│ │ ├── UpdateRoleRequest.php
│ │ └── UpdateUserRequest.php
│ └── Resources
│ │ └── Admin
│ │ ├── CategoryResource.php
│ │ ├── OptionResource.php
│ │ ├── PermissionResource.php
│ │ ├── QuestionResource.php
│ │ ├── ResultResource.php
│ │ ├── RoleResource.php
│ │ └── UserResource.php
├── Notifications
│ └── SendResultsPdfNotification.php
├── Option.php
├── Permission.php
├── Providers
│ ├── AppServiceProvider.php
│ ├── AuthServiceProvider.php
│ ├── BroadcastServiceProvider.php
│ ├── EventServiceProvider.php
│ └── RouteServiceProvider.php
├── Question.php
├── Result.php
├── Role.php
└── User.php
├── artisan
├── bootstrap
├── app.php
└── cache
│ └── .gitignore
├── composer.json
├── composer.lock
├── config
├── app.php
├── auth.php
├── broadcasting.php
├── cache.php
├── database.php
├── filesystems.php
├── hashing.php
├── logging.php
├── mail.php
├── panel.php
├── queue.php
├── services.php
├── session.php
└── view.php
├── database
├── .gitignore
├── factories
│ └── UserFactory.php
├── migrations
│ ├── 2014_10_12_100000_create_password_resets_table.php
│ ├── 2019_12_23_000001_create_permissions_table.php
│ ├── 2019_12_23_000002_create_roles_table.php
│ ├── 2019_12_23_000003_create_users_table.php
│ ├── 2019_12_23_000004_create_categories_table.php
│ ├── 2019_12_23_000005_create_questions_table.php
│ ├── 2019_12_23_000006_create_options_table.php
│ ├── 2019_12_23_000007_create_results_table.php
│ ├── 2019_12_23_000008_create_permission_role_pivot_table.php
│ ├── 2019_12_23_000009_create_role_user_pivot_table.php
│ ├── 2019_12_23_000010_create_question_result_pivot_table.php
│ ├── 2019_12_23_000011_add_relationship_fields_to_questions_table.php
│ ├── 2019_12_23_000012_add_relationship_fields_to_options_table.php
│ └── 2019_12_23_000013_add_relationship_fields_to_results_table.php
└── seeds
│ ├── CategoriesTableSeeder.php
│ ├── DatabaseSeeder.php
│ ├── OptionsTableSeeder.php
│ ├── PermissionRoleTableSeeder.php
│ ├── PermissionsTableSeeder.php
│ ├── QuestionsTableSeeder.php
│ ├── RoleUserTableSeeder.php
│ ├── RolesTableSeeder.php
│ └── UsersTableSeeder.php
├── package-lock.json
├── package.json
├── phpunit.xml
├── public
├── .htaccess
├── css
│ ├── app.css
│ └── custom.css
├── favicon.ico
├── index.php
├── js
│ ├── app.js
│ └── main.js
├── mix-manifest.json
└── robots.txt
├── resources
├── js
│ ├── app.js
│ ├── bootstrap.js
│ └── components
│ │ └── ExampleComponent.vue
├── lang
│ └── en
│ │ ├── auth.php
│ │ ├── cruds.php
│ │ ├── global.php
│ │ ├── pagination.php
│ │ ├── panel.php
│ │ ├── passwords.php
│ │ └── validation.php
├── sass
│ ├── _variables.scss
│ └── app.scss
└── views
│ ├── admin
│ ├── categories
│ │ ├── create.blade.php
│ │ ├── edit.blade.php
│ │ ├── index.blade.php
│ │ └── show.blade.php
│ ├── options
│ │ ├── create.blade.php
│ │ ├── edit.blade.php
│ │ ├── index.blade.php
│ │ └── show.blade.php
│ ├── permissions
│ │ ├── create.blade.php
│ │ ├── edit.blade.php
│ │ ├── index.blade.php
│ │ └── show.blade.php
│ ├── questions
│ │ ├── create.blade.php
│ │ ├── edit.blade.php
│ │ ├── index.blade.php
│ │ └── show.blade.php
│ ├── results
│ │ ├── create.blade.php
│ │ ├── edit.blade.php
│ │ ├── index.blade.php
│ │ └── show.blade.php
│ ├── roles
│ │ ├── create.blade.php
│ │ ├── edit.blade.php
│ │ ├── index.blade.php
│ │ └── show.blade.php
│ └── users
│ │ ├── create.blade.php
│ │ ├── edit.blade.php
│ │ ├── index.blade.php
│ │ └── show.blade.php
│ ├── auth
│ ├── login.blade.php
│ ├── passwords
│ │ ├── confirm.blade.php
│ │ ├── email.blade.php
│ │ └── reset.blade.php
│ ├── register.blade.php
│ └── verify.blade.php
│ ├── client
│ ├── changePassword.blade.php
│ ├── home.blade.php
│ ├── pdf.blade.php
│ ├── results.blade.php
│ └── test.blade.php
│ ├── home.blade.php
│ ├── layouts
│ ├── admin.blade.php
│ ├── app.blade.php
│ └── client.blade.php
│ ├── partials
│ └── menu.blade.php
│ └── welcome.blade.php
├── routes
├── api.php
├── channels.php
├── console.php
└── web.php
├── server.php
├── storage
├── app
│ └── .gitignore
├── fonts
│ └── .gitignore
├── framework
│ ├── .gitignore
│ ├── cache
│ │ └── .gitignore
│ ├── sessions
│ │ └── .gitignore
│ ├── testing
│ │ └── .gitignore
│ └── views
│ │ └── .gitignore
└── logs
│ └── .gitignore
├── tests
├── Browser
│ ├── CategoriesTest.php
│ ├── OptionsTest.php
│ ├── PermissionsTest.php
│ ├── QuestionsTest.php
│ ├── ResultsTest.php
│ ├── RolesTest.php
│ └── UsersTest.php
├── CreatesApplication.php
├── Feature
│ └── ExampleTest.php
├── TestCase.php
└── Unit
│ └── ExampleTest.php
└── webpack.mix.js
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | end_of_line = lf
6 | insert_final_newline = true
7 | indent_style = space
8 | indent_size = 4
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
14 | [*.{yml,yaml}]
15 | indent_size = 2
16 |
--------------------------------------------------------------------------------
/.env.example:
--------------------------------------------------------------------------------
1 | APP_NAME="Test"
2 | APP_ENV=local
3 | APP_KEY=
4 | APP_DEBUG=true
5 | APP_URL=http://localhost
6 |
7 | LOG_CHANNEL=stack
8 |
9 | DB_CONNECTION=mysql
10 | DB_HOST=127.0.0.1
11 | DB_PORT=3306
12 | DB_DATABASE=laravel
13 | DB_USERNAME=root
14 | DB_PASSWORD=
15 |
16 | BROADCAST_DRIVER=log
17 | CACHE_DRIVER=file
18 | QUEUE_CONNECTION=sync
19 | SESSION_DRIVER=file
20 | SESSION_LIFETIME=120
21 |
22 | REDIS_HOST=127.0.0.1
23 | REDIS_PASSWORD=null
24 | REDIS_PORT=6379
25 |
26 | MAIL_DRIVER=smtp
27 | MAIL_HOST=smtp.mailtrap.io
28 | MAIL_PORT=2525
29 | MAIL_USERNAME=null
30 | MAIL_PASSWORD=null
31 | MAIL_ENCRYPTION=null
32 |
33 | AWS_ACCESS_KEY_ID=
34 | AWS_SECRET_ACCESS_KEY=
35 | AWS_DEFAULT_REGION=us-east-1
36 | AWS_BUCKET=
37 |
38 | PUSHER_APP_ID=
39 | PUSHER_APP_KEY=
40 | PUSHER_APP_SECRET=
41 | PUSHER_APP_CLUSTER=mt1
42 |
43 | MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
44 | MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
45 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 | *.css linguist-vendored
3 | *.scss linguist-vendored
4 | *.js linguist-vendored
5 | CHANGELOG.md export-ignore
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | /public/hot
3 | /public/storage
4 | /storage/*.key
5 | /vendor
6 | .env
7 | .env.backup
8 | .phpunit.result.cache
9 | Homestead.json
10 | Homestead.yaml
11 | npm-debug.log
12 | yarn-error.log
13 | .idea
14 |
--------------------------------------------------------------------------------
/.styleci.yml:
--------------------------------------------------------------------------------
1 | php:
2 | preset: laravel
3 | enabled:
4 | - alpha_ordered_imports
5 | disabled:
6 | - length_ordered_imports
7 | - unused_use
8 | finder:
9 | not-name:
10 | - index.php
11 | - server.php
12 | js:
13 | finder:
14 | not-name:
15 | - webpack.mix.js
16 | css: true
17 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Laravel Quiz/Test Project with PDF Results
2 |
3 | Quite typical project where user goes through some set of questions - quiz, survey, assessment or similar.
4 |
5 | They get the result of how many points they've got, and then get the PDF report via email.
6 |
7 | - - - - -
8 |
9 | ## Screenshots
10 |
11 | 
12 |
13 | 
14 |
15 | 
16 |
17 | - - - - -
18 |
19 | ## How to use
20 |
21 | - Clone the repository with __git clone__
22 | - Copy __.env.example__ file to __.env__ and edit database credentials there
23 | - Run __composer install__
24 | - Run __php artisan key:generate__
25 | - Run __php artisan migrate --seed__ (it has some seeded data for your testing)
26 | - That's it: launch the main URL.
27 | - You can login to adminpanel by going go `/login` URL and login with credentials __admin@admin.com__ - __password__
28 | - Click __Register__ to register as new user and start the test
29 |
30 |
31 | - - - - -
32 |
33 | ## License
34 |
35 | Basically, feel free to use and re-use any way you want.
36 |
37 | - - - - -
38 |
39 | ## More from our LaravelDaily Team
40 |
41 | - Check out our adminpanel generator [QuickAdminPanel](https://quickadminpanel.com)
42 | - Read our [Blog with Laravel Tutorials](https://laraveldaily.com)
43 | - FREE E-book: [50 Laravel Quick Tips (and counting)](https://laraveldaily.com/free-e-book-40-laravel-quick-tips-and-counting/)
44 | - Subscribe to our [YouTube channel Laravel Business](https://www.youtube.com/channel/UCTuplgOBi6tJIlesIboymGA)
45 | - Enroll in our [Laravel Online Courses](https://laraveldaily.teachable.com/)
46 |
--------------------------------------------------------------------------------
/app/Category.php:
--------------------------------------------------------------------------------
1 | hasMany(Question::class, 'category_id', 'id');
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/Console/Kernel.php:
--------------------------------------------------------------------------------
1 | command('inspire')
28 | // ->hourly();
29 | }
30 |
31 | /**
32 | * Register the commands for the application.
33 | *
34 | * @return void
35 | */
36 | protected function commands()
37 | {
38 | $this->load(__DIR__.'/Commands');
39 |
40 | require base_path('routes/console.php');
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/Exceptions/Handler.php:
--------------------------------------------------------------------------------
1 | all());
35 |
36 | return redirect()->route('admin.categories.index');
37 | }
38 |
39 | public function edit(Category $category)
40 | {
41 | abort_if(Gate::denies('category_edit'), Response::HTTP_FORBIDDEN, '403 Forbidden');
42 |
43 | return view('admin.categories.edit', compact('category'));
44 | }
45 |
46 | public function update(UpdateCategoryRequest $request, Category $category)
47 | {
48 | $category->update($request->all());
49 |
50 | return redirect()->route('admin.categories.index');
51 | }
52 |
53 | public function show(Category $category)
54 | {
55 | abort_if(Gate::denies('category_show'), Response::HTTP_FORBIDDEN, '403 Forbidden');
56 |
57 | return view('admin.categories.show', compact('category'));
58 | }
59 |
60 | public function destroy(Category $category)
61 | {
62 | abort_if(Gate::denies('category_delete'), Response::HTTP_FORBIDDEN, '403 Forbidden');
63 |
64 | $category->delete();
65 |
66 | return back();
67 | }
68 |
69 | public function massDestroy(MassDestroyCategoryRequest $request)
70 | {
71 | Category::whereIn('id', request('ids'))->delete();
72 |
73 | return response(null, Response::HTTP_NO_CONTENT);
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Admin/HomeController.php:
--------------------------------------------------------------------------------
1 | pluck('question_text', 'id')->prepend(trans('global.pleaseSelect'), '');
31 |
32 | return view('admin.options.create', compact('questions'));
33 | }
34 |
35 | public function store(StoreOptionRequest $request)
36 | {
37 | $option = Option::create($request->all());
38 |
39 | return redirect()->route('admin.options.index');
40 | }
41 |
42 | public function edit(Option $option)
43 | {
44 | abort_if(Gate::denies('option_edit'), Response::HTTP_FORBIDDEN, '403 Forbidden');
45 |
46 | $questions = Question::all()->pluck('question_text', 'id')->prepend(trans('global.pleaseSelect'), '');
47 |
48 | $option->load('question');
49 |
50 | return view('admin.options.edit', compact('questions', 'option'));
51 | }
52 |
53 | public function update(UpdateOptionRequest $request, Option $option)
54 | {
55 | $option->update($request->all());
56 |
57 | return redirect()->route('admin.options.index');
58 | }
59 |
60 | public function show(Option $option)
61 | {
62 | abort_if(Gate::denies('option_show'), Response::HTTP_FORBIDDEN, '403 Forbidden');
63 |
64 | $option->load('question');
65 |
66 | return view('admin.options.show', compact('option'));
67 | }
68 |
69 | public function destroy(Option $option)
70 | {
71 | abort_if(Gate::denies('option_delete'), Response::HTTP_FORBIDDEN, '403 Forbidden');
72 |
73 | $option->delete();
74 |
75 | return back();
76 | }
77 |
78 | public function massDestroy(MassDestroyOptionRequest $request)
79 | {
80 | Option::whereIn('id', request('ids'))->delete();
81 |
82 | return response(null, Response::HTTP_NO_CONTENT);
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Admin/PermissionsController.php:
--------------------------------------------------------------------------------
1 | all());
35 |
36 | return redirect()->route('admin.permissions.index');
37 | }
38 |
39 | public function edit(Permission $permission)
40 | {
41 | abort_if(Gate::denies('permission_edit'), Response::HTTP_FORBIDDEN, '403 Forbidden');
42 |
43 | return view('admin.permissions.edit', compact('permission'));
44 | }
45 |
46 | public function update(UpdatePermissionRequest $request, Permission $permission)
47 | {
48 | $permission->update($request->all());
49 |
50 | return redirect()->route('admin.permissions.index');
51 | }
52 |
53 | public function show(Permission $permission)
54 | {
55 | abort_if(Gate::denies('permission_show'), Response::HTTP_FORBIDDEN, '403 Forbidden');
56 |
57 | return view('admin.permissions.show', compact('permission'));
58 | }
59 |
60 | public function destroy(Permission $permission)
61 | {
62 | abort_if(Gate::denies('permission_delete'), Response::HTTP_FORBIDDEN, '403 Forbidden');
63 |
64 | $permission->delete();
65 |
66 | return back();
67 | }
68 |
69 | public function massDestroy(MassDestroyPermissionRequest $request)
70 | {
71 | Permission::whereIn('id', request('ids'))->delete();
72 |
73 | return response(null, Response::HTTP_NO_CONTENT);
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Admin/QuestionsController.php:
--------------------------------------------------------------------------------
1 | pluck('name', 'id')->prepend(trans('global.pleaseSelect'), '');
31 |
32 | return view('admin.questions.create', compact('categories'));
33 | }
34 |
35 | public function store(StoreQuestionRequest $request)
36 | {
37 | $question = Question::create($request->all());
38 |
39 | return redirect()->route('admin.questions.index');
40 | }
41 |
42 | public function edit(Question $question)
43 | {
44 | abort_if(Gate::denies('question_edit'), Response::HTTP_FORBIDDEN, '403 Forbidden');
45 |
46 | $categories = Category::all()->pluck('name', 'id')->prepend(trans('global.pleaseSelect'), '');
47 |
48 | $question->load('category');
49 |
50 | return view('admin.questions.edit', compact('categories', 'question'));
51 | }
52 |
53 | public function update(UpdateQuestionRequest $request, Question $question)
54 | {
55 | $question->update($request->all());
56 |
57 | return redirect()->route('admin.questions.index');
58 | }
59 |
60 | public function show(Question $question)
61 | {
62 | abort_if(Gate::denies('question_show'), Response::HTTP_FORBIDDEN, '403 Forbidden');
63 |
64 | $question->load('category');
65 |
66 | return view('admin.questions.show', compact('question'));
67 | }
68 |
69 | public function destroy(Question $question)
70 | {
71 | abort_if(Gate::denies('question_delete'), Response::HTTP_FORBIDDEN, '403 Forbidden');
72 |
73 | $question->delete();
74 |
75 | return back();
76 | }
77 |
78 | public function massDestroy(MassDestroyQuestionRequest $request)
79 | {
80 | Question::whereIn('id', request('ids'))->delete();
81 |
82 | return response(null, Response::HTTP_NO_CONTENT);
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Admin/ResultsController.php:
--------------------------------------------------------------------------------
1 | pluck('name', 'id')->prepend(trans('global.pleaseSelect'), '');
32 |
33 | $questions = Question::all()->pluck('question_text', 'id');
34 |
35 | return view('admin.results.create', compact('users', 'questions'));
36 | }
37 |
38 | public function store(StoreResultRequest $request)
39 | {
40 | $result = Result::create($request->all());
41 | $result->questions()->sync($request->input('questions', []));
42 |
43 | return redirect()->route('admin.results.index');
44 | }
45 |
46 | public function edit(Result $result)
47 | {
48 | abort_if(Gate::denies('result_edit'), Response::HTTP_FORBIDDEN, '403 Forbidden');
49 |
50 | $users = User::all()->pluck('name', 'id')->prepend(trans('global.pleaseSelect'), '');
51 |
52 | $questions = Question::all()->pluck('question_text', 'id');
53 |
54 | $result->load('user', 'questions');
55 |
56 | return view('admin.results.edit', compact('users', 'questions', 'result'));
57 | }
58 |
59 | public function update(UpdateResultRequest $request, Result $result)
60 | {
61 | $result->update($request->all());
62 | $result->questions()->sync($request->input('questions', []));
63 |
64 | return redirect()->route('admin.results.index');
65 | }
66 |
67 | public function show(Result $result)
68 | {
69 | abort_if(Gate::denies('result_show'), Response::HTTP_FORBIDDEN, '403 Forbidden');
70 |
71 | $result->load('user', 'questions');
72 |
73 | return view('admin.results.show', compact('result'));
74 | }
75 |
76 | public function destroy(Result $result)
77 | {
78 | abort_if(Gate::denies('result_delete'), Response::HTTP_FORBIDDEN, '403 Forbidden');
79 |
80 | $result->delete();
81 |
82 | return back();
83 | }
84 |
85 | public function massDestroy(MassDestroyResultRequest $request)
86 | {
87 | Result::whereIn('id', request('ids'))->delete();
88 |
89 | return response(null, Response::HTTP_NO_CONTENT);
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Admin/RolesController.php:
--------------------------------------------------------------------------------
1 | pluck('title', 'id');
31 |
32 | return view('admin.roles.create', compact('permissions'));
33 | }
34 |
35 | public function store(StoreRoleRequest $request)
36 | {
37 | $role = Role::create($request->all());
38 | $role->permissions()->sync($request->input('permissions', []));
39 |
40 | return redirect()->route('admin.roles.index');
41 | }
42 |
43 | public function edit(Role $role)
44 | {
45 | abort_if(Gate::denies('role_edit'), Response::HTTP_FORBIDDEN, '403 Forbidden');
46 |
47 | $permissions = Permission::all()->pluck('title', 'id');
48 |
49 | $role->load('permissions');
50 |
51 | return view('admin.roles.edit', compact('permissions', 'role'));
52 | }
53 |
54 | public function update(UpdateRoleRequest $request, Role $role)
55 | {
56 | $role->update($request->all());
57 | $role->permissions()->sync($request->input('permissions', []));
58 |
59 | return redirect()->route('admin.roles.index');
60 | }
61 |
62 | public function show(Role $role)
63 | {
64 | abort_if(Gate::denies('role_show'), Response::HTTP_FORBIDDEN, '403 Forbidden');
65 |
66 | $role->load('permissions');
67 |
68 | return view('admin.roles.show', compact('role'));
69 | }
70 |
71 | public function destroy(Role $role)
72 | {
73 | abort_if(Gate::denies('role_delete'), Response::HTTP_FORBIDDEN, '403 Forbidden');
74 |
75 | $role->delete();
76 |
77 | return back();
78 | }
79 |
80 | public function massDestroy(MassDestroyRoleRequest $request)
81 | {
82 | Role::whereIn('id', request('ids'))->delete();
83 |
84 | return response(null, Response::HTTP_NO_CONTENT);
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Admin/UsersController.php:
--------------------------------------------------------------------------------
1 | pluck('title', 'id');
31 |
32 | return view('admin.users.create', compact('roles'));
33 | }
34 |
35 | public function store(StoreUserRequest $request)
36 | {
37 | $user = User::create($request->all());
38 | $user->roles()->sync($request->input('roles', []));
39 |
40 | return redirect()->route('admin.users.index');
41 | }
42 |
43 | public function edit(User $user)
44 | {
45 | abort_if(Gate::denies('user_edit'), Response::HTTP_FORBIDDEN, '403 Forbidden');
46 |
47 | $roles = Role::all()->pluck('title', 'id');
48 |
49 | $user->load('roles');
50 |
51 | return view('admin.users.edit', compact('roles', 'user'));
52 | }
53 |
54 | public function update(UpdateUserRequest $request, User $user)
55 | {
56 | $user->update($request->all());
57 | $user->roles()->sync($request->input('roles', []));
58 |
59 | return redirect()->route('admin.users.index');
60 | }
61 |
62 | public function show(User $user)
63 | {
64 | abort_if(Gate::denies('user_show'), Response::HTTP_FORBIDDEN, '403 Forbidden');
65 |
66 | $user->load('roles');
67 |
68 | return view('admin.users.show', compact('user'));
69 | }
70 |
71 | public function destroy(User $user)
72 | {
73 | abort_if(Gate::denies('user_delete'), Response::HTTP_FORBIDDEN, '403 Forbidden');
74 |
75 | $user->delete();
76 |
77 | return back();
78 | }
79 |
80 | public function massDestroy(MassDestroyUserRequest $request)
81 | {
82 | User::whereIn('id', request('ids'))->delete();
83 |
84 | return response(null, Response::HTTP_NO_CONTENT);
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/V1/Admin/CategoriesApiController.php:
--------------------------------------------------------------------------------
1 | all());
26 |
27 | return (new CategoryResource($category))
28 | ->response()
29 | ->setStatusCode(Response::HTTP_CREATED);
30 | }
31 |
32 | public function show(Category $category)
33 | {
34 | abort_if(Gate::denies('category_show'), Response::HTTP_FORBIDDEN, '403 Forbidden');
35 |
36 | return new CategoryResource($category);
37 | }
38 |
39 | public function update(UpdateCategoryRequest $request, Category $category)
40 | {
41 | $category->update($request->all());
42 |
43 | return (new CategoryResource($category))
44 | ->response()
45 | ->setStatusCode(Response::HTTP_ACCEPTED);
46 | }
47 |
48 | public function destroy(Category $category)
49 | {
50 | abort_if(Gate::denies('category_delete'), Response::HTTP_FORBIDDEN, '403 Forbidden');
51 |
52 | $category->delete();
53 |
54 | return response(null, Response::HTTP_NO_CONTENT);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/V1/Admin/OptionsApiController.php:
--------------------------------------------------------------------------------
1 | get());
21 | }
22 |
23 | public function store(StoreOptionRequest $request)
24 | {
25 | $option = Option::create($request->all());
26 |
27 | return (new OptionResource($option))
28 | ->response()
29 | ->setStatusCode(Response::HTTP_CREATED);
30 | }
31 |
32 | public function show(Option $option)
33 | {
34 | abort_if(Gate::denies('option_show'), Response::HTTP_FORBIDDEN, '403 Forbidden');
35 |
36 | return new OptionResource($option->load(['question']));
37 | }
38 |
39 | public function update(UpdateOptionRequest $request, Option $option)
40 | {
41 | $option->update($request->all());
42 |
43 | return (new OptionResource($option))
44 | ->response()
45 | ->setStatusCode(Response::HTTP_ACCEPTED);
46 | }
47 |
48 | public function destroy(Option $option)
49 | {
50 | abort_if(Gate::denies('option_delete'), Response::HTTP_FORBIDDEN, '403 Forbidden');
51 |
52 | $option->delete();
53 |
54 | return response(null, Response::HTTP_NO_CONTENT);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/V1/Admin/PermissionsApiController.php:
--------------------------------------------------------------------------------
1 | all());
26 |
27 | return (new PermissionResource($permission))
28 | ->response()
29 | ->setStatusCode(Response::HTTP_CREATED);
30 | }
31 |
32 | public function show(Permission $permission)
33 | {
34 | abort_if(Gate::denies('permission_show'), Response::HTTP_FORBIDDEN, '403 Forbidden');
35 |
36 | return new PermissionResource($permission);
37 | }
38 |
39 | public function update(UpdatePermissionRequest $request, Permission $permission)
40 | {
41 | $permission->update($request->all());
42 |
43 | return (new PermissionResource($permission))
44 | ->response()
45 | ->setStatusCode(Response::HTTP_ACCEPTED);
46 | }
47 |
48 | public function destroy(Permission $permission)
49 | {
50 | abort_if(Gate::denies('permission_delete'), Response::HTTP_FORBIDDEN, '403 Forbidden');
51 |
52 | $permission->delete();
53 |
54 | return response(null, Response::HTTP_NO_CONTENT);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/V1/Admin/QuestionsApiController.php:
--------------------------------------------------------------------------------
1 | get());
21 | }
22 |
23 | public function store(StoreQuestionRequest $request)
24 | {
25 | $question = Question::create($request->all());
26 |
27 | return (new QuestionResource($question))
28 | ->response()
29 | ->setStatusCode(Response::HTTP_CREATED);
30 | }
31 |
32 | public function show(Question $question)
33 | {
34 | abort_if(Gate::denies('question_show'), Response::HTTP_FORBIDDEN, '403 Forbidden');
35 |
36 | return new QuestionResource($question->load(['category']));
37 | }
38 |
39 | public function update(UpdateQuestionRequest $request, Question $question)
40 | {
41 | $question->update($request->all());
42 |
43 | return (new QuestionResource($question))
44 | ->response()
45 | ->setStatusCode(Response::HTTP_ACCEPTED);
46 | }
47 |
48 | public function destroy(Question $question)
49 | {
50 | abort_if(Gate::denies('question_delete'), Response::HTTP_FORBIDDEN, '403 Forbidden');
51 |
52 | $question->delete();
53 |
54 | return response(null, Response::HTTP_NO_CONTENT);
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/V1/Admin/ResultsApiController.php:
--------------------------------------------------------------------------------
1 | get());
21 | }
22 |
23 | public function store(StoreResultRequest $request)
24 | {
25 | $result = Result::create($request->all());
26 | $result->questions()->sync($request->input('questions', []));
27 |
28 | return (new ResultResource($result))
29 | ->response()
30 | ->setStatusCode(Response::HTTP_CREATED);
31 | }
32 |
33 | public function show(Result $result)
34 | {
35 | abort_if(Gate::denies('result_show'), Response::HTTP_FORBIDDEN, '403 Forbidden');
36 |
37 | return new ResultResource($result->load(['user', 'questions']));
38 | }
39 |
40 | public function update(UpdateResultRequest $request, Result $result)
41 | {
42 | $result->update($request->all());
43 | $result->questions()->sync($request->input('questions', []));
44 |
45 | return (new ResultResource($result))
46 | ->response()
47 | ->setStatusCode(Response::HTTP_ACCEPTED);
48 | }
49 |
50 | public function destroy(Result $result)
51 | {
52 | abort_if(Gate::denies('result_delete'), Response::HTTP_FORBIDDEN, '403 Forbidden');
53 |
54 | $result->delete();
55 |
56 | return response(null, Response::HTTP_NO_CONTENT);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/V1/Admin/RolesApiController.php:
--------------------------------------------------------------------------------
1 | get());
21 | }
22 |
23 | public function store(StoreRoleRequest $request)
24 | {
25 | $role = Role::create($request->all());
26 | $role->permissions()->sync($request->input('permissions', []));
27 |
28 | return (new RoleResource($role))
29 | ->response()
30 | ->setStatusCode(Response::HTTP_CREATED);
31 | }
32 |
33 | public function show(Role $role)
34 | {
35 | abort_if(Gate::denies('role_show'), Response::HTTP_FORBIDDEN, '403 Forbidden');
36 |
37 | return new RoleResource($role->load(['permissions']));
38 | }
39 |
40 | public function update(UpdateRoleRequest $request, Role $role)
41 | {
42 | $role->update($request->all());
43 | $role->permissions()->sync($request->input('permissions', []));
44 |
45 | return (new RoleResource($role))
46 | ->response()
47 | ->setStatusCode(Response::HTTP_ACCEPTED);
48 | }
49 |
50 | public function destroy(Role $role)
51 | {
52 | abort_if(Gate::denies('role_delete'), Response::HTTP_FORBIDDEN, '403 Forbidden');
53 |
54 | $role->delete();
55 |
56 | return response(null, Response::HTTP_NO_CONTENT);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Api/V1/Admin/UsersApiController.php:
--------------------------------------------------------------------------------
1 | get());
21 | }
22 |
23 | public function store(StoreUserRequest $request)
24 | {
25 | $user = User::create($request->all());
26 | $user->roles()->sync($request->input('roles', []));
27 |
28 | return (new UserResource($user))
29 | ->response()
30 | ->setStatusCode(Response::HTTP_CREATED);
31 | }
32 |
33 | public function show(User $user)
34 | {
35 | abort_if(Gate::denies('user_show'), Response::HTTP_FORBIDDEN, '403 Forbidden');
36 |
37 | return new UserResource($user->load(['roles']));
38 | }
39 |
40 | public function update(UpdateUserRequest $request, User $user)
41 | {
42 | $user->update($request->all());
43 | $user->roles()->sync($request->input('roles', []));
44 |
45 | return (new UserResource($user))
46 | ->response()
47 | ->setStatusCode(Response::HTTP_ACCEPTED);
48 | }
49 |
50 | public function destroy(User $user)
51 | {
52 | abort_if(Gate::denies('user_delete'), Response::HTTP_FORBIDDEN, '403 Forbidden');
53 |
54 | $user->delete();
55 |
56 | return response(null, Response::HTTP_NO_CONTENT);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Auth/ConfirmPasswordController.php:
--------------------------------------------------------------------------------
1 | middleware('auth');
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Auth/ForgotPasswordController.php:
--------------------------------------------------------------------------------
1 | middleware('guest')->except('logout');
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Auth/RegisterController.php:
--------------------------------------------------------------------------------
1 | middleware('guest');
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', 'string', 'max:255'],
53 | 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
54 | 'password' => ['required', 'string', 'min:8', 'confirmed'],
55 | ]);
56 | }
57 |
58 | /**
59 | * Create a new user instance after a valid registration.
60 | *
61 | * @param array $data
62 | * @return \App\User
63 | */
64 | protected function create(array $data)
65 | {
66 | return User::create([
67 | 'name' => $data['name'],
68 | 'email' => $data['email'],
69 | 'password' => Hash::make($data['password']),
70 | ]);
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Auth/ResetPasswordController.php:
--------------------------------------------------------------------------------
1 | middleware('auth');
38 | $this->middleware('signed')->only('verify');
39 | $this->middleware('throttle:6,1')->only('verify', 'resend');
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/Http/Controllers/ChangePasswordController.php:
--------------------------------------------------------------------------------
1 | validator($request->all())->validate();
29 |
30 | auth()->user()->update(['password' => $request->input('password')]);
31 |
32 | return redirect()->back()->withStatus('Password changed successfully.');
33 | }
34 |
35 | /**
36 | * Get a validator for an incoming registration request.
37 | *
38 | * @param array $data
39 | * @return \Illuminate\Contracts\Validation\Validator
40 | */
41 | protected function validator(array $data)
42 | {
43 | return Validator::make($data, [
44 | 'password' => ['required', 'string', 'min:8', 'confirmed'],
45 | ]);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Controller.php:
--------------------------------------------------------------------------------
1 | user()->is_admin) {
22 | return redirect()->route('admin.home')->with('status', session('status'));
23 | }
24 |
25 | return redirect()->route('client.home')->with('status', session('status'));
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/Http/Controllers/ResultsController.php:
--------------------------------------------------------------------------------
1 | whereId(auth()->id());
16 | })->findOrFail($result_id);
17 |
18 | return view('client.results', compact('result'));
19 | }
20 |
21 | public function send($result_id)
22 | {
23 | $result = Result::whereHas('user', function ($query) {
24 | $query->whereId(auth()->id());
25 | })->findOrFail($result_id);
26 | $filename = $result->id . '.pdf';
27 | $pdf = PDF::loadView('client.pdf', compact('result'));
28 | $pdf->save(storage_path($filename));
29 |
30 | auth()->user()->notify(new SendResultsPdfNotification($result));
31 | File::delete(storage_path($filename));
32 |
33 | return redirect()->route('client.results.show', $result->id)->withStatus('Your test result has been sent successfully!');
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/app/Http/Controllers/TestsController.php:
--------------------------------------------------------------------------------
1 | function ($query) {
14 | $query->inRandomOrder()
15 | ->with(['questionOptions' => function ($query) {
16 | $query->inRandomOrder();
17 | }]);
18 | }])
19 | ->whereHas('categoryQuestions')
20 | ->get();
21 |
22 | return view('client.test', compact('categories'));
23 | }
24 |
25 | public function store(StoreTestRequest $request)
26 | {
27 | $options = Option::find(array_values($request->input('questions')));
28 |
29 | $result = auth()->user()->userResults()->create([
30 | 'total_points' => $options->sum('points')
31 | ]);
32 |
33 | $questions = $options->mapWithKeys(function ($option) {
34 | return [$option->question_id => [
35 | 'option_id' => $option->id,
36 | 'points' => $option->points
37 | ]
38 | ];
39 | })->toArray();
40 |
41 | $result->questions()->sync($questions);
42 |
43 | return redirect()->route('client.results.show', $result->id);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/app/Http/Kernel.php:
--------------------------------------------------------------------------------
1 | [
19 | 'throttle:60,1',
20 | 'bindings',
21 | \App\Http\Middleware\AuthGates::class,
22 | ],
23 | 'web' => [
24 | \App\Http\Middleware\EncryptCookies::class,
25 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
26 | \Illuminate\Session\Middleware\StartSession::class,
27 | \Illuminate\View\Middleware\ShareErrorsFromSession::class,
28 | \App\Http\Middleware\VerifyCsrfToken::class,
29 | \Illuminate\Routing\Middleware\SubstituteBindings::class,
30 | \App\Http\Middleware\AuthGates::class,
31 | \App\Http\Middleware\SetLocale::class,
32 | ],
33 | ];
34 |
35 | protected $routeMiddleware = [
36 | 'can' => \Illuminate\Auth\Middleware\Authorize::class,
37 | 'auth.admin' => \App\Http\Middleware\CheckIfAdmin::class,
38 | 'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
39 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
40 | 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
41 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
42 | 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
43 | 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
44 | 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
45 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
46 | ];
47 | }
48 |
--------------------------------------------------------------------------------
/app/Http/Middleware/AuthGates.php:
--------------------------------------------------------------------------------
1 | runningInConsole() && $user) {
16 | $roles = Role::with('permissions')->get();
17 | $permissionsArray = [];
18 |
19 | foreach ($roles as $role) {
20 | foreach ($role->permissions as $permissions) {
21 | $permissionsArray[$permissions->title][] = $role->id;
22 | }
23 | }
24 |
25 | foreach ($permissionsArray as $title => $roles) {
26 | Gate::define($title, function (\App\User $user) use ($roles) {
27 | return count(array_intersect($user->roles->pluck('id')->toArray(), $roles)) > 0;
28 | });
29 | }
30 | }
31 |
32 | return $next($request);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/Http/Middleware/Authenticate.php:
--------------------------------------------------------------------------------
1 | expectsJson()) {
18 | return route('login');
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/app/Http/Middleware/CheckForMaintenanceMode.php:
--------------------------------------------------------------------------------
1 | check() && auth()->user()->is_admin) {
14 | return $next($request);
15 | }
16 |
17 | return redirect('/home');
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/app/Http/Middleware/EncryptCookies.php:
--------------------------------------------------------------------------------
1 | check()) {
21 | return redirect('/home');
22 | }
23 |
24 | return $next($request);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/Http/Middleware/SetLocale.php:
--------------------------------------------------------------------------------
1 | put('language', request('change_language'));
13 | $language = request('change_language');
14 | } elseif (session('language')) {
15 | $language = session('language');
16 | } elseif (config('panel.primary_language')) {
17 | $language = config('panel.primary_language');
18 | }
19 |
20 | if (isset($language)) {
21 | app()->setLocale($language);
22 | }
23 |
24 | return $next($request);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/Http/Middleware/TrimStrings.php:
--------------------------------------------------------------------------------
1 | 'required|array',
23 | 'ids.*' => 'exists:categories,id',
24 | ];
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/Http/Requests/MassDestroyOptionRequest.php:
--------------------------------------------------------------------------------
1 | 'required|array',
23 | 'ids.*' => 'exists:options,id',
24 | ];
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/Http/Requests/MassDestroyPermissionRequest.php:
--------------------------------------------------------------------------------
1 | 'required|array',
23 | 'ids.*' => 'exists:permissions,id',
24 | ];
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/Http/Requests/MassDestroyQuestionRequest.php:
--------------------------------------------------------------------------------
1 | 'required|array',
23 | 'ids.*' => 'exists:questions,id',
24 | ];
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/Http/Requests/MassDestroyResultRequest.php:
--------------------------------------------------------------------------------
1 | 'required|array',
23 | 'ids.*' => 'exists:results,id',
24 | ];
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/Http/Requests/MassDestroyRoleRequest.php:
--------------------------------------------------------------------------------
1 | 'required|array',
23 | 'ids.*' => 'exists:roles,id',
24 | ];
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/Http/Requests/MassDestroyUserRequest.php:
--------------------------------------------------------------------------------
1 | 'required|array',
23 | 'ids.*' => 'exists:users,id',
24 | ];
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/Http/Requests/StoreCategoryRequest.php:
--------------------------------------------------------------------------------
1 | [
23 | 'required',
24 | ],
25 | ];
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/Http/Requests/StoreOptionRequest.php:
--------------------------------------------------------------------------------
1 | [
23 | 'required',
24 | 'integer',
25 | ],
26 | 'option_text' => [
27 | 'required',
28 | ],
29 | 'points' => [
30 | 'nullable',
31 | 'integer',
32 | 'min:-2147483648',
33 | 'max:2147483647',
34 | ],
35 | ];
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/Http/Requests/StorePermissionRequest.php:
--------------------------------------------------------------------------------
1 | [
23 | 'required',
24 | ],
25 | ];
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/Http/Requests/StoreQuestionRequest.php:
--------------------------------------------------------------------------------
1 | [
23 | 'required',
24 | 'integer',
25 | ],
26 | 'question_text' => [
27 | 'required',
28 | ],
29 | ];
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/Http/Requests/StoreResultRequest.php:
--------------------------------------------------------------------------------
1 | [
23 | 'required',
24 | 'integer',
25 | ],
26 | 'total_points' => [
27 | 'nullable',
28 | 'integer',
29 | 'min:-2147483648',
30 | 'max:2147483647',
31 | ],
32 | 'questions.*' => [
33 | 'integer',
34 | ],
35 | 'questions' => [
36 | 'array',
37 | ],
38 | ];
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/Http/Requests/StoreRoleRequest.php:
--------------------------------------------------------------------------------
1 | [
23 | 'required',
24 | ],
25 | 'permissions.*' => [
26 | 'integer',
27 | ],
28 | 'permissions' => [
29 | 'required',
30 | 'array',
31 | ],
32 | ];
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/Http/Requests/StoreTestRequest.php:
--------------------------------------------------------------------------------
1 | check();
12 | }
13 |
14 | public function rules()
15 | {
16 | return [
17 | 'questions' => [
18 | 'required', 'array'
19 | ],
20 | 'questions.*' => [
21 | 'required', 'integer', 'exists:options,id'
22 | ],
23 | ];
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/app/Http/Requests/StoreUserRequest.php:
--------------------------------------------------------------------------------
1 | [
23 | 'required',
24 | ],
25 | 'email' => [
26 | 'required',
27 | 'unique:users',
28 | ],
29 | 'password' => [
30 | 'required',
31 | ],
32 | 'roles.*' => [
33 | 'integer',
34 | ],
35 | 'roles' => [
36 | 'required',
37 | 'array',
38 | ],
39 | ];
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/Http/Requests/UpdateCategoryRequest.php:
--------------------------------------------------------------------------------
1 | [
23 | 'required',
24 | ],
25 | ];
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/Http/Requests/UpdateOptionRequest.php:
--------------------------------------------------------------------------------
1 | [
23 | 'required',
24 | 'integer',
25 | ],
26 | 'option_text' => [
27 | 'required',
28 | ],
29 | 'points' => [
30 | 'nullable',
31 | 'integer',
32 | 'min:-2147483648',
33 | 'max:2147483647',
34 | ],
35 | ];
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/Http/Requests/UpdatePermissionRequest.php:
--------------------------------------------------------------------------------
1 | [
23 | 'required',
24 | ],
25 | ];
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/Http/Requests/UpdateQuestionRequest.php:
--------------------------------------------------------------------------------
1 | [
23 | 'required',
24 | 'integer',
25 | ],
26 | 'question_text' => [
27 | 'required',
28 | ],
29 | ];
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/Http/Requests/UpdateResultRequest.php:
--------------------------------------------------------------------------------
1 | [
23 | 'required',
24 | 'integer',
25 | ],
26 | 'total_points' => [
27 | 'nullable',
28 | 'integer',
29 | 'min:-2147483648',
30 | 'max:2147483647',
31 | ],
32 | 'questions.*' => [
33 | 'integer',
34 | ],
35 | 'questions' => [
36 | 'array',
37 | ],
38 | ];
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/Http/Requests/UpdateRoleRequest.php:
--------------------------------------------------------------------------------
1 | [
23 | 'required',
24 | ],
25 | 'permissions.*' => [
26 | 'integer',
27 | ],
28 | 'permissions' => [
29 | 'required',
30 | 'array',
31 | ],
32 | ];
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/Http/Requests/UpdateUserRequest.php:
--------------------------------------------------------------------------------
1 | [
23 | 'required',
24 | ],
25 | 'email' => [
26 | 'required',
27 | 'unique:users,email,' . request()->route('user')->id,
28 | ],
29 | 'roles.*' => [
30 | 'integer',
31 | ],
32 | 'roles' => [
33 | 'required',
34 | 'array',
35 | ],
36 | ];
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/app/Http/Resources/Admin/CategoryResource.php:
--------------------------------------------------------------------------------
1 | result = $result;
22 | }
23 |
24 | /**
25 | * Get the notification's delivery channels.
26 | *
27 | * @param mixed $notifiable
28 | * @return array
29 | */
30 | public function via($notifiable)
31 | {
32 | return ['mail'];
33 | }
34 |
35 | /**
36 | * Get the mail representation of the notification.
37 | *
38 | * @param mixed $notifiable
39 | * @return \Illuminate\Notifications\Messages\MailMessage
40 | */
41 | public function toMail($notifiable)
42 | {
43 | return (new MailMessage)
44 | ->subject('Your Test Results')
45 | ->line('Your test results are attached to this message')
46 | ->action('Start test again', route('client.test'))
47 | ->attach(storage_path($this->result->id.'.pdf'),[
48 | 'as' => $this->result->id.'.pdf',
49 | 'mime' => 'application/pdf',
50 | ]);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/app/Option.php:
--------------------------------------------------------------------------------
1 | belongsTo(Question::class, 'question_id');
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/Permission.php:
--------------------------------------------------------------------------------
1 | belongsToMany(Role::class);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/Providers/AppServiceProvider.php:
--------------------------------------------------------------------------------
1 | 'App\Policies\ModelPolicy',
18 | ];
19 |
20 | /**
21 | * Register any authentication / authorization services.
22 | *
23 | * @return void
24 | */
25 | public function boot()
26 | {
27 | $this->registerPolicies();
28 |
29 | if (!app()->runningInConsole()) {
30 | Passport::routes();
31 | };
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/Providers/BroadcastServiceProvider.php:
--------------------------------------------------------------------------------
1 | [
19 | SendEmailVerificationNotification::class,
20 | ],
21 | ];
22 |
23 | /**
24 | * Register any events for your application.
25 | *
26 | * @return void
27 | */
28 | public function boot()
29 | {
30 | parent::boot();
31 |
32 | //
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/Providers/RouteServiceProvider.php:
--------------------------------------------------------------------------------
1 | mapApiRoutes();
39 |
40 | $this->mapWebRoutes();
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 | * @return void
51 | */
52 | protected function mapWebRoutes()
53 | {
54 | Route::middleware('web')
55 | ->namespace($this->namespace)
56 | ->group(base_path('routes/web.php'));
57 | }
58 |
59 | /**
60 | * Define the "api" routes for the application.
61 | *
62 | * These routes are typically stateless.
63 | *
64 | * @return void
65 | */
66 | protected function mapApiRoutes()
67 | {
68 | Route::prefix('api')
69 | ->middleware('api')
70 | ->namespace($this->namespace)
71 | ->group(base_path('routes/api.php'));
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/app/Question.php:
--------------------------------------------------------------------------------
1 | hasMany(Option::class, 'question_id', 'id');
31 | }
32 |
33 | public function questionsResults()
34 | {
35 | return $this->belongsToMany(Result::class);
36 | }
37 |
38 | public function category()
39 | {
40 | return $this->belongsTo(Category::class, 'category_id');
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/Result.php:
--------------------------------------------------------------------------------
1 | belongsTo(User::class, 'user_id');
31 | }
32 |
33 | public function questions()
34 | {
35 | return $this->belongsToMany(Question::class)->withPivot(['option_id', 'points']);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/Role.php:
--------------------------------------------------------------------------------
1 | belongsToMany(User::class);
30 | }
31 |
32 | public function permissions()
33 | {
34 | return $this->belongsToMany(Permission::class);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/User.php:
--------------------------------------------------------------------------------
1 | roles()->where('id', 1)->exists();
48 | }
49 |
50 | public function __construct(array $attributes = [])
51 | {
52 | parent::__construct($attributes);
53 | self::created(function (User $user) {
54 | $registrationRole = config('panel.registration_default_role');
55 |
56 | if (!$user->roles()->get()->contains($registrationRole)) {
57 | $user->roles()->attach($registrationRole);
58 | }
59 | });
60 | }
61 |
62 | public function userResults()
63 | {
64 | return $this->hasMany(Result::class, 'user_id', 'id');
65 | }
66 |
67 | public function getEmailVerifiedAtAttribute($value)
68 | {
69 | return $value ? Carbon::createFromFormat('Y-m-d H:i:s', $value)->format(config('panel.date_format') . ' ' . config('panel.time_format')) : null;
70 | }
71 |
72 | public function setEmailVerifiedAtAttribute($value)
73 | {
74 | $this->attributes['email_verified_at'] = $value ? Carbon::createFromFormat(config('panel.date_format') . ' ' . config('panel.time_format'), $value)->format('Y-m-d H:i:s') : null;
75 | }
76 |
77 | public function setPasswordAttribute($input)
78 | {
79 | if ($input) {
80 | $this->attributes['password'] = app('hash')->needsRehash($input) ? Hash::make($input) : $input;
81 | }
82 | }
83 |
84 | public function sendPasswordResetNotification($token)
85 | {
86 | $this->notify(new ResetPassword($token));
87 | }
88 |
89 | public function roles()
90 | {
91 | return $this->belongsToMany(Role::class);
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/artisan:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env php
2 | make(Illuminate\Contracts\Console\Kernel::class);
34 |
35 | $status = $kernel->handle(
36 | $input = new Symfony\Component\Console\Input\ArgvInput,
37 | new Symfony\Component\Console\Output\ConsoleOutput
38 | );
39 |
40 | /*
41 | |--------------------------------------------------------------------------
42 | | Shutdown The Application
43 | |--------------------------------------------------------------------------
44 | |
45 | | Once Artisan has finished running, we will fire off the shutdown events
46 | | so that any final work may be done by the application before we shut
47 | | down the process. This is the last thing to happen to the request.
48 | |
49 | */
50 |
51 | $kernel->terminate($input, $status);
52 |
53 | exit($status);
54 |
--------------------------------------------------------------------------------
/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/cache/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "laravel/laravel",
3 | "type": "project",
4 | "description": "The Laravel Framework.",
5 | "keywords": [
6 | "framework",
7 | "laravel"
8 | ],
9 | "license": "MIT",
10 | "require": {
11 | "php": "^7.2",
12 | "barryvdh/laravel-dompdf": "^0.8.5",
13 | "bugsnag/bugsnag-laravel": "^2.17",
14 | "doctrine/dbal": "^2.9",
15 | "fideloper/proxy": "^4.0",
16 | "laravel/framework": "^6.2",
17 | "laravel/passport": "^7.4",
18 | "laravel/tinker": "^1.0",
19 | "yajra/laravel-datatables-oracle": "^9.7"
20 | },
21 | "require-dev": {
22 | "facade/ignition": "^1.4",
23 | "fzaninotto/faker": "^1.4",
24 | "mockery/mockery": "^1.0",
25 | "nunomaduro/collision": "^3.0",
26 | "phpunit/phpunit": "^8.0"
27 | },
28 | "config": {
29 | "optimize-autoloader": true,
30 | "preferred-install": "dist",
31 | "sort-packages": true
32 | },
33 | "extra": {
34 | "laravel": {
35 | "dont-discover": []
36 | }
37 | },
38 | "autoload": {
39 | "psr-4": {
40 | "App\\": "app/"
41 | },
42 | "classmap": [
43 | "database/seeds",
44 | "database/factories"
45 | ]
46 | },
47 | "autoload-dev": {
48 | "psr-4": {
49 | "Tests\\": "tests/"
50 | }
51 | },
52 | "minimum-stability": "dev",
53 | "prefer-stable": true,
54 | "scripts": {
55 | "post-autoload-dump": [
56 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
57 | "@php artisan package:discover --ansi"
58 | ],
59 | "post-root-package-install": [
60 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
61 | ],
62 | "post-create-project-cmd": [
63 | "@php artisan key:generate --ansi"
64 | ]
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/config/broadcasting.php:
--------------------------------------------------------------------------------
1 | env('BROADCAST_DRIVER', 'null'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Broadcast Connections
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may define all of the broadcast connections that will be used
26 | | to broadcast events to other systems or over websockets. Samples of
27 | | each available type of connection are provided inside this array.
28 | |
29 | */
30 |
31 | 'connections' => [
32 |
33 | 'pusher' => [
34 | 'driver' => 'pusher',
35 | 'key' => env('PUSHER_APP_KEY'),
36 | 'secret' => env('PUSHER_APP_SECRET'),
37 | 'app_id' => env('PUSHER_APP_ID'),
38 | 'options' => [
39 | 'cluster' => env('PUSHER_APP_CLUSTER'),
40 | 'useTLS' => true,
41 | ],
42 | ],
43 |
44 | 'redis' => [
45 | 'driver' => 'redis',
46 | 'connection' => 'default',
47 | ],
48 |
49 | 'log' => [
50 | 'driver' => 'log',
51 | ],
52 |
53 | 'null' => [
54 | 'driver' => 'null',
55 | ],
56 |
57 | ],
58 |
59 | ];
60 |
--------------------------------------------------------------------------------
/config/filesystems.php:
--------------------------------------------------------------------------------
1 | env('FILESYSTEM_DRIVER', 'local'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Default Cloud Filesystem Disk
21 | |--------------------------------------------------------------------------
22 | |
23 | | Many applications store files both locally and in the cloud. For this
24 | | reason, you may specify a default "cloud" driver here. This driver
25 | | will be bound as the Cloud disk implementation in the container.
26 | |
27 | */
28 |
29 | 'cloud' => env('FILESYSTEM_CLOUD', 's3'),
30 |
31 | /*
32 | |--------------------------------------------------------------------------
33 | | Filesystem Disks
34 | |--------------------------------------------------------------------------
35 | |
36 | | Here you may configure as many filesystem "disks" as you wish, and you
37 | | may even configure multiple disks of the same driver. Defaults have
38 | | been setup for each driver as an example of the required options.
39 | |
40 | | Supported Drivers: "local", "ftp", "sftp", "s3"
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 | 'url' => env('APP_URL').'/storage',
55 | 'visibility' => 'public',
56 | ],
57 |
58 | 's3' => [
59 | 'driver' => 's3',
60 | 'key' => env('AWS_ACCESS_KEY_ID'),
61 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
62 | 'region' => env('AWS_DEFAULT_REGION'),
63 | 'bucket' => env('AWS_BUCKET'),
64 | 'url' => env('AWS_URL'),
65 | ],
66 |
67 | ],
68 |
69 | ];
70 |
--------------------------------------------------------------------------------
/config/hashing.php:
--------------------------------------------------------------------------------
1 | 'bcrypt',
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Bcrypt Options
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may specify the configuration options that should be used when
26 | | passwords are hashed using the Bcrypt algorithm. This will allow you
27 | | to control the amount of time it takes to hash the given password.
28 | |
29 | */
30 |
31 | 'bcrypt' => [
32 | 'rounds' => env('BCRYPT_ROUNDS', 10),
33 | ],
34 |
35 | /*
36 | |--------------------------------------------------------------------------
37 | | Argon Options
38 | |--------------------------------------------------------------------------
39 | |
40 | | Here you may specify the configuration options that should be used when
41 | | passwords are hashed using the Argon algorithm. These will allow you
42 | | to control the amount of time it takes to hash the given password.
43 | |
44 | */
45 |
46 | 'argon' => [
47 | 'memory' => 1024,
48 | 'threads' => 2,
49 | 'time' => 2,
50 | ],
51 |
52 | ];
53 |
--------------------------------------------------------------------------------
/config/panel.php:
--------------------------------------------------------------------------------
1 | 'Y-m-d',
5 | 'time_format' => 'H:i:s',
6 | 'primary_language' => 'en',
7 | 'available_languages' => [
8 | 'en' => 'English',
9 | ],
10 | 'registration_default_role' => '2',
11 | ];
12 |
--------------------------------------------------------------------------------
/config/queue.php:
--------------------------------------------------------------------------------
1 | env('QUEUE_CONNECTION', 'sync'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Queue Connections
21 | |--------------------------------------------------------------------------
22 | |
23 | | Here you may configure the connection information for each server that
24 | | is used by your application. A default configuration has been added
25 | | for each back-end shipped with Laravel. You are free to add more.
26 | |
27 | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
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 | 'retry_after' => 90,
42 | ],
43 |
44 | 'beanstalkd' => [
45 | 'driver' => 'beanstalkd',
46 | 'host' => 'localhost',
47 | 'queue' => 'default',
48 | 'retry_after' => 90,
49 | 'block_for' => 0,
50 | ],
51 |
52 | 'sqs' => [
53 | 'driver' => 'sqs',
54 | 'key' => env('AWS_ACCESS_KEY_ID'),
55 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
56 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
57 | 'queue' => env('SQS_QUEUE', 'your-queue-name'),
58 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
59 | ],
60 |
61 | 'redis' => [
62 | 'driver' => 'redis',
63 | 'connection' => 'default',
64 | 'queue' => env('REDIS_QUEUE', 'default'),
65 | 'retry_after' => 90,
66 | 'block_for' => null,
67 | ],
68 |
69 | ],
70 |
71 | /*
72 | |--------------------------------------------------------------------------
73 | | Failed Queue Jobs
74 | |--------------------------------------------------------------------------
75 | |
76 | | These options configure the behavior of failed queue job logging so you
77 | | can control which database and table are used to store the jobs that
78 | | have failed. You may change them to any database / table you wish.
79 | |
80 | */
81 |
82 | 'failed' => [
83 | 'driver' => env('QUEUE_FAILED_DRIVER', 'database'),
84 | 'database' => env('DB_CONNECTION', 'mysql'),
85 | 'table' => 'failed_jobs',
86 | ],
87 |
88 | ];
89 |
--------------------------------------------------------------------------------
/config/services.php:
--------------------------------------------------------------------------------
1 | [
18 | 'domain' => env('MAILGUN_DOMAIN'),
19 | 'secret' => env('MAILGUN_SECRET'),
20 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
21 | ],
22 |
23 | 'postmark' => [
24 | 'token' => env('POSTMARK_TOKEN'),
25 | ],
26 |
27 | 'ses' => [
28 | 'key' => env('AWS_ACCESS_KEY_ID'),
29 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
30 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
31 | ],
32 |
33 | ];
34 |
--------------------------------------------------------------------------------
/config/view.php:
--------------------------------------------------------------------------------
1 | [
17 | resource_path('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' => env(
32 | 'VIEW_COMPILED_PATH',
33 | realpath(storage_path('framework/views'))
34 | ),
35 |
36 | ];
37 |
--------------------------------------------------------------------------------
/database/.gitignore:
--------------------------------------------------------------------------------
1 | *.sqlite
2 | *.sqlite-journal
3 |
--------------------------------------------------------------------------------
/database/factories/UserFactory.php:
--------------------------------------------------------------------------------
1 | define(User::class, function (Faker $faker) {
20 | return [
21 | 'name' => $faker->name,
22 | 'email' => $faker->unique()->safeEmail,
23 | 'email_verified_at' => now(),
24 | 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
25 | 'remember_token' => Str::random(10),
26 | ];
27 | });
28 |
--------------------------------------------------------------------------------
/database/migrations/2014_10_12_100000_create_password_resets_table.php:
--------------------------------------------------------------------------------
1 | string('email')->index();
18 | $table->string('token');
19 | $table->timestamp('created_at')->nullable();
20 | });
21 | }
22 |
23 | /**
24 | * Reverse the migrations.
25 | *
26 | * @return void
27 | */
28 | public function down()
29 | {
30 | Schema::dropIfExists('password_resets');
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/database/migrations/2019_12_23_000001_create_permissions_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
13 |
14 | $table->string('title')->nullable();
15 |
16 | $table->timestamps();
17 |
18 | $table->softDeletes();
19 | });
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/database/migrations/2019_12_23_000002_create_roles_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
13 |
14 | $table->string('title')->nullable();
15 |
16 | $table->timestamps();
17 |
18 | $table->softDeletes();
19 | });
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/database/migrations/2019_12_23_000003_create_users_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
13 |
14 | $table->string('name');
15 |
16 | $table->string('email')->unique();
17 |
18 | $table->datetime('email_verified_at')->nullable();
19 |
20 | $table->string('password');
21 |
22 | $table->string('remember_token')->nullable();
23 |
24 | $table->timestamps();
25 |
26 | $table->softDeletes();
27 | });
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/database/migrations/2019_12_23_000004_create_categories_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
13 |
14 | $table->string('name');
15 |
16 | $table->timestamps();
17 |
18 | $table->softDeletes();
19 | });
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/database/migrations/2019_12_23_000005_create_questions_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
13 |
14 | $table->longText('question_text');
15 |
16 | $table->timestamps();
17 |
18 | $table->softDeletes();
19 | });
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/database/migrations/2019_12_23_000006_create_options_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
13 |
14 | $table->longText('option_text');
15 |
16 | $table->integer('points')->nullable();
17 |
18 | $table->timestamps();
19 |
20 | $table->softDeletes();
21 | });
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/database/migrations/2019_12_23_000007_create_results_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
13 |
14 | $table->integer('total_points')->nullable();
15 |
16 | $table->timestamps();
17 |
18 | $table->softDeletes();
19 | });
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/database/migrations/2019_12_23_000008_create_permission_role_pivot_table.php:
--------------------------------------------------------------------------------
1 | unsignedInteger('role_id');
13 |
14 | $table->foreign('role_id', 'role_id_fk_773672')->references('id')->on('roles')->onDelete('cascade');
15 |
16 | $table->unsignedInteger('permission_id');
17 |
18 | $table->foreign('permission_id', 'permission_id_fk_773672')->references('id')->on('permissions')->onDelete('cascade');
19 | });
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/database/migrations/2019_12_23_000009_create_role_user_pivot_table.php:
--------------------------------------------------------------------------------
1 | unsignedInteger('user_id');
13 |
14 | $table->foreign('user_id', 'user_id_fk_773681')->references('id')->on('users')->onDelete('cascade');
15 |
16 | $table->unsignedInteger('role_id');
17 |
18 | $table->foreign('role_id', 'role_id_fk_773681')->references('id')->on('roles')->onDelete('cascade');
19 | });
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/database/migrations/2019_12_23_000010_create_question_result_pivot_table.php:
--------------------------------------------------------------------------------
1 | unsignedInteger('result_id');
13 |
14 | $table->foreign('result_id', 'result_id_fk_773767')->references('id')->on('results')->onDelete('cascade');
15 |
16 | $table->unsignedInteger('question_id');
17 |
18 | $table->foreign('question_id', 'question_id_fk_773767')->references('id')->on('questions')->onDelete('cascade');
19 |
20 | $table->unsignedInteger('option_id');
21 |
22 | $table->foreign('option_id', 'option_id_fk_773767')->references('id')->on('options')->onDelete('cascade');
23 |
24 | $table->integer('points')->default(0);
25 | });
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/database/migrations/2019_12_23_000011_add_relationship_fields_to_questions_table.php:
--------------------------------------------------------------------------------
1 | unsignedInteger('category_id');
13 |
14 | $table->foreign('category_id', 'category_fk_773713')->references('id')->on('categories');
15 | });
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/database/migrations/2019_12_23_000012_add_relationship_fields_to_options_table.php:
--------------------------------------------------------------------------------
1 | unsignedInteger('question_id');
13 |
14 | $table->foreign('question_id', 'question_fk_773758')->references('id')->on('questions');
15 | });
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/database/migrations/2019_12_23_000013_add_relationship_fields_to_results_table.php:
--------------------------------------------------------------------------------
1 | unsignedInteger('user_id');
13 |
14 | $table->foreign('user_id', 'user_fk_773765')->references('id')->on('users');
15 | });
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/database/seeds/CategoriesTableSeeder.php:
--------------------------------------------------------------------------------
1 | $id,
21 | 'name' => $faker->sentence(3)
22 | ]);
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/database/seeds/DatabaseSeeder.php:
--------------------------------------------------------------------------------
1 | call([
10 | PermissionsTableSeeder::class,
11 | RolesTableSeeder::class,
12 | PermissionRoleTableSeeder::class,
13 | UsersTableSeeder::class,
14 | RoleUserTableSeeder::class,
15 | CategoriesTableSeeder::class,
16 | QuestionsTableSeeder::class,
17 | OptionsTableSeeder::class,
18 | ]);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/database/seeds/OptionsTableSeeder.php:
--------------------------------------------------------------------------------
1 | questionOptions()->create([
25 | 'option_text' => $faker->unique()->word,
26 | 'points' => $index == $correctOption ? 1 : 0,
27 | ]);
28 | }
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/database/seeds/PermissionRoleTableSeeder.php:
--------------------------------------------------------------------------------
1 | permissions()->sync($admin_permissions->pluck('id'));
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/database/seeds/QuestionsTableSeeder.php:
--------------------------------------------------------------------------------
1 | categoryQuestions()->create([
23 | 'question_text' => $faker->sentence(4)
24 | ]);
25 | }
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/database/seeds/RoleUserTableSeeder.php:
--------------------------------------------------------------------------------
1 | roles()->sync(1);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/database/seeds/RolesTableSeeder.php:
--------------------------------------------------------------------------------
1 | 1,
13 | 'title' => 'Admin',
14 | ],
15 | [
16 | 'id' => 2,
17 | 'title' => 'User',
18 | ],
19 | ];
20 |
21 | Role::insert($roles);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/database/seeds/UsersTableSeeder.php:
--------------------------------------------------------------------------------
1 | 1,
13 | 'name' => 'Admin',
14 | 'email' => 'admin@admin.com',
15 | 'password' => '$2y$10$wNIDxA5tfzPm6XEsjrt0IOS9dbUrhjZSigPvzruq2Rz0BEqudStyK',
16 | 'remember_token' => null,
17 | ],
18 | ];
19 |
20 | User::insert($users);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "scripts": {
4 | "dev": "npm run development",
5 | "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
6 | "watch": "npm run development -- --watch",
7 | "watch-poll": "npm run watch -- --watch-poll",
8 | "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
9 | "prod": "npm run production",
10 | "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
11 | },
12 | "devDependencies": {
13 | "axios": "^0.19",
14 | "bootstrap": "^4.0.0",
15 | "cross-env": "^5.1",
16 | "jquery": "^3.2",
17 | "laravel-mix": "^4.0.7",
18 | "lodash": "^4.17.13",
19 | "popper.js": "^1.12",
20 | "resolve-url-loader": "^2.3.1",
21 | "sass": "^1.20.1",
22 | "sass-loader": "7.*",
23 | "vue": "^2.5.17",
24 | "vue-template-compiler": "^2.6.10"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
15 | ./tests/Unit
16 |
17 |
18 |
19 | ./tests/Feature
20 |
21 |
22 |
23 |
24 | ./app
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/public/.htaccess:
--------------------------------------------------------------------------------
1 |
2 |
3 | Options -MultiViews -Indexes
4 |
5 |
6 | RewriteEngine On
7 |
8 | # Handle Authorization Header
9 | RewriteCond %{HTTP:Authorization} .
10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
11 |
12 | # Redirect Trailing Slashes If Not A Folder...
13 | RewriteCond %{REQUEST_FILENAME} !-d
14 | RewriteCond %{REQUEST_URI} (.+)/$
15 | RewriteRule ^ %1 [L,R=301]
16 |
17 | # Handle Front Controller...
18 | RewriteCond %{REQUEST_FILENAME} !-d
19 | RewriteCond %{REQUEST_FILENAME} !-f
20 | RewriteRule ^ index.php [L]
21 |
22 |
--------------------------------------------------------------------------------
/public/css/custom.css:
--------------------------------------------------------------------------------
1 | .ck-editor__editable,
2 | textarea {
3 | min-height: 150px;
4 | }
5 |
6 | .datatable {
7 | width: 100% !important;
8 | }
9 |
10 | .dataTables_length,
11 | .dataTables_filter,
12 | .dt-buttons {
13 | margin-bottom: 0.333em;
14 | margin-top: .2rem;
15 | }
16 |
17 | .dataTables_filter {
18 | margin-right: .2rem;
19 | }
20 |
21 | .dt-buttons .btn {
22 | margin-left: 0.333em;
23 | border-radius: 0;
24 | }
25 |
26 | .table.datatable {
27 | box-sizing: border-box;
28 | border-collapse: collapse;
29 | }
30 |
31 | table.dataTable thead th {
32 | border-bottom: 2px solid #c8ced3;
33 | }
34 |
35 | .dataTables_wrapper.no-footer .dataTables_scrollBody {
36 | border-bottom: 1px solid #c8ced3;
37 | }
38 |
39 | .select2 {
40 | max-width: 100%;
41 | width: 100% !important;
42 | }
43 |
44 | .select2-selection__rendered {
45 | padding-bottom: 5px !important;
46 | }
47 |
48 | .has-error .invalid-feedback {
49 | display: block !important;
50 | }
51 |
52 | .btn-info,
53 | .badge-info {
54 | color: white;
55 | }
56 |
57 | table.dataTable thead .sorting,
58 | table.dataTable thead .sorting_asc,
59 | table.dataTable thead .sorting_desc {
60 | background-image: none;
61 | }
62 |
63 | .sidebar .nav-item {
64 | cursor: pointer;
65 | }
66 |
67 | .btn-default {
68 | color: #23282c;
69 | background-color: #f0f3f5;
70 | border-color: #f0f3f5;
71 | }
72 |
73 | .btn-default.focus,
74 | .btn-default:focus {
75 | box-shadow: 0 0 0 .2rem rgba(209, 213, 215, .5);
76 | }
77 |
78 | .btn-default:hover {
79 | color: #23282c;
80 | background-color: #d9e1e6;
81 | border-color: #d1dbe1;
82 | }
83 |
84 | .btn-group-xs > .btn,
85 | .btn-xs {
86 | padding: 1px 5px;
87 | font-size: 12px;
88 | line-height: 1.5;
89 | border-radius: 3px;
90 | }
91 |
92 | .searchable-title {
93 | font-weight: bold;
94 | }
95 | .searchable-fields {
96 | padding-left:5px;
97 | }
98 | .searchable-link {
99 | padding:0 5px 0 5px;
100 | }
101 | .searchable-link:hover {
102 | cursor: pointer;
103 | background: #eaeaea;
104 | }
105 | .select2-results__option {
106 | padding-left: 0px;
107 | padding-right: 0px;
108 | }
109 |
110 | .form-group .required::after {
111 | content: " *";
112 | color: red;
113 | }
114 |
115 | .form-check.is-invalid ~ .invalid-feedback {
116 | display: block;
117 | }
118 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LaravelDaily/Laravel-Test-Result-PDF/3d4107abad40123c5ff09ff228b11dd7be37ee2d/public/favicon.ico
--------------------------------------------------------------------------------
/public/index.php:
--------------------------------------------------------------------------------
1 |
8 | */
9 |
10 | define('LARAVEL_START', microtime(true));
11 |
12 | /*
13 | |--------------------------------------------------------------------------
14 | | Register The Auto Loader
15 | |--------------------------------------------------------------------------
16 | |
17 | | Composer provides a convenient, automatically generated class loader for
18 | | our application. We just need to utilize it! We'll simply require it
19 | | into the script here so that we don't have to worry about manual
20 | | loading any of our classes later on. It feels great to relax.
21 | |
22 | */
23 |
24 | require __DIR__.'/../vendor/autoload.php';
25 |
26 | /*
27 | |--------------------------------------------------------------------------
28 | | Turn On The Lights
29 | |--------------------------------------------------------------------------
30 | |
31 | | We need to illuminate PHP development, so let us turn on the lights.
32 | | This bootstraps the framework and gets it ready for use, then it
33 | | will load up this application so that we can run it and send
34 | | the responses back to the browser and delight our users.
35 | |
36 | */
37 |
38 | $app = require_once __DIR__.'/../bootstrap/app.php';
39 |
40 | /*
41 | |--------------------------------------------------------------------------
42 | | Run The Application
43 | |--------------------------------------------------------------------------
44 | |
45 | | Once we have the application, we can handle the incoming request
46 | | through the kernel, and send the associated response back to
47 | | the client's browser allowing them to enjoy the creative
48 | | and wonderful application we have prepared for them.
49 | |
50 | */
51 |
52 | $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
53 |
54 | $response = $kernel->handle(
55 | $request = Illuminate\Http\Request::capture()
56 | );
57 |
58 | $response->send();
59 |
60 | $kernel->terminate($request, $response);
61 |
--------------------------------------------------------------------------------
/public/js/main.js:
--------------------------------------------------------------------------------
1 | $(document).ready(function () {
2 | window._token = $('meta[name="csrf-token"]').attr('content')
3 |
4 | var allEditors = document.querySelectorAll('.ckeditor');
5 | for (var i = 0; i < allEditors.length; ++i) {
6 | ClassicEditor.create(
7 | allEditors[i],
8 | {
9 | removePlugins: ['ImageUpload']
10 | }
11 | );
12 | }
13 |
14 | moment.updateLocale('en', {
15 | week: {dow: 1} // Monday is the first day of the week
16 | })
17 |
18 | $('.date').datetimepicker({
19 | format: 'YYYY-MM-DD',
20 | locale: 'en',
21 | icons: {
22 | up: 'fas fa-chevron-up',
23 | down: 'fas fa-chevron-down',
24 | previous: 'fas fa-chevron-left',
25 | next: 'fas fa-chevron-right'
26 | }
27 | })
28 |
29 | $('.datetime').datetimepicker({
30 | format: 'YYYY-MM-DD HH:mm:ss',
31 | locale: 'en',
32 | sideBySide: true,
33 | icons: {
34 | up: 'fas fa-chevron-up',
35 | down: 'fas fa-chevron-down',
36 | previous: 'fas fa-chevron-left',
37 | next: 'fas fa-chevron-right'
38 | }
39 | })
40 |
41 | $('.timepicker').datetimepicker({
42 | format: 'HH:mm:ss',
43 | icons: {
44 | up: 'fas fa-chevron-up',
45 | down: 'fas fa-chevron-down',
46 | previous: 'fas fa-chevron-left',
47 | next: 'fas fa-chevron-right'
48 | }
49 | })
50 |
51 | $('.select-all').click(function () {
52 | let $select2 = $(this).parent().siblings('.select2')
53 | $select2.find('option').prop('selected', 'selected')
54 | $select2.trigger('change')
55 | })
56 | $('.deselect-all').click(function () {
57 | let $select2 = $(this).parent().siblings('.select2')
58 | $select2.find('option').prop('selected', '')
59 | $select2.trigger('change')
60 | })
61 |
62 | $('.select2').select2()
63 |
64 | $('.treeview').each(function () {
65 | var shouldExpand = false
66 | $(this).find('li').each(function () {
67 | if ($(this).hasClass('active')) {
68 | shouldExpand = true
69 | }
70 | })
71 | if (shouldExpand) {
72 | $(this).addClass('active')
73 | }
74 | })
75 | })
76 |
--------------------------------------------------------------------------------
/public/mix-manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "/js/app.js": "/js/app.js",
3 | "/css/app.css": "/css/app.css"
4 | }
5 |
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Disallow:
3 |
--------------------------------------------------------------------------------
/resources/js/app.js:
--------------------------------------------------------------------------------
1 | /**
2 | * First we will load all of this project's JavaScript dependencies which
3 | * includes Vue and other libraries. It is a great starting point when
4 | * building robust, powerful web applications using Vue and Laravel.
5 | */
6 |
7 | require('./bootstrap');
8 |
9 | window.Vue = require('vue');
10 |
11 | /**
12 | * The following block of code may be used to automatically register your
13 | * Vue components. It will recursively scan this directory for the Vue
14 | * components and automatically register them with their "basename".
15 | *
16 | * Eg. ./components/ExampleComponent.vue ->
17 | */
18 |
19 | // const files = require.context('./', true, /\.vue$/i)
20 | // files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default))
21 |
22 | Vue.component('example-component', require('./components/ExampleComponent.vue').default);
23 |
24 | /**
25 | * Next, we will create a fresh Vue application instance and attach it to
26 | * the page. Then, you may begin adding components to this application
27 | * or customize the JavaScript scaffolding to fit your unique needs.
28 | */
29 |
30 | const app = new Vue({
31 | el: '#app',
32 | });
33 |
--------------------------------------------------------------------------------
/resources/js/bootstrap.js:
--------------------------------------------------------------------------------
1 | window._ = require('lodash');
2 |
3 | /**
4 | * We'll load jQuery and the Bootstrap jQuery plugin which provides support
5 | * for JavaScript based Bootstrap features such as modals and tabs. This
6 | * code may be modified to fit the specific needs of your application.
7 | */
8 |
9 | try {
10 | window.Popper = require('popper.js').default;
11 | window.$ = window.jQuery = require('jquery');
12 |
13 | require('bootstrap');
14 | } catch (e) {}
15 |
16 | /**
17 | * We'll load the axios HTTP library which allows us to easily issue requests
18 | * to our Laravel back-end. This library automatically handles sending the
19 | * CSRF token as a header based on the value of the "XSRF" token cookie.
20 | */
21 |
22 | window.axios = require('axios');
23 |
24 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
25 |
26 | /**
27 | * Echo exposes an expressive API for subscribing to channels and listening
28 | * for events that are broadcast by Laravel. Echo and event broadcasting
29 | * allows your team to easily build robust real-time web applications.
30 | */
31 |
32 | // import Echo from 'laravel-echo';
33 |
34 | // window.Pusher = require('pusher-js');
35 |
36 | // window.Echo = new Echo({
37 | // broadcaster: 'pusher',
38 | // key: process.env.MIX_PUSHER_APP_KEY,
39 | // cluster: process.env.MIX_PUSHER_APP_CLUSTER,
40 | // encrypted: true
41 | // });
42 |
--------------------------------------------------------------------------------
/resources/js/components/ExampleComponent.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | I'm an example component.
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
24 |
--------------------------------------------------------------------------------
/resources/lang/en/auth.php:
--------------------------------------------------------------------------------
1 | 'These credentials do not match our records.',
5 | 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
6 | ];
7 |
--------------------------------------------------------------------------------
/resources/lang/en/pagination.php:
--------------------------------------------------------------------------------
1 | '« Previous',
5 | 'next' => 'Next »',
6 | ];
7 |
--------------------------------------------------------------------------------
/resources/lang/en/panel.php:
--------------------------------------------------------------------------------
1 | 'Test',
5 | ];
6 |
--------------------------------------------------------------------------------
/resources/lang/en/passwords.php:
--------------------------------------------------------------------------------
1 | 'Passwords must be at least six characters and match the confirmation.',
5 | 'reset' => 'Your password has been reset!',
6 | 'sent' => 'We have e-mailed your password reset link!',
7 | 'token' => 'This password reset token is invalid.',
8 | 'user' => 'We can\'t find a user with that e-mail address.',
9 | 'updated' => 'Your password has been changed!',
10 | ];
11 |
--------------------------------------------------------------------------------
/resources/sass/_variables.scss:
--------------------------------------------------------------------------------
1 | // Body
2 | $body-bg: #f8fafc;
3 |
4 | // Typography
5 | $font-family-sans-serif: 'Nunito', sans-serif;
6 | $font-size-base: 0.9rem;
7 | $line-height-base: 1.6;
8 |
9 | // Colors
10 | $blue: #3490dc;
11 | $indigo: #6574cd;
12 | $purple: #9561e2;
13 | $pink: #f66d9b;
14 | $red: #e3342f;
15 | $orange: #f6993f;
16 | $yellow: #ffed4a;
17 | $green: #38c172;
18 | $teal: #4dc0b5;
19 | $cyan: #6cb2eb;
20 |
--------------------------------------------------------------------------------
/resources/sass/app.scss:
--------------------------------------------------------------------------------
1 | // Fonts
2 | @import url('https://fonts.googleapis.com/css?family=Nunito');
3 |
4 | // Variables
5 | @import 'variables';
6 |
7 | // Bootstrap
8 | @import '~bootstrap/scss/bootstrap';
9 |
--------------------------------------------------------------------------------
/resources/views/admin/categories/create.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.admin')
2 | @section('content')
3 |
4 |
30 |
31 |
32 |
33 | @endsection
--------------------------------------------------------------------------------
/resources/views/admin/categories/edit.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.admin')
2 | @section('content')
3 |
4 |
31 |
32 |
33 |
34 | @endsection
--------------------------------------------------------------------------------
/resources/views/admin/categories/show.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.admin')
2 | @section('content')
3 |
4 |
44 |
45 |
46 |
47 | @endsection
--------------------------------------------------------------------------------
/resources/views/admin/options/create.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.admin')
2 | @section('content')
3 |
4 |
54 |
55 |
56 |
57 | @endsection
--------------------------------------------------------------------------------
/resources/views/admin/options/edit.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.admin')
2 | @section('content')
3 |
4 |
5 |
8 |
9 |
10 |
id]) }}" enctype="multipart/form-data">
11 | @method('PUT')
12 | @csrf
13 |
27 |
37 |
47 |
48 |
49 | {{ trans('global.save') }}
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | @endsection
--------------------------------------------------------------------------------
/resources/views/admin/options/show.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.admin')
2 | @section('content')
3 |
4 |
60 |
61 |
62 |
63 | @endsection
--------------------------------------------------------------------------------
/resources/views/admin/permissions/create.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.admin')
2 | @section('content')
3 |
4 |
5 |
8 |
9 |
10 |
11 | @csrf
12 |
22 |
23 |
24 | {{ trans('global.save') }}
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 | @endsection
--------------------------------------------------------------------------------
/resources/views/admin/permissions/edit.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.admin')
2 | @section('content')
3 |
4 |
5 |
8 |
9 |
10 |
id]) }}" enctype="multipart/form-data">
11 | @method('PUT')
12 | @csrf
13 |
23 |
24 |
25 | {{ trans('global.save') }}
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | @endsection
--------------------------------------------------------------------------------
/resources/views/admin/permissions/show.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.admin')
2 | @section('content')
3 |
4 |
44 |
45 |
46 |
47 | @endsection
--------------------------------------------------------------------------------
/resources/views/admin/questions/create.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.admin')
2 | @section('content')
3 |
4 |
5 |
8 |
9 |
10 |
11 | @csrf
12 |
26 |
36 |
37 |
38 | {{ trans('global.save') }}
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | @endsection
--------------------------------------------------------------------------------
/resources/views/admin/questions/edit.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.admin')
2 | @section('content')
3 |
4 |
5 |
8 |
9 |
10 |
id]) }}" enctype="multipart/form-data">
11 | @method('PUT')
12 | @csrf
13 |
27 |
37 |
38 |
39 | {{ trans('global.save') }}
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | @endsection
--------------------------------------------------------------------------------
/resources/views/admin/questions/show.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.admin')
2 | @section('content')
3 |
4 |
52 |
53 |
54 |
55 | @endsection
--------------------------------------------------------------------------------
/resources/views/admin/results/show.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.admin')
2 | @section('content')
3 |
4 |
62 |
63 |
64 |
65 | @endsection
--------------------------------------------------------------------------------
/resources/views/admin/roles/create.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.admin')
2 | @section('content')
3 |
4 |
5 |
8 |
9 |
10 |
11 | @csrf
12 |
22 |
40 |
41 |
42 | {{ trans('global.save') }}
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | @endsection
--------------------------------------------------------------------------------
/resources/views/admin/roles/edit.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.admin')
2 | @section('content')
3 |
4 |
5 |
8 |
9 |
10 |
id]) }}" enctype="multipart/form-data">
11 | @method('PUT')
12 | @csrf
13 |
23 |
41 |
42 |
43 | {{ trans('global.save') }}
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | @endsection
--------------------------------------------------------------------------------
/resources/views/admin/roles/show.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.admin')
2 | @section('content')
3 |
4 |
54 |
55 |
56 |
57 | @endsection
--------------------------------------------------------------------------------
/resources/views/admin/users/show.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.admin')
2 | @section('content')
3 |
4 |
70 |
71 |
72 |
73 | @endsection
--------------------------------------------------------------------------------
/resources/views/auth/passwords/confirm.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.app')
2 |
3 | @section('content')
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | {{ __('Please confirm your password before continuing.') }}
13 |
14 |
15 |
16 | @csrf
17 |
18 |
31 |
32 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | @endsection
--------------------------------------------------------------------------------
/resources/views/auth/passwords/email.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.app')
2 | @section('content')
3 |
4 |
5 |
6 |
7 |
{{ trans('panel.site_title') }}
8 |
9 |
{{ trans('global.reset_password') }}
10 |
11 | @if(session('status'))
12 |
13 | {{ session('status') }}
14 |
15 | @endif
16 |
17 |
18 | @csrf
19 |
20 |
29 |
30 |
31 |
32 |
33 | {{ trans('global.send_password') }}
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 | @endsection
--------------------------------------------------------------------------------
/resources/views/auth/passwords/reset.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.app')
2 | @section('content')
3 |
4 |
5 |
6 |
7 |
{{ trans('panel.site_title') }}
8 |
9 |
{{ trans('global.reset_password') }}
10 |
11 |
12 | @csrf
13 |
14 |
15 |
16 |
25 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | {{ trans('global.reset_password') }}
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | @endsection
--------------------------------------------------------------------------------
/resources/views/auth/verify.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.app')
2 |
3 | @section('content')
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | @if (session('resent'))
12 |
13 | {{ __('A fresh verification link has been sent to your email address.') }}
14 |
15 | @endif
16 |
17 | {{ __('Before proceeding, please check your email for a verification link.') }}
18 | {{ __('If you did not receive the email') }},
19 |
20 | @csrf
21 | {{ __('click here to request another') }} .
22 |
23 |
24 |
25 |
26 |
27 |
28 | @endsection
29 |
--------------------------------------------------------------------------------
/resources/views/client/changePassword.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.client')
2 |
3 | @section('content')
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | @if(session('status'))
12 |
13 |
14 |
15 | {{ session('status') }}
16 |
17 |
18 |
19 | @endif
20 |
21 |
22 | @csrf
23 |
24 |
37 |
38 |
45 |
46 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | @endsection
--------------------------------------------------------------------------------
/resources/views/client/home.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.client')
2 |
3 | @section('content')
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | @if(session('status'))
12 |
13 |
14 |
15 | {{ session('status') }}
16 |
17 |
18 |
19 | @endif
20 |
21 | You are logged in!
22 |
23 |
24 |
25 |
26 |
27 | @endsection
--------------------------------------------------------------------------------
/resources/views/client/pdf.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Test No. {{ $result->id }}
6 |
7 |
17 |
18 |
19 | Total points: {{ $result->total_points }} points
20 |
21 |
22 |
23 | Question Text
24 | Points
25 |
26 |
27 |
28 | @foreach($result->questions as $question)
29 |
30 | {{ $question->question_text }}
31 | {{ $question->pivot->points }}
32 |
33 | @endforeach
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/resources/views/client/results.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.client')
2 |
3 | @section('content')
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | @if(session('status'))
12 |
21 | @endif
22 |
23 |
Total points: {{ $result->total_points }} points
24 |
25 |
GET DETAILS IN PDF BY EMAIL
26 |
27 |
28 |
29 |
30 |
31 |
32 | @endsection
--------------------------------------------------------------------------------
/resources/views/home.blade.php:
--------------------------------------------------------------------------------
1 | @extends('layouts.admin')
2 | @section('content')
3 |
4 |
5 |
6 |
7 |
10 |
11 |
12 | @if(session('status'))
13 |
14 | {{ session('status') }}
15 |
16 | @endif
17 |
18 | You are logged in!
19 |
20 |
21 |
22 |
23 |
24 | @endsection
25 | @section('scripts')
26 | @parent
27 |
28 | @endsection
--------------------------------------------------------------------------------
/resources/views/layouts/app.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 | {{ trans('panel.site_title') }}
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | @yield('styles')
22 |
23 |
24 |
25 |
26 |
27 | @yield("content")
28 |
29 |
30 | @yield('scripts')
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/routes/api.php:
--------------------------------------------------------------------------------
1 | 'v1', 'as' => 'api.', 'namespace' => 'Api\V1\Admin', 'middleware' => ['auth:api']], function () {
4 | // Permissions
5 | Route::apiResource('permissions', 'PermissionsApiController');
6 |
7 | // Roles
8 | Route::apiResource('roles', 'RolesApiController');
9 |
10 | // Users
11 | Route::apiResource('users', 'UsersApiController');
12 |
13 | // Categories
14 | Route::apiResource('categories', 'CategoriesApiController');
15 |
16 | // Questions
17 | Route::apiResource('questions', 'QuestionsApiController');
18 |
19 | // Options
20 | Route::apiResource('options', 'OptionsApiController');
21 |
22 | // Results
23 | Route::apiResource('results', 'ResultsApiController');
24 | });
25 |
--------------------------------------------------------------------------------
/routes/channels.php:
--------------------------------------------------------------------------------
1 | id === (int) $id;
16 | });
17 |
--------------------------------------------------------------------------------
/routes/console.php:
--------------------------------------------------------------------------------
1 | comment(Inspiring::quote());
18 | })->describe('Display an inspiring quote');
19 |
--------------------------------------------------------------------------------
/routes/web.php:
--------------------------------------------------------------------------------
1 | 'client.', 'middleware' => ['auth']], function () {
8 | Route::get('home', 'HomeController@redirect');
9 | Route::get('dashboard', 'HomeController@index')->name('home');
10 | Route::get('change-password', 'ChangePasswordController@create')->name('password.create');
11 | Route::post('change-password', 'ChangePasswordController@update')->name('password.update');
12 | Route::get('test', 'TestsController@index')->name('test');
13 | Route::post('test', 'TestsController@store')->name('test.store');
14 | Route::get('results/{result_id}', 'ResultsController@show')->name('results.show');
15 | Route::get('send/{result_id}', 'ResultsController@send')->name('results.send');
16 | });
17 |
18 | Auth::routes();
19 | // Admin
20 |
21 | Route::group(['prefix' => 'admin', 'as' => 'admin.', 'namespace' => 'Admin', 'middleware' => ['auth.admin']], function () {
22 | Route::get('/', 'HomeController@index')->name('home');
23 | // Permissions
24 | Route::delete('permissions/destroy', 'PermissionsController@massDestroy')->name('permissions.massDestroy');
25 | Route::resource('permissions', 'PermissionsController');
26 |
27 | // Roles
28 | Route::delete('roles/destroy', 'RolesController@massDestroy')->name('roles.massDestroy');
29 | Route::resource('roles', 'RolesController');
30 |
31 | // Users
32 | Route::delete('users/destroy', 'UsersController@massDestroy')->name('users.massDestroy');
33 | Route::resource('users', 'UsersController');
34 |
35 | // Categories
36 | Route::delete('categories/destroy', 'CategoriesController@massDestroy')->name('categories.massDestroy');
37 | Route::resource('categories', 'CategoriesController');
38 |
39 | // Questions
40 | Route::delete('questions/destroy', 'QuestionsController@massDestroy')->name('questions.massDestroy');
41 | Route::resource('questions', 'QuestionsController');
42 |
43 | // Options
44 | Route::delete('options/destroy', 'OptionsController@massDestroy')->name('options.massDestroy');
45 | Route::resource('options', 'OptionsController');
46 |
47 | // Results
48 | Route::delete('results/destroy', 'ResultsController@massDestroy')->name('results.massDestroy');
49 | Route::resource('results', 'ResultsController');
50 | });
51 |
--------------------------------------------------------------------------------
/server.php:
--------------------------------------------------------------------------------
1 |
8 | */
9 |
10 | $uri = urldecode(
11 | parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
12 | );
13 |
14 | // This file allows us to emulate Apache's "mod_rewrite" functionality from the
15 | // built-in PHP web server. This provides a convenient way to test a Laravel
16 | // application without having installed a "real" web server software here.
17 | if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
18 | return false;
19 | }
20 |
21 | require_once __DIR__.'/public/index.php';
22 |
--------------------------------------------------------------------------------
/storage/app/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !public/
3 | !.gitignore
4 |
--------------------------------------------------------------------------------
/storage/fonts/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/storage/framework/.gitignore:
--------------------------------------------------------------------------------
1 | config.php
2 | routes.php
3 | schedule-*
4 | compiled.php
5 | services.json
6 | events.scanned.php
7 | routes.scanned.php
8 | down
9 |
--------------------------------------------------------------------------------
/storage/framework/cache/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !data/
3 | !.gitignore
4 |
--------------------------------------------------------------------------------
/storage/framework/sessions/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/storage/framework/testing/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/storage/framework/views/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/storage/logs/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/tests/Browser/CategoriesTest.php:
--------------------------------------------------------------------------------
1 | browse(function (Browser $browser) use ($admin) {
15 | $browser->loginAs($admin);
16 | $browser->visit(route('admin.categories.index'));
17 | $browser->assertRouteIs('admin.categories.index');
18 | });
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/tests/Browser/OptionsTest.php:
--------------------------------------------------------------------------------
1 | browse(function (Browser $browser) use ($admin) {
15 | $browser->loginAs($admin);
16 | $browser->visit(route('admin.options.index'));
17 | $browser->assertRouteIs('admin.options.index');
18 | });
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/tests/Browser/PermissionsTest.php:
--------------------------------------------------------------------------------
1 | browse(function (Browser $browser) use ($admin) {
15 | $browser->loginAs($admin);
16 | $browser->visit(route('admin.permissions.index'));
17 | $browser->assertRouteIs('admin.permissions.index');
18 | });
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/tests/Browser/QuestionsTest.php:
--------------------------------------------------------------------------------
1 | browse(function (Browser $browser) use ($admin) {
15 | $browser->loginAs($admin);
16 | $browser->visit(route('admin.questions.index'));
17 | $browser->assertRouteIs('admin.questions.index');
18 | });
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/tests/Browser/ResultsTest.php:
--------------------------------------------------------------------------------
1 | browse(function (Browser $browser) use ($admin) {
15 | $browser->loginAs($admin);
16 | $browser->visit(route('admin.results.index'));
17 | $browser->assertRouteIs('admin.results.index');
18 | });
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/tests/Browser/RolesTest.php:
--------------------------------------------------------------------------------
1 | browse(function (Browser $browser) use ($admin) {
15 | $browser->loginAs($admin);
16 | $browser->visit(route('admin.roles.index'));
17 | $browser->assertRouteIs('admin.roles.index');
18 | });
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/tests/Browser/UsersTest.php:
--------------------------------------------------------------------------------
1 | browse(function (Browser $browser) use ($admin) {
15 | $browser->loginAs($admin);
16 | $browser->visit(route('admin.users.index'));
17 | $browser->assertRouteIs('admin.users.index');
18 | });
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/tests/CreatesApplication.php:
--------------------------------------------------------------------------------
1 | make(Kernel::class)->bootstrap();
19 |
20 | return $app;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/tests/Feature/ExampleTest.php:
--------------------------------------------------------------------------------
1 | get('/');
18 |
19 | $response->assertStatus(200);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/tests/TestCase.php:
--------------------------------------------------------------------------------
1 | assertTrue(true);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/webpack.mix.js:
--------------------------------------------------------------------------------
1 | const mix = require('laravel-mix');
2 |
3 | /*
4 | |--------------------------------------------------------------------------
5 | | Mix Asset Management
6 | |--------------------------------------------------------------------------
7 | |
8 | | Mix provides a clean, fluent API for defining some Webpack build steps
9 | | for your Laravel application. By default, we are compiling the Sass
10 | | file for the application as well as bundling up all the JS files.
11 | |
12 | */
13 |
14 | mix.js('resources/js/app.js', 'public/js')
15 | .sass('resources/sass/app.scss', 'public/css');
16 |
--------------------------------------------------------------------------------