├── frontend ├── store │ ├── index.js │ ├── auth.js │ ├── README.md │ └── validation.js ├── static │ ├── favicon.ico │ ├── background.jpg │ └── README.md ├── middleware │ ├── clearValidationErrors.js │ ├── guest.js │ └── README.md ├── assets │ ├── styles.css │ └── README.md ├── components │ ├── README.md │ └── Navbar.vue ├── .editorconfig ├── layouts │ ├── default.vue │ └── README.md ├── pages │ ├── README.md │ ├── topics │ │ ├── edit │ │ │ └── index.vue │ │ ├── posts │ │ │ └── edit │ │ │ │ └── index.vue │ │ ├── _id │ │ │ └── index.vue │ │ └── index.vue │ ├── index.vue │ ├── dashboard.vue │ ├── password │ │ ├── forgot.vue │ │ └── find │ │ │ └── _token.vue │ ├── login.vue │ └── register.vue ├── plugins │ ├── mixins │ │ ├── validation.js │ │ └── user.js │ ├── README.md │ └── axios.js ├── README.md ├── package.json ├── .gitignore └── nuxt.config.js ├── backend ├── public │ ├── favicon.ico │ ├── robots.txt │ ├── .htaccess │ ├── index.php │ └── svg │ │ ├── 404.svg │ │ ├── 503.svg │ │ ├── 403.svg │ │ └── 500.svg ├── routes │ ├── web.php │ ├── channels.php │ ├── console.php │ └── api.php ├── database │ ├── .gitignore │ ├── seeds │ │ └── DatabaseSeeder.php │ ├── migrations │ │ ├── 2018_10_28_000805_add_id_and_updated_at_to_password_resets.php │ │ ├── 2014_10_12_100000_create_password_resets_table.php │ │ ├── 2018_10_20_222506_create_topics_table.php │ │ ├── 2018_10_23_121833_create_likes_table.php │ │ ├── 2018_10_20_222516_create_posts_table.php │ │ └── 2014_10_12_000000_create_users_table.php │ └── factories │ │ └── UserFactory.php ├── storage │ ├── logs │ │ └── .gitignore │ ├── app │ │ ├── public │ │ │ └── .gitignore │ │ └── .gitignore │ └── framework │ │ ├── sessions │ │ └── .gitignore │ │ ├── testing │ │ └── .gitignore │ │ ├── views │ │ └── .gitignore │ │ ├── cache │ │ ├── data │ │ │ └── .gitignore │ │ └── .gitignore │ │ └── .gitignore ├── bootstrap │ ├── cache │ │ └── .gitignore │ └── app.php ├── .gitattributes ├── app │ ├── PasswordReset.php │ ├── Like.php │ ├── Traits │ │ └── Orderable.php │ ├── Http │ │ ├── Requests │ │ │ ├── UpdatePostRequest.php │ │ │ ├── StorePostRequest.php │ │ │ ├── UpdateTopicRequest.php │ │ │ ├── TopicCreateRequest.php │ │ │ ├── UserLoginRequest.php │ │ │ └── UserRegisterRequest.php │ │ ├── Middleware │ │ │ ├── EncryptCookies.php │ │ │ ├── CheckForMaintenanceMode.php │ │ │ ├── TrimStrings.php │ │ │ ├── TrustProxies.php │ │ │ ├── Authenticate.php │ │ │ ├── VerifyCsrfToken.php │ │ │ └── RedirectIfAuthenticated.php │ │ ├── Controllers │ │ │ ├── Controller.php │ │ │ ├── PostLikeController.php │ │ │ ├── PostController.php │ │ │ ├── TopicController.php │ │ │ ├── AuthController.php │ │ │ └── PasswordResetController.php │ │ ├── Resources │ │ │ ├── User.php │ │ │ ├── Topic.php │ │ │ └── Post.php │ │ └── Kernel.php │ ├── Topic.php │ ├── Post.php │ ├── Policies │ │ ├── TopicPolicy.php │ │ └── PostPolicy.php │ ├── Providers │ │ ├── BroadcastServiceProvider.php │ │ ├── AppServiceProvider.php │ │ ├── AuthServiceProvider.php │ │ ├── EventServiceProvider.php │ │ └── RouteServiceProvider.php │ ├── Notifications │ │ ├── PasswordResetSuccess.php │ │ └── PasswordResetRequest.php │ ├── Console │ │ └── Kernel.php │ ├── User.php │ └── Exceptions │ │ └── Handler.php ├── tests │ ├── TestCase.php │ ├── Unit │ │ └── ExampleTest.php │ ├── Feature │ │ └── ExampleTest.php │ └── CreatesApplication.php ├── .gitignore ├── .editorconfig ├── resources │ ├── sass │ │ ├── app.scss │ │ └── _variables.scss │ ├── lang │ │ └── en │ │ │ ├── pagination.php │ │ │ ├── auth.php │ │ │ ├── passwords.php │ │ │ └── validation.php │ └── js │ │ ├── components │ │ └── ExampleComponent.vue │ │ ├── app.js │ │ └── bootstrap.js ├── webpack.mix.js ├── server.php ├── config │ ├── cors.php │ ├── view.php │ ├── services.php │ ├── hashing.php │ ├── broadcasting.php │ ├── filesystems.php │ ├── logging.php │ ├── queue.php │ ├── cache.php │ ├── auth.php │ ├── mail.php │ ├── database.php │ ├── session.php │ ├── app.php │ └── jwt.php ├── .env.example ├── package.json ├── phpunit.xml ├── composer.json └── artisan ├── app.png ├── app2.png ├── app3.png ├── app4.png ├── app5.png ├── .DS_Store └── README.md /frontend/store/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /backend/public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /backend/routes/web.php: -------------------------------------------------------------------------------- 1 | 2 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/backend/app/Topic.php:
--------------------------------------------------------------------------------
1 | belongsTo(User::class);
12 | }
13 |
14 | public function posts() {
15 | return $this->hasMany(Post::class);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/backend/app/Http/Middleware/EncryptCookies.php:
--------------------------------------------------------------------------------
1 | assertTrue(true);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/backend/app/Http/Requests/TopicCreateRequest.php:
--------------------------------------------------------------------------------
1 | 'required|max:255',
15 | 'body' => 'required|max:2000',
16 | ];
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/frontend/plugins/axios.js:
--------------------------------------------------------------------------------
1 | export default function({ $axios, store, redirect }) {
2 | $axios.onError(error => {
3 | if (error.response.status === 422) {
4 | store.dispatch("validation/setErrors", error.response.data.errors);
5 | // return redirect("/login");
6 | }
7 | return Promise.reject(error);
8 | });
9 |
10 | $axios.onRequest(() => {
11 | store.dispatch("validation/clearErrors");
12 | });
13 | }
14 |
--------------------------------------------------------------------------------
/frontend/static/README.md:
--------------------------------------------------------------------------------
1 | # STATIC
2 |
3 | **This directory is not required, you can delete it if you don't want to use it.**
4 |
5 | This directory contains your static files.
6 | Each file inside this directory is mapped to `/`.
7 |
8 | Example: `/static/robots.txt` is mapped as `/robots.txt`.
9 |
10 | More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/assets#static).
11 |
--------------------------------------------------------------------------------
/frontend/middleware/README.md:
--------------------------------------------------------------------------------
1 | # MIDDLEWARE
2 |
3 | **This directory is not required, you can delete it if you don't want to use it.**
4 |
5 | This directory contains your application middleware.
6 | The middleware lets you define custom function to be ran before rendering a page or a group of pages (layouts).
7 |
8 | More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/routing#middleware).
9 |
--------------------------------------------------------------------------------
/backend/resources/sass/_variables.scss:
--------------------------------------------------------------------------------
1 |
2 | // Body
3 | $body-bg: #f8fafc;
4 |
5 | // Typography
6 | $font-family-sans-serif: "Nunito", sans-serif;
7 | $font-size-base: 0.9rem;
8 | $line-height-base: 1.6;
9 |
10 | // Colors
11 | $blue: #3490dc;
12 | $indigo: #6574cd;
13 | $purple: #9561e2;
14 | $pink: #f66D9b;
15 | $red: #e3342f;
16 | $orange: #f6993f;
17 | $yellow: #ffed4a;
18 | $green: #38c172;
19 | $teal: #4dc0b5;
20 | $cyan: #6cb2eb;
21 |
--------------------------------------------------------------------------------
/backend/app/Http/Controllers/Controller.php:
--------------------------------------------------------------------------------
1 | belongsTo(User::class);
11 | }
12 |
13 | public function topic() {
14 | return $this->belongsTo(Topic::class);
15 | }
16 |
17 | public function likes() {
18 | return $this->morphMany(Like::class, 'likeable');
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/backend/app/Http/Middleware/CheckForMaintenanceMode.php:
--------------------------------------------------------------------------------
1 | get('/');
18 |
19 | $response->assertStatus(200);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/frontend/README.md:
--------------------------------------------------------------------------------
1 | # frontend
2 |
3 | > My grand Nuxt.js project
4 |
5 | ## Build Setup
6 |
7 | ``` bash
8 | # install dependencies
9 | $ yarn install
10 |
11 | # serve with hot reload at localhost:3000
12 | $ yarn run dev
13 |
14 | # build for production and launch server
15 | $ yarn run build
16 | $ yarn start
17 |
18 | # generate static project
19 | $ yarn run generate
20 | ```
21 |
22 | For detailed explanation on how things work, checkout [Nuxt.js docs](https://nuxtjs.org).
23 |
--------------------------------------------------------------------------------
/backend/tests/CreatesApplication.php:
--------------------------------------------------------------------------------
1 | make(Kernel::class)->bootstrap();
19 |
20 | return $app;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/backend/app/Policies/TopicPolicy.php:
--------------------------------------------------------------------------------
1 | ownsTopic($topic);
18 | }
19 |
20 | public function destroy(User $user, Topic $topic) {
21 | return $user->ownsTopic($topic);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/backend/app/Providers/BroadcastServiceProvider.php:
--------------------------------------------------------------------------------
1 | ({
2 | errors: {}
3 | });
4 |
5 | // getters
6 | export const getters = {
7 | errors(state) {
8 | return state.errors;
9 | }
10 | };
11 |
12 | // mutations
13 | export const mutations = {
14 | SET_VALIDATION_ERRORS(state, errors) {
15 | state.errors = errors;
16 | }
17 | };
18 |
19 | // actions
20 | export const actions = {
21 | setErrors({ commit }, errors) {
22 | commit("SET_VALIDATION_ERRORS", errors);
23 | },
24 | clearErrors({ commit }) {
25 | commit("SET_VALIDATION_ERRORS", {});
26 | }
27 | };
28 |
--------------------------------------------------------------------------------
/backend/app/Http/Resources/User.php:
--------------------------------------------------------------------------------
1 | $this->id,
18 | 'name' => $this->name,
19 | 'email' => $this->email,
20 | 'created_at' => $this->created_at,
21 | ];
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/frontend/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "frontend",
3 | "version": "1.0.0",
4 | "description": "My grand Nuxt.js project",
5 | "author": "Ryan Dhungel",
6 | "private": true,
7 | "scripts": {
8 | "dev": "nuxt",
9 | "build": "nuxt build",
10 | "start": "nuxt start",
11 | "generate": "nuxt generate"
12 | },
13 | "dependencies": {
14 | "@nuxtjs/auth": "^4.5.2",
15 | "@nuxtjs/axios": "^5.3.3",
16 | "axios": "^0.18.0",
17 | "cross-env": "^5.2.0",
18 | "nuxt": "^2.0.0"
19 | },
20 | "devDependencies": {
21 | "nodemon": "^1.11.0"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/backend/app/Http/Middleware/Authenticate.php:
--------------------------------------------------------------------------------
1 | expectsJson()) {
18 | return route('login');
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/backend/routes/channels.php:
--------------------------------------------------------------------------------
1 | id === (int) $id;
16 | });
17 |
--------------------------------------------------------------------------------
/backend/app/Http/Middleware/VerifyCsrfToken.php:
--------------------------------------------------------------------------------
1 | ownsPost($post);
18 | }
19 |
20 | public function destroy(User $user, Post $post) {
21 | return $user->ownsPost($post);
22 | }
23 |
24 | public function like(User $user, Post $post) {
25 | return !$user->ownsPost($post);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/backend/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 |
--------------------------------------------------------------------------------
/backend/app/Http/Resources/Topic.php:
--------------------------------------------------------------------------------
1 | $this->id,
13 | 'title' => $this->title,
14 | 'created_at' => $this->created_at->diffForHumans(),
15 | 'updated_at' => $this->updated_at->diffForHumans(),
16 | 'posts' => PostResource::collection($this->posts),
17 | 'user' => $this->user,
18 | ];
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/backend/app/Http/Requests/UserLoginRequest.php:
--------------------------------------------------------------------------------
1 | 'required',
25 | 'password' => 'required|min:6',
26 | ];
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/backend/app/Http/Controllers/PostLikeController.php:
--------------------------------------------------------------------------------
1 | authorize('like', $post);
13 | // check
14 | if ($request->user()->hasLikedPost($post)) {
15 | return response(null, 409);
16 | }
17 | // create like
18 | $like = new Like;
19 | $like->user()->associate($request->user());
20 | $post->likes()->save($like);
21 | return response(null, 204);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/backend/resources/lang/en/pagination.php:
--------------------------------------------------------------------------------
1 | '« Previous',
17 | 'next' => 'Next »',
18 |
19 | ];
20 |
--------------------------------------------------------------------------------
/backend/routes/console.php:
--------------------------------------------------------------------------------
1 | comment(Inspiring::quote());
18 | })->describe('Display an inspiring quote');
19 |
--------------------------------------------------------------------------------
/backend/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 |
--------------------------------------------------------------------------------
/backend/config/cors.php:
--------------------------------------------------------------------------------
1 | false,
16 | 'allowedOrigins' => ['*'],
17 | 'allowedOriginsPatterns' => [],
18 | 'allowedHeaders' => ['*'],
19 | 'allowedMethods' => ['*'],
20 | 'exposedHeaders' => [],
21 | 'maxAge' => 0,
22 |
23 | ];
24 |
--------------------------------------------------------------------------------
/backend/app/Http/Resources/Post.php:
--------------------------------------------------------------------------------
1 | $this->id,
13 | 'body' => $this->body,
14 | 'created_at' => $this->created_at->diffForHumans(),
15 | 'updated_at' => $this->updated_at->diffForHumans(),
16 | 'user' => $this->user,
17 | 'like_count' => $this->likes->count(),
18 | 'users' => UserResource::collection($this->likes->pluck('user')),
19 | ];
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/backend/database/migrations/2018_10_28_000805_add_id_and_updated_at_to_password_resets.php:
--------------------------------------------------------------------------------
1 | increments('id');
11 | $table->timestamp('updated_at')->nullable();
12 | });
13 | }
14 |
15 | public function down() {
16 | Schema::table('password_resets', function (Blueprint $table) {
17 | Schema::dropIfExists('password_resets');
18 | });
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/backend/app/Http/Middleware/RedirectIfAuthenticated.php:
--------------------------------------------------------------------------------
1 | check()) {
21 | return redirect('/home');
22 | }
23 |
24 | return $next($request);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/backend/app/Http/Requests/UserRegisterRequest.php:
--------------------------------------------------------------------------------
1 | 'email|required|unique:users,email',
25 | 'name' => 'required',
26 | 'password' => 'required|min:6',
27 | ];
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/backend/public/.htaccess:
--------------------------------------------------------------------------------
1 |
13 |
13 |
Dont have an account?
Already have an account?
{{topic.created_at}} by {{topic.user.name}}
7 |{{content.body}}
9 | 10 |{{content.created_at}} by {{content.user.name}}
21 |Already have an account?
{{topic.created_at}} by {{topic.user.name}}
18 | 19 |{{content.created_at}} by {{content.user.name}}
22 | 23 |