├── .editorconfig
├── .env.example
├── .eslintrc
├── .eslintrc.js
├── .gitattributes
├── .gitignore
├── LICENSE
├── app
├── Console
│ └── Kernel.php
├── Exceptions
│ ├── EmailTakenException.php
│ └── Handler.php
├── Http
│ ├── Controllers
│ │ ├── Auth
│ │ │ ├── ForgotPasswordController.php
│ │ │ ├── LoginController.php
│ │ │ ├── OAuthController.php
│ │ │ ├── RegisterController.php
│ │ │ └── ResetPasswordController.php
│ │ ├── Controller.php
│ │ ├── Settings
│ │ │ ├── PasswordController.php
│ │ │ └── ProfileController.php
│ │ └── UserController.php
│ ├── Kernel.php
│ ├── Middleware
│ │ ├── EncryptCookies.php
│ │ ├── RedirectIfAuthenticated.php
│ │ ├── SetLocale.php
│ │ ├── TrimStrings.php
│ │ ├── TrustProxies.php
│ │ └── VerifyCsrfToken.php
│ └── Requests
│ │ └── UserRequest.php
├── Models
│ ├── OAuthProvider.php
│ └── User.php
├── Notifications
│ └── ResetPassword.php
├── Policies
│ └── UserPolicy.php
├── Providers
│ ├── AppServiceProvider.php
│ ├── AuthServiceProvider.php
│ ├── BroadcastServiceProvider.php
│ ├── EventServiceProvider.php
│ └── RouteServiceProvider.php
└── Traits
│ └── HasRole.php
├── artisan
├── bootstrap
├── app.php
└── cache
│ └── .gitignore
├── client
├── assets
│ └── css
│ │ ├── _tailwind.css
│ │ └── main.css
├── components
│ ├── AccountDropdown.vue
│ ├── LocaleDropdown.vue
│ ├── Logo.vue
│ ├── Navbar.vue
│ └── global
│ │ ├── Card.vue
│ │ ├── Container.vue
│ │ ├── LayoutContainer.vue
│ │ ├── LayoutMain.vue
│ │ ├── LayoutNavigation.vue
│ │ ├── LoginWithGithub.vue
│ │ └── index.js
├── lang
│ ├── en.json
│ ├── es.json
│ └── zh-CN.json
├── layouts
│ ├── default.vue
│ └── simple.vue
├── middleware
│ ├── auth.js
│ ├── check-auth.js
│ ├── guest.js
│ └── locale.js
├── modules
│ └── spa.js
├── nuxt.config.js
├── pages
│ ├── auth
│ │ ├── login.vue
│ │ ├── password
│ │ │ ├── email.vue
│ │ │ └── reset.vue
│ │ └── register.vue
│ ├── home.vue
│ ├── settings
│ │ ├── index.vue
│ │ ├── password.vue
│ │ └── profile.vue
│ └── welcome.vue
├── plugins
│ ├── axios.js
│ ├── i18n.js
│ ├── nuxt-client-init.js
│ └── vue-tailwind.js
├── router.js
├── static
│ └── favicon.ico
├── store
│ ├── auth.js
│ ├── index.js
│ └── lang.js
└── utils
│ └── index.js
├── composer.json
├── composer.lock
├── config
├── app.php
├── auth.php
├── broadcasting.php
├── cache.php
├── database.php
├── filesystems.php
├── hashing.php
├── logging.php
├── mail.php
├── queue.php
├── services.php
├── session.php
└── view.php
├── database
├── .gitignore
├── factories
│ └── UserFactory.php
├── migrations
│ ├── 2014_10_12_000000_create_users_table.php
│ ├── 2014_10_12_100000_create_password_resets_table.php
│ └── 2017_12_07_122845_create_oauth_providers_table.php
└── seeds
│ └── DatabaseSeeder.php
├── package-lock.json
├── package.json
├── phpunit.xml
├── postcss.config.js
├── public
├── .htaccess
├── favicon.ico
├── index.php
├── robots.txt
└── web.config
├── resources
├── lang
│ ├── en
│ │ ├── auth.php
│ │ ├── pagination.php
│ │ ├── passwords.php
│ │ └── validation.php
│ ├── es
│ │ ├── auth.php
│ │ ├── pagination.php
│ │ ├── passwords.php
│ │ └── validation.php
│ └── zh-CN
│ │ ├── auth.php
│ │ ├── pagination.php
│ │ ├── passwords.php
│ │ └── validation.php
└── views
│ ├── errors
│ └── layout.blade.php
│ └── oauth
│ ├── callback.blade.php
│ └── emailTaken.blade.php
├── routes
├── api.php
├── channels.php
├── console.php
└── web.php
├── server.php
├── storage
├── app
│ ├── .gitignore
│ └── public
│ │ └── .gitignore
├── framework
│ ├── .gitignore
│ ├── cache
│ │ ├── .gitignore
│ │ └── data
│ │ │ └── .gitignore
│ ├── sessions
│ │ └── .gitignore
│ ├── testing
│ │ └── .gitignore
│ └── views
│ │ └── .gitignore
└── logs
│ └── .gitignore
├── tailwind.config.js
└── tests
├── CreatesApplication.php
├── Feature
├── LocaleTest.php
├── LoginTest.php
├── OAuthTest.php
├── RegisterTest.php
├── SettingsTest.php
└── UserControllerTest.php
└── TestCase.php
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = space
5 | indent_size = 4
6 | end_of_line = lf
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
14 | [*.{vue,js,json,html,scss,blade.php}]
15 | indent_style = space
16 | indent_size = 2
17 |
--------------------------------------------------------------------------------
/.env.example:
--------------------------------------------------------------------------------
1 | APP_NAME=LaravelNuxt
2 | APP_ENV=local
3 | APP_KEY=
4 | APP_DEBUG=true
5 | APP_LOG_LEVEL=debug
6 |
7 | APP_URL=http://api.laravel-nuxt.test
8 | CLIENT_URL=http://localhost:3000
9 |
10 | DB_CONNECTION=mysql
11 | DB_HOST=127.0.0.1
12 | DB_PORT=3306
13 | DB_DATABASE=homestead
14 | DB_USERNAME=homestead
15 | DB_PASSWORD=secret
16 |
17 | BROADCAST_DRIVER=log
18 | CACHE_DRIVER=file
19 | SESSION_DRIVER=file
20 | QUEUE_CONNECTION=sync
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 | PUSHER_APP_ID=
34 | PUSHER_APP_KEY=
35 | PUSHER_APP_SECRET=
36 |
37 | JWT_TTL=1440
38 | JWT_SECRET=
39 |
40 | GITHUB_CLIENT_ID=
41 | GITHUB_CLIENT_SECRET=
42 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "root": true,
3 | "parserOptions": {
4 | "parser": "babel-eslint",
5 | "ecmaVersion": 2017,
6 | "sourceType": "module"
7 | },
8 | "extends": [
9 | "plugin:vue/recommended",
10 | "@vue/standard"
11 | ],
12 | "rules": {
13 | "vue/max-attributes-per-line": "off"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | env: {
4 | node: true
5 | },
6 | 'extends': [
7 | 'plugin:vue/recommended'
8 | ],
9 | rules: {
10 | 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
11 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
12 | },
13 | parserOptions: {
14 | parser: 'babel-eslint'
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 | *.css linguist-vendored
3 | *.scss linguist-vendored
4 | *.js linguist-vendored
5 | CHANGELOG.md export-ignore
6 | README.md export-ignore
7 | .travis.yml export-ignore
8 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | /public/hot
3 | /public/storage
4 | /storage/*.key
5 | /vendor
6 | /.idea
7 | /.vagrant
8 | Homestead.json
9 | Homestead.yaml
10 | npm-debug.log
11 | yarn-error.log
12 | .env*
13 | .nuxt
14 | .php_cs.cache
15 | /dist
16 | /public/_nuxt
17 |
18 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Alfonso Bribiesca
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/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/EmailTakenException.php:
--------------------------------------------------------------------------------
1 | view('oauth.emailTaken', [], 400);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/app/Exceptions/Handler.php:
--------------------------------------------------------------------------------
1 | middleware('guest');
21 | }
22 |
23 | /**
24 | * Get the response for a successful password reset link.
25 | *
26 | * @param \Illuminate\Http\Request $request
27 | * @param string $response
28 | * @return \Illuminate\Http\RedirectResponse
29 | */
30 | protected function sendResetLinkResponse(Request $request, $response)
31 | {
32 | return ['status' => trans($response)];
33 | }
34 |
35 | /**
36 | * Get the response for a failed password reset link.
37 | *
38 | * @param \Illuminate\Http\Request $request
39 | * @param string $response
40 | * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
41 | */
42 | protected function sendResetLinkFailedResponse(Request $request, $response)
43 | {
44 | return response()->json(['email' => trans($response)], 400);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Auth/LoginController.php:
--------------------------------------------------------------------------------
1 | middleware('guest')->except('logout');
21 | }
22 |
23 | /**
24 | * Attempt to log the user into the application.
25 | *
26 | * @param \Illuminate\Http\Request $request
27 | * @return bool
28 | */
29 | protected function attemptLogin(Request $request)
30 | {
31 | $token = $this->guard()->attempt($this->credentials($request));
32 |
33 | if ($token) {
34 | $this->guard()->setToken($token);
35 |
36 | return true;
37 | }
38 |
39 | return false;
40 | }
41 |
42 | /**
43 | * Send the response after the user was authenticated.
44 | *
45 | * @param \Illuminate\Http\Request $request
46 | * @return \Illuminate\Http\Response
47 | */
48 | protected function sendLoginResponse(Request $request)
49 | {
50 | $this->clearLoginAttempts($request);
51 |
52 | $token = (string) $this->guard()->getToken();
53 | $expiration = $this->guard()->getPayload()->get('exp');
54 |
55 | return [
56 | 'token' => $token,
57 | 'token_type' => 'bearer',
58 | 'expires_in' => $expiration - time(),
59 | ];
60 | }
61 |
62 | /**
63 | * Log the user out of the application.
64 | *
65 | * @param \Illuminate\Http\Request $request
66 | * @return \Illuminate\Http\Response
67 | */
68 | public function logout(Request $request)
69 | {
70 | $this->guard()->logout();
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Auth/OAuthController.php:
--------------------------------------------------------------------------------
1 | route('oauth.callback', 'github'),
25 | ]);
26 | }
27 |
28 | /**
29 | * Redirect the user to the provider authentication page.
30 | *
31 | * @param string $provider
32 | * @return \Illuminate\Http\RedirectResponse
33 | */
34 | public function redirectToProvider($provider)
35 | {
36 | return [
37 | 'url' => Socialite::driver($provider)->stateless()->redirect()->getTargetUrl(),
38 | ];
39 | }
40 |
41 | /**
42 | * Obtain the user information from the provider.
43 | *
44 | * @param string $driver
45 | * @return \Illuminate\Http\Response
46 | */
47 | public function handleProviderCallback($provider)
48 | {
49 | $user = Socialite::driver($provider)->stateless()->user();
50 | $user = $this->findOrCreateUser($provider, $user);
51 |
52 | $this->guard()->setToken(
53 | $token = $this->guard()->login($user)
54 | );
55 |
56 | return view('oauth/callback', [
57 | 'token' => $token,
58 | 'token_type' => 'bearer',
59 | 'expires_in' => $this->guard()->getPayload()->get('exp') - time(),
60 | ]);
61 | }
62 |
63 | /**
64 | * @param string $provider
65 | * @param \Laravel\Socialite\Contracts\User $sUser
66 | * @return \App\User|false
67 | */
68 | protected function findOrCreateUser($provider, $user)
69 | {
70 | $oauthProvider = OAuthProvider::where('provider', $provider)
71 | ->where('provider_user_id', $user->getId())
72 | ->first();
73 |
74 | if ($oauthProvider) {
75 | $oauthProvider->update([
76 | 'access_token' => $user->token,
77 | 'refresh_token' => $user->refreshToken,
78 | ]);
79 |
80 | return $oauthProvider->user;
81 | }
82 |
83 | if (User::where('email', $user->getEmail())->exists()) {
84 | throw new EmailTakenException;
85 | }
86 |
87 | return $this->createUser($provider, $user);
88 | }
89 |
90 | /**
91 | * @param string $provider
92 | * @param \Laravel\Socialite\Contracts\User $sUser
93 | * @return \App\User
94 | */
95 | protected function createUser($provider, $sUser)
96 | {
97 | $user = User::create([
98 | 'name' => $sUser->getName(),
99 | 'email' => $sUser->getEmail(),
100 | ]);
101 |
102 | $user->oauthProviders()->create([
103 | 'provider' => $provider,
104 | 'provider_user_id' => $sUser->getId(),
105 | 'access_token' => $sUser->token,
106 | 'refresh_token' => $sUser->refreshToken,
107 | ]);
108 |
109 | return $user;
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Auth/RegisterController.php:
--------------------------------------------------------------------------------
1 | middleware('guest');
23 | }
24 |
25 | /**
26 | * The user has been registered.
27 | *
28 | * @param \Illuminate\Http\Request $request
29 | * @param mixed $user
30 | * @return mixed
31 | */
32 | protected function registered(Request $request, $user)
33 | {
34 | return $user;
35 | }
36 |
37 | /**
38 | * Get a validator for an incoming registration request.
39 | *
40 | * @param array $data
41 | * @return \Illuminate\Contracts\Validation\Validator
42 | */
43 | protected function validator(array $data)
44 | {
45 | return Validator::make($data, [
46 | 'name' => 'required|max:255',
47 | 'email' => 'required|email|max:255|unique:users',
48 | 'password' => 'required|min:6|confirmed',
49 | ]);
50 | }
51 |
52 | /**
53 | * Create a new user instance after a valid registration.
54 | *
55 | * @param array $data
56 | * @return User
57 | */
58 | protected function create(array $data)
59 | {
60 | return User::create([
61 | 'name' => $data['name'],
62 | 'email' => $data['email'],
63 | 'password' => bcrypt($data['password']),
64 | ]);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Auth/ResetPasswordController.php:
--------------------------------------------------------------------------------
1 | middleware('guest');
21 | }
22 |
23 | /**
24 | * Get the response for a successful password reset.
25 | *
26 | * @param \Illuminate\Http\Request $request
27 | * @param string $response
28 | * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
29 | */
30 | protected function sendResetResponse(Request $request, $response)
31 | {
32 | return ['status' => trans($response)];
33 | }
34 |
35 | /**
36 | * Get the response for a failed password reset.
37 | *
38 | * @param \Illuminate\Http\Request $request
39 | * @param string $response
40 | * @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
41 | */
42 | protected function sendResetFailedResponse(Request $request, $response)
43 | {
44 | return response()->json(['email' => trans($response)], 400);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Controller.php:
--------------------------------------------------------------------------------
1 | validate($request, [
19 | 'password' => 'required|confirmed|min:6',
20 | ]);
21 |
22 | $request->user()->update([
23 | 'password' => bcrypt($request->password),
24 | ]);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Settings/ProfileController.php:
--------------------------------------------------------------------------------
1 | user();
19 |
20 | $this->validate($request, [
21 | 'name' => 'required',
22 | 'email' => 'required|email|unique:users,email,'.$user->id,
23 | ]);
24 |
25 | return tap($user)->update($request->only('name', 'email'));
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/Http/Controllers/UserController.php:
--------------------------------------------------------------------------------
1 | input('per_page', 20));
20 | }
21 |
22 | /**
23 | * Store a newly created resource in storage.
24 | *
25 | * @param \App\Http\Requests\UserRequest $request
26 | * @return \Illuminate\Http\Response
27 | */
28 | public function store(UserRequest $request)
29 | {
30 | $user = User::create($request->validated());
31 |
32 | return $user;
33 | }
34 |
35 | /**
36 | * Display the specified resource.
37 | *
38 | * @param \App\Models\User $user
39 | * @return \Illuminate\Http\Response
40 | */
41 | public function show(User $user)
42 | {
43 | $this->authorize('show', $user);
44 |
45 | return $user;
46 | }
47 |
48 | /**
49 | * Update the specified resource in storage.
50 | *
51 | * @param \App\Http\Requests\UserRequest $request
52 | * @param \App\Models\User $user
53 | * @return \Illuminate\Http\Response
54 | */
55 | public function update(UserRequest $request, User $user)
56 | {
57 | $user->update($request->validated());
58 |
59 | return $user;
60 | }
61 |
62 | /**
63 | * Remove the specified resource from storage.
64 | *
65 | * @param \App\Models\User $user
66 | * @return \Illuminate\Http\Response
67 | */
68 | public function destroy(User $user)
69 | {
70 | $this->authorize('destroy', $user);
71 |
72 | return tap($user)->delete();
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/app/Http/Kernel.php:
--------------------------------------------------------------------------------
1 | [
33 | \App\Http\Middleware\EncryptCookies::class,
34 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
35 | \Illuminate\Session\Middleware\StartSession::class,
36 | \Illuminate\Session\Middleware\AuthenticateSession::class,
37 | \Illuminate\View\Middleware\ShareErrorsFromSession::class,
38 | \App\Http\Middleware\VerifyCsrfToken::class,
39 | \Illuminate\Routing\Middleware\SubstituteBindings::class,
40 | ],
41 |
42 | 'api' => [
43 | 'throttle:60,1',
44 | 'bindings',
45 | ],
46 | ];
47 |
48 | /**
49 | * The application's route middleware.
50 | *
51 | * These middleware may be assigned to groups or used individually.
52 | *
53 | * @var array
54 | */
55 | protected $routeMiddleware = [
56 | 'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
57 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
58 | 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
59 | 'can' => \Illuminate\Auth\Middleware\Authorize::class,
60 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
61 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
62 | 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
63 | ];
64 | }
65 |
--------------------------------------------------------------------------------
/app/Http/Middleware/EncryptCookies.php:
--------------------------------------------------------------------------------
1 | check()) {
21 | return response()->json(['error' => 'Already authenticated.'], 400);
22 | }
23 |
24 | return $next($request);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/Http/Middleware/SetLocale.php:
--------------------------------------------------------------------------------
1 | parseLocale($request)) {
19 | app()->setLocale($locale);
20 | }
21 |
22 | return $next($request);
23 | }
24 |
25 | /**
26 | * @param \Illuminate\Http\Request $request
27 | * @return string|null
28 | */
29 | protected function parseLocale($request)
30 | {
31 | $locales = config('app.locales');
32 |
33 | // if (array_key_exists($locale = $request->cookie('locale'), $locales)) {
34 | // return $locale;
35 | // }
36 |
37 | $locale = $request->server('HTTP_ACCEPT_LANGUAGE');
38 | $locale = substr($locale, 0, strpos($locale, ',') ?: strlen($locale));
39 |
40 | if (array_key_exists($locale, $locales)) {
41 | return $locale;
42 | }
43 |
44 | if (array_key_exists($locale, $locales)) {
45 | return $locale;
46 | }
47 |
48 | $locale = substr($locale, 0, 2);
49 | if (array_key_exists($locale, $locales)) {
50 | return $locale;
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/app/Http/Middleware/TrimStrings.php:
--------------------------------------------------------------------------------
1 | user
18 | ? $this->user()->can('update', $this->user)
19 | : $this->user()->can('store', User::class);
20 | }
21 |
22 | /**
23 | * Get the validation rules that apply to the request.
24 | *
25 | * @return array
26 | */
27 | public function rules()
28 | {
29 | if ($this->user) {
30 | return [
31 | 'name' => 'nullable',
32 | 'email' => 'nullable|email|unique:users,email,' . $this->user->id,
33 | 'password' => 'nullable|min:6',
34 | 'role' => 'nullable|in:' . $this->user()->assignable_roles->implode(','),
35 | ];
36 | }
37 |
38 | return [
39 | 'name' => 'required',
40 | 'email' => 'required|email|unique:users,email',
41 | 'password' => 'required|min:6',
42 | 'role' => 'required|in:' . $this->user()->assignable_roles->implode(','),
43 | ];
44 | }
45 |
46 | public function validated()
47 | {
48 | $validated = parent::validated();
49 | if (!empty($validated['password'])) {
50 | $validated['password'] = bcrypt($validated['password']);
51 | }
52 | return $validated;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/app/Models/OAuthProvider.php:
--------------------------------------------------------------------------------
1 | belongsTo(User::class);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/Models/User.php:
--------------------------------------------------------------------------------
1 | email)).'.jpg?s=200&d=mm';
59 | }
60 |
61 | /**
62 | * Get the oauth providers.
63 | *
64 | * @return \Illuminate\Database\Eloquent\Relations\HasMany
65 | */
66 | public function oauthProviders()
67 | {
68 | return $this->hasMany(OAuthProvider::class);
69 | }
70 |
71 | /**
72 | * Send the password reset notification.
73 | *
74 | * @param string $token
75 | * @return void
76 | */
77 | public function sendPasswordResetNotification($token)
78 | {
79 | $this->notify(new ResetPasswordNotification($token));
80 | }
81 |
82 | /**
83 | * @return int
84 | */
85 | public function getJWTIdentifier()
86 | {
87 | return $this->getKey();
88 | }
89 |
90 | /**
91 | * @return array
92 | */
93 | public function getJWTCustomClaims()
94 | {
95 | return [];
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/app/Notifications/ResetPassword.php:
--------------------------------------------------------------------------------
1 | line('You are receiving this email because we received a password reset request for your account.')
20 | ->action('Reset Password', url(config('app.client_url').'/password/reset/'.$this->token).'?email='.urlencode($notifiable->email))
21 | ->line('If you did not request a password reset, no further action is required.');
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app/Policies/UserPolicy.php:
--------------------------------------------------------------------------------
1 | is_admin;
21 | }
22 |
23 | /**
24 | * Determine whether the user can view the model.
25 | *
26 | * @param \App\Models\User $user
27 | * @param \App\Models\User $model
28 | * @return mixed
29 | */
30 | public function show(User $user, User $model)
31 | {
32 | return $user->is_admin;
33 | }
34 |
35 | /**
36 | * Determine whether the user can store models.
37 | *
38 | * @param \App\Models\User $user
39 | * @return mixed
40 | */
41 | public function store(User $user)
42 | {
43 | return $user->is_admin;
44 | }
45 |
46 | /**
47 | * Determine whether the user can update the model.
48 | *
49 | * @param \App\Models\User $user
50 | * @param \App\Models\User $model
51 | * @return mixed
52 | */
53 | public function update(User $user, User $model)
54 | {
55 | return $user->is_admin
56 | // Can only update users in the role that has access
57 | && $user->assignableRoles->contains($model->role);
58 | }
59 |
60 | /**
61 | * Determine whether the user can destroy the model.
62 | *
63 | * @param \App\Models\User $user
64 | * @param \App\Models\User $model
65 | * @return mixed
66 | */
67 | public function destroy(User $user, User $model)
68 | {
69 | return $user->is_admin
70 | // Can only destroy users in the role that has access
71 | && $user->assignableRoles->contains($model->role);
72 | }
73 |
74 | /**
75 | * Determine whether the user can restore the model.
76 | *
77 | * @param \App\Models\User $user
78 | * @param \App\Models\User $model
79 | * @return mixed
80 | */
81 | public function restore(User $user, User $model)
82 | {
83 | //
84 | }
85 |
86 | /**
87 | * Determine whether the user can permanently destroy the model.
88 | *
89 | * @param \App\Models\User $user
90 | * @param \App\Models\User $model
91 | * @return mixed
92 | */
93 | public function forceDelete(User $user, User $model)
94 | {
95 | //
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/app/Providers/AppServiceProvider.php:
--------------------------------------------------------------------------------
1 | app->runningUnitTests()) {
19 | Schema::defaultStringLength(191);
20 | }
21 | }
22 |
23 | /**
24 | * Register any application services.
25 | *
26 | * @return void
27 | */
28 | public function register()
29 | {
30 | if ($this->app->environment('local', 'testing')) {
31 | $this->app->register(DuskServiceProvider::class);
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/Providers/AuthServiceProvider.php:
--------------------------------------------------------------------------------
1 | \App\Policies\UserPolicy::class,
16 | \App\Models\Company::class => \App\Policies\CompanyPolicy::class,
17 | \App\Models\Provider::class => \App\Policies\ProviderPolicy::class,
18 | \App\Models\Layout::class => \App\Policies\LayoutPolicy::class,
19 | \App\Models\Column::class => \App\Policies\ColumnPolicy::class,
20 | \App\Models\Data::class => \App\Policies\DataPolicy::class,
21 | ];
22 |
23 | /**
24 | * Register any authentication / authorization services.
25 | *
26 | * @return void
27 | */
28 | public function boot()
29 | {
30 | $this->registerPolicies();
31 |
32 | //
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/Providers/BroadcastServiceProvider.php:
--------------------------------------------------------------------------------
1 | [
17 | 'App\Listeners\EventListener',
18 | ],
19 | ];
20 |
21 | /**
22 | * Register any events for your application.
23 | *
24 | * @return void
25 | */
26 | public function boot()
27 | {
28 | parent::boot();
29 |
30 | //
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app/Providers/RouteServiceProvider.php:
--------------------------------------------------------------------------------
1 | layout);
30 | if (! auth()->user()->can('show', $layout)) {
31 | abort(403);
32 | }
33 | return $layout->data()->findOrFail($id);
34 | });
35 | }
36 |
37 | /**
38 | * Define the routes for the application.
39 | *
40 | * @return void
41 | */
42 | public function map()
43 | {
44 | $this->mapApiRoutes();
45 |
46 | $this->mapWebRoutes();
47 |
48 | //
49 | }
50 |
51 | /**
52 | * Define the "web" routes for the application.
53 | *
54 | * These routes all receive session state, CSRF protection, etc.
55 | *
56 | * @return void
57 | */
58 | protected function mapWebRoutes()
59 | {
60 | Route::middleware('web')
61 | ->namespace($this->namespace)
62 | ->group(base_path('routes/web.php'));
63 | }
64 |
65 | /**
66 | * Define the "api" routes for the application.
67 | *
68 | * These routes are typically stateless.
69 | *
70 | * @return void
71 | */
72 | protected function mapApiRoutes()
73 | {
74 | Route::middleware('api')
75 | // ->prefix('api')
76 | ->namespace($this->namespace)
77 | ->group(base_path('routes/api.php'));
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/app/Traits/HasRole.php:
--------------------------------------------------------------------------------
1 | role === self::ROLE_ROOT;
18 | }
19 |
20 | public function getIsAdminAttribute()
21 | {
22 | return in_array($this->role, [
23 | self::ROLE_ROOT,
24 | self::ROLE_ADMIN,
25 | ]);
26 | }
27 |
28 | public function getAssignableRolesAttribute()
29 | {
30 | if ($this->role === self::ROLE_ROOT) {
31 | return self::roleOptions();
32 | }
33 |
34 | if ($this->is_admin) {
35 | return self::roleOptions()->filter(function ($role) {
36 | return $role !== self::ROLE_ROOT;
37 | });
38 | }
39 |
40 | return collect();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/client/assets/css/_tailwind.css:
--------------------------------------------------------------------------------
1 | @tailwind base;
2 |
3 | @tailwind components;
4 |
5 | @tailwind utilities;
6 |
--------------------------------------------------------------------------------
/client/assets/css/main.css:
--------------------------------------------------------------------------------
1 | /** ------------------------------------------------------------
2 | ## TAILWIND CSS
3 | --------------------------------------------------------- */
4 |
5 | @import '_tailwind';
6 |
7 | /** ------------------------------------------------------------
8 | ## CUSTOM CLASSES
9 | --------------------------------------------------------- */
10 |
11 | html,
12 | body,
13 | #__nuxt,
14 | #__layout {
15 | height: 100%;
16 | }
17 |
18 | body {
19 | @apply bg-gray-300
20 | }
21 |
22 | p, h1, h2, h3, h4, h5 {
23 | @apply mb-2
24 | }
--------------------------------------------------------------------------------
/client/components/AccountDropdown.vue:
--------------------------------------------------------------------------------
1 |
2 |
8 |
26 |
27 |
28 |
29 |
48 |
--------------------------------------------------------------------------------
/client/components/LocaleDropdown.vue:
--------------------------------------------------------------------------------
1 |
2 |
8 |
20 |
21 |
22 |
23 |
44 |
--------------------------------------------------------------------------------
/client/components/Logo.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{ alt }}
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/client/components/Navbar.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
9 |
10 |
11 |
15 |
16 | -
17 |
18 | {{ $t('login') }}
19 |
20 |
21 | -
22 |
23 | {{ $t('register') }}
24 |
25 |
26 |
27 |
28 |
29 |
30 |
36 |
37 |
38 | -
39 |
42 | {{ $t('home') }}
43 |
44 |
45 | -
46 |
49 | {{ $t('settings') }}
50 |
51 |
52 |
53 | -
54 |
58 | {{ $t('logout') }}
59 |
60 |
61 |
62 |
63 | -
64 |
67 | {{ $t('login') }}
68 |
69 |
70 | -
71 |
74 | {{ $t('register') }}
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
106 |
107 |
114 |
--------------------------------------------------------------------------------
/client/components/global/Card.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
19 |
--------------------------------------------------------------------------------
/client/components/global/Container.vue:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
21 |
--------------------------------------------------------------------------------
/client/components/global/LayoutContainer.vue:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
12 |
24 |
--------------------------------------------------------------------------------
/client/components/global/LayoutMain.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
--------------------------------------------------------------------------------
/client/components/global/LayoutNavigation.vue:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
19 |
--------------------------------------------------------------------------------
/client/components/global/LoginWithGithub.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | {{ $t('login_with') }}
4 | Github
5 |
6 |
7 |
8 |
87 |
--------------------------------------------------------------------------------
/client/components/global/index.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 |
3 | const requireContext = require.context('./', false, /.*\.(vue)$/)
4 |
5 | requireContext.keys().forEach(file => {
6 | const Component = requireContext(file).default
7 |
8 | if (Component.name) {
9 | Vue.component(Component.name, Component)
10 | }
11 | })
12 |
--------------------------------------------------------------------------------
/client/lang/en.json:
--------------------------------------------------------------------------------
1 | {
2 | "cancel": "Cancel",
3 | "confirm_password": "Confirm Password",
4 | "email": "Email",
5 | "error_alert_text": "Something went wrong! Please try again.",
6 | "error_alert_title": "Oops...",
7 | "forgot_password": "Forgot Your Password?",
8 | "go_home": "Go Home",
9 | "home": "Home",
10 | "info_updated": "Your info has been updated!",
11 | "login": "Log In",
12 | "login_with": "Login with",
13 | "logout": "Logout",
14 | "menu": "Menu",
15 | "name": "Name",
16 | "new_password": "New Password",
17 | "ok": "Ok",
18 | "page_not_found": "Page Not Found",
19 | "password": "Password",
20 | "password_updated": "Your password has been updated!",
21 | "profile": "Profile",
22 | "register": "Register",
23 | "register_with": "Register with",
24 | "remember_me": "Remember Me",
25 | "reset_password": "Reset Password",
26 | "send_password_reset_link": "Send Password Reset Link",
27 | "settings": "Settings",
28 | "toggle_navigation": "Toggle navigation",
29 | "token_expired_alert_text": "Please log in again to continue.",
30 | "token_expired_alert_title": "Session Expired!",
31 | "update": "Update",
32 | "you_are_logged_in": "You are logged in!",
33 | "your_info": "Your Info",
34 | "your_password": "Your Password"
35 | }
36 |
--------------------------------------------------------------------------------
/client/lang/es.json:
--------------------------------------------------------------------------------
1 | {
2 | "ok": "De Acuerdo",
3 | "cancel": "Cancelar",
4 | "error_alert_title": "Ha ocurrido un problema",
5 | "error_alert_text": "¡Algo salió mal! Inténtalo de nuevo.",
6 | "token_expired_alert_title": "!Sesión Expirada!",
7 | "token_expired_alert_text": "Por favor inicie sesión de nuevo para continuar.",
8 | "login": "Iniciar Sesión",
9 | "register": "Registro",
10 | "page_not_found": "Página No Encontrada",
11 | "go_home": "Ir a Inicio",
12 | "logout": "Cerrar Sesión",
13 | "email": "Correo Electrónico",
14 | "remember_me": "Recuérdame",
15 | "password": "Contraseña",
16 | "forgot_password": "¿Olvidaste tu contraseña?",
17 | "confirm_password": "Confirmar Contraseña",
18 | "name": "Nombre",
19 | "toggle_navigation": "Cambiar Navegación",
20 | "home": "Inicio",
21 | "you_are_logged_in": "¡Has iniciado sesión!",
22 | "reset_password": "Restablecer la contraseña",
23 | "send_password_reset_link": "Enviar Enlace de Restablecimiento de Contraseña",
24 | "settings": "Configuraciones",
25 | "profile": "Perfil",
26 | "your_info": "Tu Información",
27 | "info_updated": "¡Tu información ha sido actualizada!",
28 | "update": "Actualizar",
29 | "your_password": "Tu Contraseña",
30 | "password_updated": "¡Tu contraseña ha sido actualizada!",
31 | "new_password": "Nueva Contraseña",
32 | "menu": "Menú",
33 | "login_with": "Iniciar Sesión con",
34 | "register_with": "Registro con"
35 | }
36 |
--------------------------------------------------------------------------------
/client/lang/zh-CN.json:
--------------------------------------------------------------------------------
1 | {
2 | "ok": "确定",
3 | "cancel": "取消",
4 | "error_alert_title": "错误...",
5 | "error_alert_text": "遇到一些错误,请稍后重试~",
6 | "token_expired_alert_title": "验证过期!",
7 | "token_expired_alert_text": "请稍后重新登录系统",
8 | "login": "登录",
9 | "register": "注册",
10 | "page_not_found": "页面不存在",
11 | "go_home": "返回首页",
12 | "logout": "退出",
13 | "email": "邮箱",
14 | "remember_me": "记住我",
15 | "password": "密码",
16 | "forgot_password": "忘记密码?",
17 | "confirm_password": "重复密码",
18 | "name": "用户名",
19 | "toggle_navigation": "切换导航",
20 | "home": "首页",
21 | "you_are_logged_in": "您已经登录!",
22 | "reset_password": "重置密码",
23 | "send_password_reset_link": "发送重置链接",
24 | "settings": "设置",
25 | "profile": "个人设置",
26 | "your_info": "您的个人信息",
27 | "info_updated": "您的个人信息已经更改!",
28 | "update": "更新",
29 | "your_password": "您的密码",
30 | "password_updated": "您的密码已经更新!",
31 | "new_password": "新密码",
32 | "menu": "メニュー",
33 | "login_with": "登录",
34 | "register_with": "注册"
35 | }
36 |
--------------------------------------------------------------------------------
/client/layouts/default.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
24 |
25 |
--------------------------------------------------------------------------------
/client/layouts/simple.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/client/middleware/auth.js:
--------------------------------------------------------------------------------
1 | export default ({ store, redirect }) => {
2 | if (!store.getters['auth/check']) {
3 | return redirect('/login')
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/client/middleware/check-auth.js:
--------------------------------------------------------------------------------
1 | import axios from 'axios'
2 |
3 | export default async ({ store, req }) => {
4 | const token = store.getters['auth/token']
5 |
6 | if (process.server) {
7 | if (token) {
8 | axios.defaults.headers.common['Authorization'] = `Bearer ${token}`
9 | } else {
10 | delete axios.defaults.headers.common['Authorization']
11 | }
12 | }
13 |
14 | if (!store.getters['auth/check'] && token) {
15 | await store.dispatch('auth/fetchUser')
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/client/middleware/guest.js:
--------------------------------------------------------------------------------
1 | export default ({ store, redirect }) => {
2 | if (store.getters['auth/check']) {
3 | return redirect('/')
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/client/middleware/locale.js:
--------------------------------------------------------------------------------
1 | import axios from 'axios'
2 | import { loadMessages } from '~/plugins/i18n'
3 |
4 | export default async ({ store }) => {
5 | if (process.server) {
6 | const locale = store.getters['lang/locale']
7 | if (locale) {
8 | axios.defaults.headers.common['Accept-Language'] = locale
9 | }
10 | }
11 |
12 | await loadMessages(store.getters['lang/locale'])
13 | }
14 |
--------------------------------------------------------------------------------
/client/modules/spa.js:
--------------------------------------------------------------------------------
1 | const path = require('path')
2 | const fs = require('fs-extra')
3 |
4 | /**
5 | * Copy dist files to public/ in spa mode.
6 | */
7 | module.exports = function () {
8 | if (this.options.dev || this.options.mode !== 'spa') {
9 | return
10 | }
11 |
12 | const publicDir = path.resolve('./public' + this.options.build.publicPath)
13 |
14 | this.nuxt.hook('generate:done', async () => {
15 | const { html } = await this.nuxt.renderer.renderRoute('/', { url: '/' })
16 |
17 | fs.removeSync(publicDir)
18 |
19 | fs.copySync('./dist' + this.options.build.publicPath, publicDir)
20 | // fs.copy('./dist/200.html', publicDir + '/index.html')
21 | fs.writeFileSync(publicDir + '/index.html', html)
22 |
23 | try {
24 | // fs.removeSync(path.resolve('./dist'))
25 | } catch (e) {}
26 | })
27 | }
28 |
--------------------------------------------------------------------------------
/client/nuxt.config.js:
--------------------------------------------------------------------------------
1 | require('dotenv').config()
2 |
3 | module.exports = {
4 | mode: 'spa',
5 |
6 | srcDir: __dirname,
7 |
8 | env: {
9 | apiUrl: process.env.APP_URL || 'http://api.laravel-nuxt.test',
10 | appName: process.env.APP_NAME || 'Laravel-Nuxt',
11 | appLocale: process.env.APP_LOCALE || 'en',
12 | githubAuth: !!process.env.GITHUB_CLIENT_ID
13 | },
14 |
15 | head: {
16 | title: process.env.APP_NAME,
17 | titleTemplate: '%s - ' + process.env.APP_NAME,
18 | meta: [
19 | { charset: 'utf-8' },
20 | { name: 'viewport', content: 'width=device-width, initial-scale=1' },
21 | { hid: 'description', name: 'description', content: 'Nuxt.js project' }
22 | ],
23 | link: [
24 | { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
25 | ]
26 | },
27 |
28 | loading: { color: '#007bff' },
29 |
30 | router: {
31 | middleware: ['locale', 'check-auth']
32 | },
33 |
34 | css: ['@/assets/css/main.css'],
35 |
36 | plugins: [
37 | '~components/global',
38 | '~plugins/i18n',
39 | '~plugins/axios',
40 | '~plugins/vue-tailwind',
41 | '~plugins/nuxt-client-init',
42 | ],
43 |
44 | modules: [
45 | '@nuxtjs/router',
46 | '~/modules/spa'
47 | ],
48 |
49 | buildDir: 'client/.nuxt',
50 |
51 | build: {
52 | extractCSS: true,
53 | babel: {
54 | 'plugins': [
55 | 'babel-plugin-async-import'
56 | ]
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/client/pages/auth/login.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
74 |
75 |
76 |
77 |
121 |
--------------------------------------------------------------------------------
/client/pages/auth/password/email.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
37 |
38 |
39 |
40 |
66 |
--------------------------------------------------------------------------------
/client/pages/auth/password/reset.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
65 |
66 |
67 |
68 |
103 |
--------------------------------------------------------------------------------
/client/pages/auth/register.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
83 |
84 |
85 |
86 |
129 |
--------------------------------------------------------------------------------
/client/pages/home.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 | {{ $t('you_are_logged_in') }}
7 |
8 |
9 |
10 |
11 |
20 |
--------------------------------------------------------------------------------
/client/pages/settings/index.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 | -
13 |
18 | {{ tab.name }}
19 |
20 |
21 |
22 |
23 |
24 |
25 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
57 |
--------------------------------------------------------------------------------
/client/pages/settings/password.vue:
--------------------------------------------------------------------------------
1 |
2 |
51 |
52 |
53 |
80 |
--------------------------------------------------------------------------------
/client/pages/settings/profile.vue:
--------------------------------------------------------------------------------
1 |
2 |
5 |
49 |
50 |
51 |
52 |
91 |
--------------------------------------------------------------------------------
/client/pages/welcome.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {{ title }}
6 |
7 |
8 |
25 |
26 |
27 |
28 |
29 |
46 |
--------------------------------------------------------------------------------
/client/plugins/axios.js:
--------------------------------------------------------------------------------
1 | import axios from 'axios'
2 | import swal from 'sweetalert2'
3 |
4 | process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
5 |
6 | export default ({ app, store, redirect }) => {
7 | axios.defaults.baseURL = process.env.apiUrl
8 |
9 | if (process.server) {
10 | return
11 | }
12 |
13 | // Request interceptor
14 | axios.interceptors.request.use(request => {
15 | request.baseURL = process.env.apiUrl
16 |
17 | const token = store.getters['auth/token']
18 |
19 | if (token) {
20 | request.headers.common['Authorization'] = `Bearer ${token}`
21 | }
22 |
23 | const locale = store.getters['lang/locale']
24 | if (locale) {
25 | request.headers.common['Accept-Language'] = locale
26 | }
27 |
28 | return request
29 | })
30 |
31 | // Response interceptor
32 | axios.interceptors.response.use(response => response, error => {
33 | const { status } = error.response || {}
34 |
35 | if (status >= 500) {
36 | swal({
37 | type: 'error',
38 | title: app.i18n.t('error_alert_title'),
39 | text: app.i18n.t('error_alert_text'),
40 | reverseButtons: true,
41 | confirmButtonText: app.i18n.t('ok'),
42 | cancelButtonText: app.i18n.t('cancel')
43 | })
44 | }
45 |
46 | if (status === 401 && store.getters['auth/check']) {
47 | swal({
48 | type: 'warning',
49 | title: app.i18n.t('token_expired_alert_title'),
50 | text: app.i18n.t('token_expired_alert_text'),
51 | reverseButtons: true,
52 | confirmButtonText: app.i18n.t('ok'),
53 | cancelButtonText: app.i18n.t('cancel')
54 | }).then(() => {
55 | store.commit('auth/LOGOUT')
56 |
57 | redirect({ name: 'login' })
58 | })
59 | }
60 |
61 | return Promise.reject(error)
62 | })
63 | }
64 |
--------------------------------------------------------------------------------
/client/plugins/i18n.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import VueI18n from 'vue-i18n'
3 |
4 | Vue.use(VueI18n)
5 |
6 | const i18n = new VueI18n({
7 | locale: 'en',
8 | messages: {}
9 | })
10 |
11 | export default async ({ app, store }) => {
12 | if (process.client) {
13 | await loadMessages(store.getters['lang/locale'])
14 | }
15 |
16 | app.i18n = i18n
17 | }
18 |
19 | /**
20 | * @param {String} locale
21 | */
22 | export async function loadMessages (locale) {
23 | if (Object.keys(i18n.getLocaleMessage(locale)).length === 0) {
24 | const messages = await import(/* webpackChunkName: "lang-[request]" */ `~/lang/${locale}`)
25 | i18n.setLocaleMessage(locale, messages)
26 | }
27 |
28 | if (i18n.locale !== locale) {
29 | i18n.locale = locale
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/client/plugins/nuxt-client-init.js:
--------------------------------------------------------------------------------
1 | export default (ctx) => {
2 | ctx.store.dispatch('nuxtClientInit', ctx)
3 | }
4 |
--------------------------------------------------------------------------------
/client/plugins/vue-tailwind.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import VueTailwind from 'vue-tailwind'
3 |
4 | Vue.use(VueTailwind)
5 |
--------------------------------------------------------------------------------
/client/router.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import Router from 'vue-router'
3 | import { scrollBehavior } from '~/utils'
4 |
5 | Vue.use(Router)
6 |
7 | const Home = () => import('~/pages/home').then(m => m.default || m)
8 | const Welcome = () => import('~/pages/welcome').then(m => m.default || m)
9 |
10 | const Login = () => import('~/pages/auth/login').then(m => m.default || m)
11 | const Register = () => import('~/pages/auth/register').then(m => m.default || m)
12 | const PasswordReset = () => import('~/pages/auth/password/reset').then(m => m.default || m)
13 | const PasswordRequest = () => import('~/pages/auth/password/email').then(m => m.default || m)
14 |
15 | const Settings = () => import('~/pages/settings/index').then(m => m.default || m)
16 | const SettingsProfile = () => import('~/pages/settings/profile').then(m => m.default || m)
17 | const SettingsPassword = () => import('~/pages/settings/password').then(m => m.default || m)
18 |
19 | const routes = [
20 | { path: '/', name: 'welcome', component: Welcome },
21 | { path: '/home', name: 'home', component: Home },
22 |
23 | { path: '/login', name: 'login', component: Login },
24 | { path: '/register', name: 'register', component: Register },
25 | { path: '/password/reset', name: 'password.request', component: PasswordRequest },
26 | { path: '/password/reset/:token', name: 'password.reset', component: PasswordReset },
27 |
28 | { path: '/settings',
29 | component: Settings,
30 | children: [
31 | { path: '', redirect: { name: 'settings.profile' } },
32 | { path: 'profile', name: 'settings.profile', component: SettingsProfile },
33 | { path: 'password', name: 'settings.password', component: SettingsPassword }
34 | ] }
35 | ]
36 |
37 | export function createRouter () {
38 | return new Router({
39 | routes,
40 | scrollBehavior,
41 | mode: 'history'
42 | })
43 | }
44 |
--------------------------------------------------------------------------------
/client/static/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alfonsobries/laravel-nuxt-tailwind/aaeb102c3a7500e0cabe9c72a2f6589bb5bda894/client/static/favicon.ico
--------------------------------------------------------------------------------
/client/store/auth.js:
--------------------------------------------------------------------------------
1 | import axios from 'axios'
2 | import Cookies from 'js-cookie'
3 |
4 | // state
5 | export const state = () => ({
6 | user: null,
7 | token: null
8 | })
9 |
10 | // getters
11 | export const getters = {
12 | user: state => state.user,
13 | token: state => state.token,
14 | check: state => state.user !== null
15 | }
16 |
17 | // mutations
18 | export const mutations = {
19 | SET_TOKEN (state, token) {
20 | state.token = token
21 | },
22 |
23 | FETCH_USER_SUCCESS (state, user) {
24 | state.user = user
25 | },
26 |
27 | FETCH_USER_FAILURE (state) {
28 | state.token = null
29 | },
30 |
31 | LOGOUT (state) {
32 | state.user = null
33 | state.token = null
34 | },
35 |
36 | UPDATE_USER (state, { user }) {
37 | state.user = user
38 | }
39 | }
40 |
41 | // actions
42 | export const actions = {
43 | saveToken ({ commit, dispatch }, { token, remember }) {
44 | commit('SET_TOKEN', token)
45 |
46 | Cookies.set('token', token, { expires: remember ? 365 : null })
47 | },
48 |
49 | async fetchUser ({ commit }) {
50 | try {
51 | const { data } = await axios.get('/user')
52 |
53 | commit('FETCH_USER_SUCCESS', data)
54 | } catch (e) {
55 | Cookies.remove('token')
56 |
57 | commit('FETCH_USER_FAILURE')
58 | }
59 | },
60 |
61 | updateUser ({ commit }, payload) {
62 | commit('UPDATE_USER', payload)
63 | },
64 |
65 | async logout ({ commit }) {
66 | try {
67 | await axios.post('/logout')
68 | } catch (e) { }
69 |
70 | Cookies.remove('token')
71 |
72 | commit('LOGOUT')
73 | },
74 |
75 | async fetchOauthUrl (ctx, { provider }) {
76 | const { data } = await axios.post(`/oauth/${provider}`)
77 |
78 | return data.url
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/client/store/index.js:
--------------------------------------------------------------------------------
1 | import Cookies from 'js-cookie'
2 | import { cookieFromRequest } from '~/utils'
3 |
4 | export const actions = {
5 | nuxtServerInit ({ commit }, { req }) {
6 | const token = cookieFromRequest(req, 'token')
7 | if (token) {
8 | commit('auth/SET_TOKEN', token)
9 | }
10 |
11 | const locale = cookieFromRequest(req, 'locale')
12 | if (locale) {
13 | commit('lang/SET_LOCALE', { locale })
14 | }
15 | },
16 |
17 | nuxtClientInit ({ commit }) {
18 | const token = Cookies.get('token')
19 | if (token) {
20 | commit('auth/SET_TOKEN', token)
21 | }
22 |
23 | const locale = Cookies.get('locale')
24 | if (locale) {
25 | commit('lang/SET_LOCALE', { locale })
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/client/store/lang.js:
--------------------------------------------------------------------------------
1 | import Cookies from 'js-cookie'
2 |
3 | // state
4 | export const state = () => ({
5 | locale: process.env.appLocale,
6 | locales: {
7 | 'en': 'EN',
8 | 'zh-CN': '中文',
9 | 'es': 'ES'
10 | }
11 | })
12 |
13 | // getters
14 | export const getters = {
15 | locale: state => state.locale,
16 | locales: state => state.locales
17 | }
18 |
19 | // mutations
20 | export const mutations = {
21 | SET_LOCALE (state, { locale }) {
22 | state.locale = locale
23 | }
24 | }
25 |
26 | // actions
27 | export const actions = {
28 | setLocale ({ commit }, { locale }) {
29 | commit('SET_LOCALE', { locale })
30 |
31 | Cookies.set('locale', locale, { expires: 365 })
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/client/utils/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Get cookie from request.
3 | *
4 | * @param {Object} req
5 | * @param {String} key
6 | * @return {String|undefined}
7 | */
8 | export function cookieFromRequest (req, key) {
9 | if (!req.headers.cookie) {
10 | return
11 | }
12 |
13 | const cookie = req.headers.cookie.split(';').find(
14 | c => c.trim().startsWith(`${key}=`)
15 | )
16 |
17 | if (cookie) {
18 | return cookie.split('=')[1]
19 | }
20 | }
21 |
22 | /**
23 | * https://router.vuejs.org/en/advanced/scroll-behavior.html
24 | */
25 | export function scrollBehavior (to, from, savedPosition) {
26 | if (savedPosition) {
27 | return savedPosition
28 | }
29 |
30 | let position = {}
31 |
32 | if (to.matched.length < 2) {
33 | position = { x: 0, y: 0 }
34 | } else if (to.matched.some(r => r.components.default.options.scrollToTop)) {
35 | position = { x: 0, y: 0 }
36 | } if (to.hash) {
37 | position = { selector: to.hash }
38 | }
39 |
40 | return position
41 | }
42 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "alfonsobries/laravel-nuxt",
3 | "description": "A Laravel-Nuxt-Tailwind starter project template.",
4 | "keywords": ["laravel", "nuxt", "vue", "spa", "tailwind"],
5 | "license": "MIT",
6 | "type": "project",
7 | "require": {
8 | "php": "^7.1.3",
9 | "doctrine/dbal": "^2.9",
10 | "fideloper/proxy": "^4.0",
11 | "laravel/framework": "5.8.*",
12 | "laravel/socialite": "^4.1",
13 | "laravel/tinker": "~1.0",
14 | "spatie/laravel-cors": "^1.0",
15 | "tymon/jwt-auth": "^1.0.0-rc.2"
16 | },
17 | "require-dev": {
18 | "beyondcode/laravel-dump-server": "^1.0",
19 | "filp/whoops": "^2.0",
20 | "fzaninotto/faker": "^1.4",
21 | "laravel/dusk": "^3.0",
22 | "mockery/mockery": "^1.0",
23 | "nunomaduro/collision": "^3.0",
24 | "phpunit/phpunit": "^7.5"
25 | },
26 | "config": {
27 | "optimize-autoloader": true,
28 | "preferred-install": "dist",
29 | "sort-packages": true
30 | },
31 | "extra": {
32 | "laravel": {
33 | "dont-discover": [
34 | "laravel/dusk"
35 | ]
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 | "@php artisan jwt:secret --force"
65 | ]
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/config/app.php:
--------------------------------------------------------------------------------
1 | env('APP_NAME', 'Laravel'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Application Environment
21 | |--------------------------------------------------------------------------
22 | |
23 | | This value determines the "environment" your application is currently
24 | | running in. This may determine how you prefer to configure various
25 | | services your application utilizes. Set this in your ".env" file.
26 | |
27 | */
28 |
29 | 'env' => env('APP_ENV', 'production'),
30 |
31 | /*
32 | |--------------------------------------------------------------------------
33 | | Application Debug Mode
34 | |--------------------------------------------------------------------------
35 | |
36 | | When your application is in debug mode, detailed error messages with
37 | | stack traces will be shown on every error that occurs within your
38 | | application. If disabled, a simple generic error page is shown.
39 | |
40 | */
41 |
42 | 'debug' => env('APP_DEBUG', false),
43 |
44 | /*
45 | |--------------------------------------------------------------------------
46 | | Application URL
47 | |--------------------------------------------------------------------------
48 | |
49 | | This URL is used by the console to properly generate URLs when using
50 | | the Artisan command line tool. You should set this to the root of
51 | | your application so that it is used when running Artisan tasks.
52 | |
53 | */
54 |
55 | 'url' => env('APP_URL', 'http://localhost'),
56 |
57 | 'client_url' => env('CLIENT_URL', 'http://localhost:3000'),
58 |
59 | /*
60 | |--------------------------------------------------------------------------
61 | | Application Timezone
62 | |--------------------------------------------------------------------------
63 | |
64 | | Here you may specify the default timezone for your application, which
65 | | will be used by the PHP date and date-time functions. We have gone
66 | | ahead and set this to a sensible default for you out of the box.
67 | |
68 | */
69 |
70 | 'timezone' => 'UTC',
71 |
72 | /*
73 | |--------------------------------------------------------------------------
74 | | Application Locale Configuration
75 | |--------------------------------------------------------------------------
76 | |
77 | | The application locale determines the default locale that will be used
78 | | by the translation service provider. You are free to set this value
79 | | to any of the locales which will be supported by the application.
80 | |
81 | */
82 |
83 | 'locale' => 'en',
84 |
85 | 'locales' => [
86 | 'en' => 'EN',
87 | 'zh-CN' => '中文',
88 | 'es' => 'ES',
89 | ],
90 |
91 | /*
92 | |--------------------------------------------------------------------------
93 | | Application Fallback Locale
94 | |--------------------------------------------------------------------------
95 | |
96 | | The fallback locale determines the locale to use when the current one
97 | | is not available. You may change the value to correspond to any of
98 | | the language folders that are provided through your application.
99 | |
100 | */
101 |
102 | 'fallback_locale' => 'en',
103 |
104 | /*
105 | |--------------------------------------------------------------------------
106 | | Encryption Key
107 | |--------------------------------------------------------------------------
108 | |
109 | | This key is used by the Illuminate encrypter service and should be set
110 | | to a random, 32 character string, otherwise these encrypted strings
111 | | will not be safe. Please do this before deploying an application!
112 | |
113 | */
114 |
115 | 'key' => env('APP_KEY'),
116 |
117 | 'cipher' => 'AES-256-CBC',
118 |
119 | /*
120 | |--------------------------------------------------------------------------
121 | | Autoloaded Service Providers
122 | |--------------------------------------------------------------------------
123 | |
124 | | The service providers listed here will be automatically loaded on the
125 | | request to your application. Feel free to add your own services to
126 | | this array to grant expanded functionality to your applications.
127 | |
128 | */
129 |
130 | 'providers' => [
131 |
132 | /*
133 | * Laravel Framework Service Providers...
134 | */
135 | Illuminate\Auth\AuthServiceProvider::class,
136 | Illuminate\Broadcasting\BroadcastServiceProvider::class,
137 | Illuminate\Bus\BusServiceProvider::class,
138 | Illuminate\Cache\CacheServiceProvider::class,
139 | Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
140 | Illuminate\Cookie\CookieServiceProvider::class,
141 | Illuminate\Database\DatabaseServiceProvider::class,
142 | Illuminate\Encryption\EncryptionServiceProvider::class,
143 | Illuminate\Filesystem\FilesystemServiceProvider::class,
144 | Illuminate\Foundation\Providers\FoundationServiceProvider::class,
145 | Illuminate\Hashing\HashServiceProvider::class,
146 | Illuminate\Mail\MailServiceProvider::class,
147 | Illuminate\Notifications\NotificationServiceProvider::class,
148 | Illuminate\Pagination\PaginationServiceProvider::class,
149 | Illuminate\Pipeline\PipelineServiceProvider::class,
150 | Illuminate\Queue\QueueServiceProvider::class,
151 | Illuminate\Redis\RedisServiceProvider::class,
152 | Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
153 | Illuminate\Session\SessionServiceProvider::class,
154 | Illuminate\Translation\TranslationServiceProvider::class,
155 | Illuminate\Validation\ValidationServiceProvider::class,
156 | Illuminate\View\ViewServiceProvider::class,
157 |
158 | /*
159 | * Package Service Providers...
160 | */
161 |
162 | /*
163 | * Application Service Providers...
164 | */
165 | App\Providers\AppServiceProvider::class,
166 | App\Providers\AuthServiceProvider::class,
167 | // App\Providers\BroadcastServiceProvider::class,
168 | App\Providers\EventServiceProvider::class,
169 | App\Providers\RouteServiceProvider::class,
170 |
171 | ],
172 |
173 | /*
174 | |--------------------------------------------------------------------------
175 | | Class Aliases
176 | |--------------------------------------------------------------------------
177 | |
178 | | This array of class aliases will be registered when this application
179 | | is started. However, feel free to register as many as you wish as
180 | | the aliases are "lazy" loaded so they don't hinder performance.
181 | |
182 | */
183 |
184 | 'aliases' => [
185 |
186 | 'App' => Illuminate\Support\Facades\App::class,
187 | 'Artisan' => Illuminate\Support\Facades\Artisan::class,
188 | 'Auth' => Illuminate\Support\Facades\Auth::class,
189 | 'Blade' => Illuminate\Support\Facades\Blade::class,
190 | 'Broadcast' => Illuminate\Support\Facades\Broadcast::class,
191 | 'Bus' => Illuminate\Support\Facades\Bus::class,
192 | 'Cache' => Illuminate\Support\Facades\Cache::class,
193 | 'Config' => Illuminate\Support\Facades\Config::class,
194 | 'Cookie' => Illuminate\Support\Facades\Cookie::class,
195 | 'Crypt' => Illuminate\Support\Facades\Crypt::class,
196 | 'DB' => Illuminate\Support\Facades\DB::class,
197 | 'Eloquent' => Illuminate\Database\Eloquent\Model::class,
198 | 'Event' => Illuminate\Support\Facades\Event::class,
199 | 'File' => Illuminate\Support\Facades\File::class,
200 | 'Gate' => Illuminate\Support\Facades\Gate::class,
201 | 'Hash' => Illuminate\Support\Facades\Hash::class,
202 | 'Lang' => Illuminate\Support\Facades\Lang::class,
203 | 'Log' => Illuminate\Support\Facades\Log::class,
204 | 'Mail' => Illuminate\Support\Facades\Mail::class,
205 | 'Notification' => Illuminate\Support\Facades\Notification::class,
206 | 'Password' => Illuminate\Support\Facades\Password::class,
207 | 'Queue' => Illuminate\Support\Facades\Queue::class,
208 | 'Redirect' => Illuminate\Support\Facades\Redirect::class,
209 | 'Redis' => Illuminate\Support\Facades\Redis::class,
210 | 'Request' => Illuminate\Support\Facades\Request::class,
211 | 'Response' => Illuminate\Support\Facades\Response::class,
212 | 'Route' => Illuminate\Support\Facades\Route::class,
213 | 'Schema' => Illuminate\Support\Facades\Schema::class,
214 | 'Session' => Illuminate\Support\Facades\Session::class,
215 | 'Storage' => Illuminate\Support\Facades\Storage::class,
216 | 'URL' => Illuminate\Support\Facades\URL::class,
217 | 'Validator' => Illuminate\Support\Facades\Validator::class,
218 | 'View' => Illuminate\Support\Facades\View::class,
219 |
220 | ],
221 |
222 | ];
223 |
--------------------------------------------------------------------------------
/config/auth.php:
--------------------------------------------------------------------------------
1 | [
17 | 'guard' => 'api',
18 | 'passwords' => 'users',
19 | ],
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | Authentication Guards
24 | |--------------------------------------------------------------------------
25 | |
26 | | Next, you may define every authentication guard for your application.
27 | | Of course, a great default configuration has been defined for you
28 | | here which uses session storage and the Eloquent user provider.
29 | |
30 | | All authentication drivers have a user provider. This defines how the
31 | | users are actually retrieved out of your database or other storage
32 | | mechanisms used by this application to persist your user's data.
33 | |
34 | | Supported: "session", "token"
35 | |
36 | */
37 |
38 | 'guards' => [
39 | 'web' => [
40 | 'driver' => 'session',
41 | 'provider' => 'users',
42 | ],
43 |
44 | 'api' => [
45 | 'driver' => 'jwt',
46 | 'provider' => 'users',
47 | ],
48 | ],
49 |
50 | /*
51 | |--------------------------------------------------------------------------
52 | | User Providers
53 | |--------------------------------------------------------------------------
54 | |
55 | | All authentication drivers have a user provider. This defines how the
56 | | users are actually retrieved out of your database or other storage
57 | | mechanisms used by this application to persist your user's data.
58 | |
59 | | If you have multiple user tables or models you may configure multiple
60 | | sources which represent each model / table. These sources may then
61 | | be assigned to any extra authentication guards you have defined.
62 | |
63 | | Supported: "database", "eloquent"
64 | |
65 | */
66 |
67 | 'providers' => [
68 | 'users' => [
69 | 'driver' => 'eloquent',
70 | 'model' => App\Models\User::class,
71 | ],
72 |
73 | // 'users' => [
74 | // 'driver' => 'database',
75 | // 'table' => 'users',
76 | // ],
77 | ],
78 |
79 | /*
80 | |--------------------------------------------------------------------------
81 | | Resetting Passwords
82 | |--------------------------------------------------------------------------
83 | |
84 | | You may specify multiple password reset configurations if you have more
85 | | than one user table or model in the application and you want to have
86 | | separate password reset settings based on the specific user types.
87 | |
88 | | The expire time is the number of minutes that the reset token should be
89 | | considered valid. This security feature keeps tokens short-lived so
90 | | they have less time to be guessed. You may change this as needed.
91 | |
92 | */
93 |
94 | 'passwords' => [
95 | 'users' => [
96 | 'provider' => 'users',
97 | 'table' => 'password_resets',
98 | 'expire' => 60,
99 | ],
100 | ],
101 |
102 | ];
103 |
--------------------------------------------------------------------------------
/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 | //
40 | ],
41 | ],
42 |
43 | 'redis' => [
44 | 'driver' => 'redis',
45 | 'connection' => 'default',
46 | ],
47 |
48 | 'log' => [
49 | 'driver' => 'log',
50 | ],
51 |
52 | 'null' => [
53 | 'driver' => 'null',
54 | ],
55 |
56 | ],
57 |
58 | ];
59 |
--------------------------------------------------------------------------------
/config/cache.php:
--------------------------------------------------------------------------------
1 | env('CACHE_DRIVER', 'file'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Cache Stores
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may define all of the cache "stores" for your application as
26 | | well as their drivers. You may even define multiple stores for the
27 | | same cache driver to group types of items stored in your caches.
28 | |
29 | */
30 |
31 | 'stores' => [
32 |
33 | 'apc' => [
34 | 'driver' => 'apc',
35 | ],
36 |
37 | 'array' => [
38 | 'driver' => 'array',
39 | ],
40 |
41 | 'database' => [
42 | 'driver' => 'database',
43 | 'table' => 'cache',
44 | 'connection' => null,
45 | ],
46 |
47 | 'file' => [
48 | 'driver' => 'file',
49 | 'path' => storage_path('framework/cache/data'),
50 | ],
51 |
52 | 'memcached' => [
53 | 'driver' => 'memcached',
54 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
55 | 'sasl' => [
56 | env('MEMCACHED_USERNAME'),
57 | env('MEMCACHED_PASSWORD'),
58 | ],
59 | 'options' => [
60 | // Memcached::OPT_CONNECT_TIMEOUT => 2000,
61 | ],
62 | 'servers' => [
63 | [
64 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'),
65 | 'port' => env('MEMCACHED_PORT', 11211),
66 | 'weight' => 100,
67 | ],
68 | ],
69 | ],
70 |
71 | 'redis' => [
72 | 'driver' => 'redis',
73 | 'connection' => 'default',
74 | ],
75 |
76 | ],
77 |
78 | /*
79 | |--------------------------------------------------------------------------
80 | | Cache Key Prefix
81 | |--------------------------------------------------------------------------
82 | |
83 | | When utilizing a RAM based store such as APC or Memcached, there might
84 | | be other applications utilizing the same cache. So, we'll specify a
85 | | value to get prefixed to all our keys so we can avoid collisions.
86 | |
87 | */
88 |
89 | 'prefix' => 'laravel',
90 |
91 | ];
92 |
--------------------------------------------------------------------------------
/config/database.php:
--------------------------------------------------------------------------------
1 | env('DB_CONNECTION', 'mysql'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Database Connections
21 | |--------------------------------------------------------------------------
22 | |
23 | | Here are each of the database connections setup for your application.
24 | | Of course, examples of configuring each database platform that is
25 | | supported by Laravel is shown below to make development simple.
26 | |
27 | |
28 | | All database work in Laravel is done through the PHP PDO facilities
29 | | so make sure you have the driver for your particular database of
30 | | choice installed on your machine before you begin development.
31 | |
32 | */
33 |
34 | 'connections' => [
35 |
36 | 'sqlite' => [
37 | 'driver' => 'sqlite',
38 | 'database' => env('DB_DATABASE', database_path('database.sqlite')),
39 | 'prefix' => '',
40 | ],
41 |
42 | 'mysql' => [
43 | 'driver' => 'mysql',
44 | 'host' => env('DB_HOST', '127.0.0.1'),
45 | 'port' => env('DB_PORT', '3306'),
46 | 'database' => env('DB_DATABASE', 'forge'),
47 | 'username' => env('DB_USERNAME', 'forge'),
48 | 'password' => env('DB_PASSWORD', ''),
49 | 'unix_socket' => env('DB_SOCKET', ''),
50 | 'charset' => 'utf8mb4',
51 | 'collation' => 'utf8mb4_unicode_ci',
52 | 'prefix' => '',
53 | 'strict' => true,
54 | 'engine' => null,
55 | ],
56 |
57 | 'pgsql' => [
58 | 'driver' => 'pgsql',
59 | 'host' => env('DB_HOST', '127.0.0.1'),
60 | 'port' => env('DB_PORT', '5432'),
61 | 'database' => env('DB_DATABASE', 'forge'),
62 | 'username' => env('DB_USERNAME', 'forge'),
63 | 'password' => env('DB_PASSWORD', ''),
64 | 'charset' => 'utf8',
65 | 'prefix' => '',
66 | 'schema' => 'public',
67 | 'sslmode' => 'prefer',
68 | ],
69 |
70 | 'sqlsrv' => [
71 | 'driver' => 'sqlsrv',
72 | 'host' => env('DB_HOST', 'localhost'),
73 | 'port' => env('DB_PORT', '1433'),
74 | 'database' => env('DB_DATABASE', 'forge'),
75 | 'username' => env('DB_USERNAME', 'forge'),
76 | 'password' => env('DB_PASSWORD', ''),
77 | 'charset' => 'utf8',
78 | 'prefix' => '',
79 | ],
80 |
81 | ],
82 |
83 | /*
84 | |--------------------------------------------------------------------------
85 | | Migration Repository Table
86 | |--------------------------------------------------------------------------
87 | |
88 | | This table keeps track of all the migrations that have already run for
89 | | your application. Using this information, we can determine which of
90 | | the migrations on disk haven't actually been run in the database.
91 | |
92 | */
93 |
94 | 'migrations' => 'migrations',
95 |
96 | /*
97 | |--------------------------------------------------------------------------
98 | | Redis Databases
99 | |--------------------------------------------------------------------------
100 | |
101 | | Redis is an open source, fast, and advanced key-value store that also
102 | | provides a richer set of commands than a typical key-value systems
103 | | such as APC or Memcached. Laravel makes it easy to dig right in.
104 | |
105 | */
106 |
107 | 'redis' => [
108 |
109 | 'client' => 'predis',
110 |
111 | 'default' => [
112 | 'host' => env('REDIS_HOST', '127.0.0.1'),
113 | 'password' => env('REDIS_PASSWORD', null),
114 | 'port' => env('REDIS_PORT', 6379),
115 | 'database' => 0,
116 | ],
117 |
118 | ],
119 |
120 | ];
121 |
--------------------------------------------------------------------------------
/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", "s3", "rackspace"
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_KEY'),
61 | 'secret' => env('AWS_SECRET'),
62 | 'region' => env('AWS_REGION'),
63 | 'bucket' => env('AWS_BUCKET'),
64 | ],
65 |
66 | ],
67 |
68 | ];
69 |
--------------------------------------------------------------------------------
/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/logging.php:
--------------------------------------------------------------------------------
1 | env('LOG_CHANNEL', 'stack'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Log Channels
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may configure the log channels for your application. Out of
26 | | the box, Laravel uses the Monolog PHP logging library. This gives
27 | | you a variety of powerful log handlers / formatters to utilize.
28 | |
29 | | Available Drivers: "single", "daily", "slack", "syslog",
30 | | "errorlog", "monolog",
31 | | "custom", "stack"
32 | |
33 | */
34 |
35 | 'channels' => [
36 | 'stack' => [
37 | 'driver' => 'stack',
38 | 'channels' => ['single'],
39 | ],
40 |
41 | 'single' => [
42 | 'driver' => 'single',
43 | 'path' => storage_path('logs/laravel.log'),
44 | 'level' => 'debug',
45 | ],
46 |
47 | 'daily' => [
48 | 'driver' => 'daily',
49 | 'path' => storage_path('logs/laravel.log'),
50 | 'level' => 'debug',
51 | 'days' => 7,
52 | ],
53 |
54 | 'slack' => [
55 | 'driver' => 'slack',
56 | 'url' => env('LOG_SLACK_WEBHOOK_URL'),
57 | 'username' => 'Laravel Log',
58 | 'emoji' => ':boom:',
59 | 'level' => 'critical',
60 | ],
61 |
62 | 'stderr' => [
63 | 'driver' => 'monolog',
64 | 'handler' => StreamHandler::class,
65 | 'with' => [
66 | 'stream' => 'php://stderr',
67 | ],
68 | ],
69 |
70 | 'syslog' => [
71 | 'driver' => 'syslog',
72 | 'level' => 'debug',
73 | ],
74 |
75 | 'errorlog' => [
76 | 'driver' => 'errorlog',
77 | 'level' => 'debug',
78 | ],
79 | ],
80 |
81 | ];
82 |
--------------------------------------------------------------------------------
/config/mail.php:
--------------------------------------------------------------------------------
1 | env('MAIL_DRIVER', 'smtp'),
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | SMTP Host Address
24 | |--------------------------------------------------------------------------
25 | |
26 | | Here you may provide the host address of the SMTP server used by your
27 | | applications. A default option is provided that is compatible with
28 | | the Mailgun mail service which will provide reliable deliveries.
29 | |
30 | */
31 |
32 | 'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
33 |
34 | /*
35 | |--------------------------------------------------------------------------
36 | | SMTP Host Port
37 | |--------------------------------------------------------------------------
38 | |
39 | | This is the SMTP port used by your application to deliver e-mails to
40 | | users of the application. Like the host we have set this value to
41 | | stay compatible with the Mailgun e-mail application by default.
42 | |
43 | */
44 |
45 | 'port' => env('MAIL_PORT', 587),
46 |
47 | /*
48 | |--------------------------------------------------------------------------
49 | | Global "From" Address
50 | |--------------------------------------------------------------------------
51 | |
52 | | You may wish for all e-mails sent by your application to be sent from
53 | | the same address. Here, you may specify a name and address that is
54 | | used globally for all e-mails that are sent by your application.
55 | |
56 | */
57 |
58 | 'from' => [
59 | 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'),
60 | 'name' => env('MAIL_FROM_NAME', 'Example'),
61 | ],
62 |
63 | /*
64 | |--------------------------------------------------------------------------
65 | | E-Mail Encryption Protocol
66 | |--------------------------------------------------------------------------
67 | |
68 | | Here you may specify the encryption protocol that should be used when
69 | | the application send e-mail messages. A sensible default using the
70 | | transport layer security protocol should provide great security.
71 | |
72 | */
73 |
74 | 'encryption' => env('MAIL_ENCRYPTION', 'tls'),
75 |
76 | /*
77 | |--------------------------------------------------------------------------
78 | | SMTP Server Username
79 | |--------------------------------------------------------------------------
80 | |
81 | | If your SMTP server requires a username for authentication, you should
82 | | set it here. This will get used to authenticate with your server on
83 | | connection. You may also set the "password" value below this one.
84 | |
85 | */
86 |
87 | 'username' => env('MAIL_USERNAME'),
88 |
89 | 'password' => env('MAIL_PASSWORD'),
90 |
91 | /*
92 | |--------------------------------------------------------------------------
93 | | Sendmail System Path
94 | |--------------------------------------------------------------------------
95 | |
96 | | When using the "sendmail" driver to send e-mails, we will need to know
97 | | the path to where Sendmail lives on this server. A default path has
98 | | been provided here, which will work well on most of your systems.
99 | |
100 | */
101 |
102 | 'sendmail' => '/usr/sbin/sendmail -bs',
103 |
104 | /*
105 | |--------------------------------------------------------------------------
106 | | Markdown Mail Settings
107 | |--------------------------------------------------------------------------
108 | |
109 | | If you are using Markdown based email rendering, you may configure your
110 | | theme and component paths here, allowing you to customize the design
111 | | of the emails. Or, you may simply stick with the Laravel defaults!
112 | |
113 | */
114 |
115 | 'markdown' => [
116 | 'theme' => 'default',
117 |
118 | 'paths' => [
119 | resource_path('views/vendor/mail'),
120 | ],
121 | ],
122 |
123 | ];
124 |
--------------------------------------------------------------------------------
/config/queue.php:
--------------------------------------------------------------------------------
1 | env('QUEUE_CONNECTION', 'sync'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Queue Connections
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may configure the connection information for each server that
26 | | is used by your application. A default configuration has been added
27 | | for each back-end shipped with Laravel. You are free to add more.
28 | |
29 | */
30 |
31 | 'connections' => [
32 |
33 | 'sync' => [
34 | 'driver' => 'sync',
35 | ],
36 |
37 | 'database' => [
38 | 'driver' => 'database',
39 | 'table' => 'jobs',
40 | 'queue' => 'default',
41 | 'retry_after' => 90,
42 | ],
43 |
44 | 'beanstalkd' => [
45 | 'driver' => 'beanstalkd',
46 | 'host' => 'localhost',
47 | 'queue' => 'default',
48 | 'retry_after' => 90,
49 | ],
50 |
51 | 'sqs' => [
52 | 'driver' => 'sqs',
53 | 'key' => 'your-public-key',
54 | 'secret' => 'your-secret-key',
55 | 'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id',
56 | 'queue' => 'your-queue-name',
57 | 'region' => 'us-east-1',
58 | ],
59 |
60 | 'redis' => [
61 | 'driver' => 'redis',
62 | 'connection' => 'default',
63 | 'queue' => 'default',
64 | 'retry_after' => 90,
65 | ],
66 |
67 | ],
68 |
69 | /*
70 | |--------------------------------------------------------------------------
71 | | Failed Queue Jobs
72 | |--------------------------------------------------------------------------
73 | |
74 | | These options configure the behavior of failed queue job logging so you
75 | | can control which database and table are used to store the jobs that
76 | | have failed. You may change them to any database / table you wish.
77 | |
78 | */
79 |
80 | 'failed' => [
81 | 'database' => env('DB_CONNECTION', 'mysql'),
82 | 'table' => 'failed_jobs',
83 | ],
84 |
85 | ];
86 |
--------------------------------------------------------------------------------
/config/services.php:
--------------------------------------------------------------------------------
1 | [
18 | 'domain' => env('MAILGUN_DOMAIN'),
19 | 'secret' => env('MAILGUN_SECRET'),
20 | ],
21 |
22 | 'ses' => [
23 | 'key' => env('SES_KEY'),
24 | 'secret' => env('SES_SECRET'),
25 | 'region' => 'us-east-1',
26 | ],
27 |
28 | 'sparkpost' => [
29 | 'secret' => env('SPARKPOST_SECRET'),
30 | ],
31 |
32 | 'stripe' => [
33 | 'model' => App\Models\User::class,
34 | 'key' => env('STRIPE_KEY'),
35 | 'secret' => env('STRIPE_SECRET'),
36 | ],
37 |
38 | 'github' => [
39 | 'client_id' => env('GITHUB_CLIENT_ID'),
40 | 'client_secret' => env('GITHUB_CLIENT_SECRET'),
41 | ],
42 |
43 | ];
44 |
--------------------------------------------------------------------------------
/config/session.php:
--------------------------------------------------------------------------------
1 | env('SESSION_DRIVER', 'file'),
20 |
21 | /*
22 | |--------------------------------------------------------------------------
23 | | Session Lifetime
24 | |--------------------------------------------------------------------------
25 | |
26 | | Here you may specify the number of minutes that you wish the session
27 | | to be allowed to remain idle before it expires. If you want them
28 | | to immediately expire on the browser closing, set that option.
29 | |
30 | */
31 |
32 | 'lifetime' => 120,
33 |
34 | 'expire_on_close' => false,
35 |
36 | /*
37 | |--------------------------------------------------------------------------
38 | | Session Encryption
39 | |--------------------------------------------------------------------------
40 | |
41 | | This option allows you to easily specify that all of your session data
42 | | should be encrypted before it is stored. All encryption will be run
43 | | automatically by Laravel and you can use the Session like normal.
44 | |
45 | */
46 |
47 | 'encrypt' => false,
48 |
49 | /*
50 | |--------------------------------------------------------------------------
51 | | Session File Location
52 | |--------------------------------------------------------------------------
53 | |
54 | | When using the native session driver, we need a location where session
55 | | files may be stored. A default has been set for you but a different
56 | | location may be specified. This is only needed for file sessions.
57 | |
58 | */
59 |
60 | 'files' => storage_path('framework/sessions'),
61 |
62 | /*
63 | |--------------------------------------------------------------------------
64 | | Session Database Connection
65 | |--------------------------------------------------------------------------
66 | |
67 | | When using the "database" or "redis" session drivers, you may specify a
68 | | connection that should be used to manage these sessions. This should
69 | | correspond to a connection in your database configuration options.
70 | |
71 | */
72 |
73 | 'connection' => null,
74 |
75 | /*
76 | |--------------------------------------------------------------------------
77 | | Session Database Table
78 | |--------------------------------------------------------------------------
79 | |
80 | | When using the "database" session driver, you may specify the table we
81 | | should use to manage the sessions. Of course, a sensible default is
82 | | provided for you; however, you are free to change this as needed.
83 | |
84 | */
85 |
86 | 'table' => 'sessions',
87 |
88 | /*
89 | |--------------------------------------------------------------------------
90 | | Session Cache Store
91 | |--------------------------------------------------------------------------
92 | |
93 | | When using the "apc" or "memcached" session drivers, you may specify a
94 | | cache store that should be used for these sessions. This value must
95 | | correspond with one of the application's configured cache stores.
96 | |
97 | */
98 |
99 | 'store' => null,
100 |
101 | /*
102 | |--------------------------------------------------------------------------
103 | | Session Sweeping Lottery
104 | |--------------------------------------------------------------------------
105 | |
106 | | Some session drivers must manually sweep their storage location to get
107 | | rid of old sessions from storage. Here are the chances that it will
108 | | happen on a given request. By default, the odds are 2 out of 100.
109 | |
110 | */
111 |
112 | 'lottery' => [2, 100],
113 |
114 | /*
115 | |--------------------------------------------------------------------------
116 | | Session Cookie Name
117 | |--------------------------------------------------------------------------
118 | |
119 | | Here you may change the name of the cookie used to identify a session
120 | | instance by ID. The name specified here will get used every time a
121 | | new session cookie is created by the framework for every driver.
122 | |
123 | */
124 |
125 | 'cookie' => env(
126 | 'SESSION_COOKIE',
127 | str_slug(env('APP_NAME', 'laravel'), '_').'_session'
128 | ),
129 |
130 | /*
131 | |--------------------------------------------------------------------------
132 | | Session Cookie Path
133 | |--------------------------------------------------------------------------
134 | |
135 | | The session cookie path determines the path for which the cookie will
136 | | be regarded as available. Typically, this will be the root path of
137 | | your application but you are free to change this when necessary.
138 | |
139 | */
140 |
141 | 'path' => '/',
142 |
143 | /*
144 | |--------------------------------------------------------------------------
145 | | Session Cookie Domain
146 | |--------------------------------------------------------------------------
147 | |
148 | | Here you may change the domain of the cookie used to identify a session
149 | | in your application. This will determine which domains the cookie is
150 | | available to in your application. A sensible default has been set.
151 | |
152 | */
153 |
154 | 'domain' => env('SESSION_DOMAIN', null),
155 |
156 | /*
157 | |--------------------------------------------------------------------------
158 | | HTTPS Only Cookies
159 | |--------------------------------------------------------------------------
160 | |
161 | | By setting this option to true, session cookies will only be sent back
162 | | to the server if the browser has a HTTPS connection. This will keep
163 | | the cookie from being sent to you if it can not be done securely.
164 | |
165 | */
166 |
167 | 'secure' => env('SESSION_SECURE_COOKIE', false),
168 |
169 | /*
170 | |--------------------------------------------------------------------------
171 | | HTTP Access Only
172 | |--------------------------------------------------------------------------
173 | |
174 | | Setting this value to true will prevent JavaScript from accessing the
175 | | value of the cookie and the cookie will only be accessible through
176 | | the HTTP protocol. You are free to modify this option if needed.
177 | |
178 | */
179 |
180 | 'http_only' => true,
181 |
182 | /*
183 | |--------------------------------------------------------------------------
184 | | Same-Site Cookies
185 | |--------------------------------------------------------------------------
186 | |
187 | | This option determines how your cookies behave when cross-site requests
188 | | take place, and can be used to mitigate CSRF attacks. By default, we
189 | | do not enable this as other CSRF protection services are in place.
190 | |
191 | | Supported: "lax", "strict"
192 | |
193 | */
194 |
195 | 'same_site' => null,
196 |
197 | ];
198 |
--------------------------------------------------------------------------------
/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' => realpath(storage_path('framework/views')),
32 |
33 | ];
34 |
--------------------------------------------------------------------------------
/database/.gitignore:
--------------------------------------------------------------------------------
1 | *.sqlite
2 |
--------------------------------------------------------------------------------
/database/factories/UserFactory.php:
--------------------------------------------------------------------------------
1 | define(User::class, function (Faker $faker) {
7 | static $password;
8 |
9 | return [
10 | 'name' => $faker->name,
11 | 'email' => $faker->unique()->safeEmail,
12 | 'password' => $password ?: $password = bcrypt('secret'),
13 | 'role' => User::roleOptions()->random(),
14 | 'remember_token' => str_random(10),
15 | ];
16 | });
17 |
18 | $factory->state(User::class, 'root', [
19 | 'role' => User::ROLE_ROOT,
20 | ]);
21 |
22 | $factory->state(User::class, 'admin', [
23 | 'role' => User::ROLE_ADMIN,
24 | ]);
25 |
26 | $factory->state(User::class, 'store', function ($faker) {
27 | return [
28 | 'name' => $faker->name,
29 | 'email' => $faker->unique()->safeEmail,
30 | 'password' => 'secret',
31 | 'role' => User::roleOptions()->random(),
32 | 'remember_token' => null
33 | ];
34 | });
35 |
36 |
--------------------------------------------------------------------------------
/database/migrations/2014_10_12_000000_create_users_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
19 | $table->string('name');
20 | $table->string('email')->unique();
21 | $table->string('password')->nullable();
22 | $table->string('role')->default(User::ROLE_ADMIN);
23 | $table->rememberToken();
24 | $table->timestamps();
25 | $table->softDeletes();
26 | });
27 | }
28 |
29 | /**
30 | * Reverse the migrations.
31 | *
32 | * @return void
33 | */
34 | public function down()
35 | {
36 | Schema::dropIfExists('users');
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/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/2017_12_07_122845_create_oauth_providers_table.php:
--------------------------------------------------------------------------------
1 | increments('id');
18 | $table->integer('user_id')->unsigned();
19 | $table->string('provider');
20 | $table->string('provider_user_id')->index();
21 | $table->string('access_token')->nullable();
22 | $table->string('refresh_token')->nullable();
23 | $table->timestamps();
24 |
25 | $table->foreign('user_id')
26 | ->references('id')
27 | ->on('users')
28 | ->onDelete('cascade');
29 | });
30 | }
31 |
32 | /**
33 | * Reverse the migrations.
34 | *
35 | * @return void
36 | */
37 | public function down()
38 | {
39 | Schema::dropIfExists('oauth_providers');
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/database/seeds/DatabaseSeeder.php:
--------------------------------------------------------------------------------
1 | call(UsersTableSeeder::class);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "scripts": {
4 | "dev": "nuxt -c ./client/nuxt.config.js",
5 | "build": "nuxt build -c ./client/nuxt.config.js",
6 | "start": "nuxt start -c ./client/nuxt.config.js",
7 | "lint": "vue-cli-service lint ./client/"
8 | },
9 | "dependencies": {
10 | "@nuxtjs/router": "^1.5.0",
11 | "axios": "^0.18.1",
12 | "dotenv": "^6.2.0",
13 | "jquery": "^3.4.1",
14 | "js-cookie": "^2.2.1",
15 | "nuxt": "^2.10.1",
16 | "popper.js": "^1.16.0",
17 | "sweetalert2": "^8.18.4",
18 | "vform": "^1.0.1",
19 | "vue-i18n": "^8.15.0",
20 | "vue-tailwind": "^0.4"
21 | },
22 | "devDependencies": {
23 | "@vue/cli-plugin-eslint": "^3.12.0",
24 | "@vue/cli-service": "^3.12.0",
25 | "@vue/eslint-config-standard": "^4.0.0",
26 | "babel-plugin-async-import": "^2.1.0",
27 | "postcss-loader": "^3.0.0",
28 | "tailwindcss": "^1.1.2"
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 | ./tests/Unit
14 |
15 |
16 |
17 | ./tests/Feature
18 |
19 |
20 |
21 |
22 | ./app
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: [
3 | require('postcss-import'),
4 | require('postcss-url'),
5 | require('tailwindcss')('./tailwind.config.js'),
6 | require('autoprefixer')({
7 | cascade: false,
8 | grid: true
9 | }),
10 | require('postcss-preset-env')({
11 | stage: 0
12 | }),
13 | require('cssnano')({
14 | preset: 'default',
15 | discardComments: { removeAll: true },
16 | zindex: false
17 | })
18 | ]
19 | }
20 |
--------------------------------------------------------------------------------
/public/.htaccess:
--------------------------------------------------------------------------------
1 |
2 |
3 | Options -MultiViews
4 |
5 |
6 | RewriteEngine On
7 |
8 | # Redirect Trailing Slashes If Not A Folder...
9 | RewriteCond %{REQUEST_FILENAME} !-d
10 | RewriteCond %{REQUEST_URI} (.+)/$
11 | RewriteRule ^ %1 [L,R=301]
12 |
13 | # Handle Front Controller...
14 | RewriteCond %{REQUEST_FILENAME} !-d
15 | RewriteCond %{REQUEST_FILENAME} !-f
16 | RewriteRule ^ index.php [L]
17 |
18 | # Handle Authorization Header
19 | RewriteCond %{HTTP:Authorization} .
20 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
21 |
22 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alfonsobries/laravel-nuxt-tailwind/aaeb102c3a7500e0cabe9c72a2f6589bb5bda894/public/favicon.ico
--------------------------------------------------------------------------------
/public/index.php:
--------------------------------------------------------------------------------
1 |
7 | */
8 | define('LARAVEL_START', microtime(true));
9 |
10 | /*
11 | |--------------------------------------------------------------------------
12 | | Register The Auto Loader
13 | |--------------------------------------------------------------------------
14 | |
15 | | Composer provides a convenient, automatically generated class loader for
16 | | our application. We just need to utilize it! We'll simply require it
17 | | into the script here so that we don't have to worry about manual
18 | | loading any of our classes later on. It feels great to relax.
19 | |
20 | */
21 |
22 | require __DIR__.'/../vendor/autoload.php';
23 |
24 | /*
25 | |--------------------------------------------------------------------------
26 | | Turn On The Lights
27 | |--------------------------------------------------------------------------
28 | |
29 | | We need to illuminate PHP development, so let us turn on the lights.
30 | | This bootstraps the framework and gets it ready for use, then it
31 | | will load up this application so that we can run it and send
32 | | the responses back to the browser and delight our users.
33 | |
34 | */
35 |
36 | $app = require_once __DIR__.'/../bootstrap/app.php';
37 |
38 | /*
39 | |--------------------------------------------------------------------------
40 | | Run The Application
41 | |--------------------------------------------------------------------------
42 | |
43 | | Once we have the application, we can handle the incoming request
44 | | through the kernel, and send the associated response back to
45 | | the client's browser allowing them to enjoy the creative
46 | | and wonderful application we have prepared for them.
47 | |
48 | */
49 |
50 | $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
51 |
52 | $response = $kernel->handle(
53 | $request = Illuminate\Http\Request::capture()
54 | );
55 |
56 | $response->send();
57 |
58 | $kernel->terminate($request, $response);
59 |
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Disallow:
3 |
--------------------------------------------------------------------------------
/public/web.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/resources/lang/en/auth.php:
--------------------------------------------------------------------------------
1 | 'These credentials do not match our records.',
17 | 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
18 |
19 | ];
20 |
--------------------------------------------------------------------------------
/resources/lang/en/pagination.php:
--------------------------------------------------------------------------------
1 | '« Previous',
17 | 'next' => 'Next »',
18 |
19 | ];
20 |
--------------------------------------------------------------------------------
/resources/lang/en/passwords.php:
--------------------------------------------------------------------------------
1 | 'Passwords must be at least six characters and match the confirmation.',
17 | 'reset' => 'Your password has been reset!',
18 | 'sent' => 'We have e-mailed your password reset link!',
19 | 'token' => 'This password reset token is invalid.',
20 | 'user' => "We can't find a user with that e-mail address.",
21 |
22 | ];
23 |
--------------------------------------------------------------------------------
/resources/lang/en/validation.php:
--------------------------------------------------------------------------------
1 | 'The :attribute must be accepted.',
17 | 'active_url' => 'The :attribute is not a valid URL.',
18 | 'after' => 'The :attribute must be a date after :date.',
19 | 'after_or_equal' => 'The :attribute must be a date after or equal to :date.',
20 | 'alpha' => 'The :attribute may only contain letters.',
21 | 'alpha_dash' => 'The :attribute may only contain letters, numbers, and dashes.',
22 | 'alpha_num' => 'The :attribute may only contain letters and numbers.',
23 | 'array' => 'The :attribute must be an array.',
24 | 'before' => 'The :attribute must be a date before :date.',
25 | 'before_or_equal' => 'The :attribute must be a date before or equal to :date.',
26 | 'between' => [
27 | 'numeric' => 'The :attribute must be between :min and :max.',
28 | 'file' => 'The :attribute must be between :min and :max kilobytes.',
29 | 'string' => 'The :attribute must be between :min and :max characters.',
30 | 'array' => 'The :attribute must have between :min and :max items.',
31 | ],
32 | 'boolean' => 'The :attribute field must be true or false.',
33 | 'confirmed' => 'The :attribute confirmation does not match.',
34 | 'date' => 'The :attribute is not a valid date.',
35 | 'date_format' => 'The :attribute does not match the format :format.',
36 | 'different' => 'The :attribute and :other must be different.',
37 | 'digits' => 'The :attribute must be :digits digits.',
38 | 'digits_between' => 'The :attribute must be between :min and :max digits.',
39 | 'dimensions' => 'The :attribute has invalid image dimensions.',
40 | 'distinct' => 'The :attribute field has a duplicate value.',
41 | 'email' => 'The :attribute must be a valid email address.',
42 | 'exists' => 'The selected :attribute is invalid.',
43 | 'file' => 'The :attribute must be a file.',
44 | 'filled' => 'The :attribute field must have a value.',
45 | 'image' => 'The :attribute must be an image.',
46 | 'in' => 'The selected :attribute is invalid.',
47 | 'in_array' => 'The :attribute field does not exist in :other.',
48 | 'integer' => 'The :attribute must be an integer.',
49 | 'ip' => 'The :attribute must be a valid IP address.',
50 | 'ipv4' => 'The :attribute must be a valid IPv4 address.',
51 | 'ipv6' => 'The :attribute must be a valid IPv6 address.',
52 | 'json' => 'The :attribute must be a valid JSON string.',
53 | 'max' => [
54 | 'numeric' => 'The :attribute may not be greater than :max.',
55 | 'file' => 'The :attribute may not be greater than :max kilobytes.',
56 | 'string' => 'The :attribute may not be greater than :max characters.',
57 | 'array' => 'The :attribute may not have more than :max items.',
58 | ],
59 | 'mimes' => 'The :attribute must be a file of type: :values.',
60 | 'mimetypes' => 'The :attribute must be a file of type: :values.',
61 | 'min' => [
62 | 'numeric' => 'The :attribute must be at least :min.',
63 | 'file' => 'The :attribute must be at least :min kilobytes.',
64 | 'string' => 'The :attribute must be at least :min characters.',
65 | 'array' => 'The :attribute must have at least :min items.',
66 | ],
67 | 'not_in' => 'The selected :attribute is invalid.',
68 | 'numeric' => 'The :attribute must be a number.',
69 | 'present' => 'The :attribute field must be present.',
70 | 'regex' => 'The :attribute format is invalid.',
71 | 'required' => 'The :attribute field is required.',
72 | 'required_if' => 'The :attribute field is required when :other is :value.',
73 | 'required_unless' => 'The :attribute field is required unless :other is in :values.',
74 | 'required_with' => 'The :attribute field is required when :values is present.',
75 | 'required_with_all' => 'The :attribute field is required when :values is present.',
76 | 'required_without' => 'The :attribute field is required when :values is not present.',
77 | 'required_without_all' => 'The :attribute field is required when none of :values are present.',
78 | 'same' => 'The :attribute and :other must match.',
79 | 'size' => [
80 | 'numeric' => 'The :attribute must be :size.',
81 | 'file' => 'The :attribute must be :size kilobytes.',
82 | 'string' => 'The :attribute must be :size characters.',
83 | 'array' => 'The :attribute must contain :size items.',
84 | ],
85 | 'string' => 'The :attribute must be a string.',
86 | 'timezone' => 'The :attribute must be a valid zone.',
87 | 'unique' => 'The :attribute has already been taken.',
88 | 'uploaded' => 'The :attribute failed to upload.',
89 | 'url' => 'The :attribute format is invalid.',
90 |
91 | /*
92 | |--------------------------------------------------------------------------
93 | | Custom Validation Language Lines
94 | |--------------------------------------------------------------------------
95 | |
96 | | Here you may specify custom validation messages for attributes using the
97 | | convention "attribute.rule" to name the lines. This makes it quick to
98 | | specify a specific custom language line for a given attribute rule.
99 | |
100 | */
101 |
102 | 'custom' => [
103 | 'attribute-name' => [
104 | 'rule-name' => 'custom-message',
105 | ],
106 | ],
107 |
108 | /*
109 | |--------------------------------------------------------------------------
110 | | Custom Validation Attributes
111 | |--------------------------------------------------------------------------
112 | |
113 | | The following language lines are used to swap attribute place-holders
114 | | with something more reader friendly such as E-Mail Address instead
115 | | of "email". This simply helps us make messages a little cleaner.
116 | |
117 | */
118 |
119 | 'attributes' => [],
120 |
121 | ];
122 |
--------------------------------------------------------------------------------
/resources/lang/es/auth.php:
--------------------------------------------------------------------------------
1 | 'Estas credenciales no coinciden con nuestros registros.',
17 | 'throttle' => 'Demasiados intentos de acceso. Por favor intente nuevamente en :seconds segundos.',
18 |
19 | ];
20 |
--------------------------------------------------------------------------------
/resources/lang/es/pagination.php:
--------------------------------------------------------------------------------
1 | '« Anterior',
17 | 'next' => 'Siguiente »',
18 |
19 | ];
20 |
--------------------------------------------------------------------------------
/resources/lang/es/passwords.php:
--------------------------------------------------------------------------------
1 | 'Las contraseñas deben coincidir y contener al menos 6 caracteres',
17 | 'reset' => '¡Tu contraseña ha sido restablecida!',
18 | 'sent' => '¡Te hemos enviado por correo el enlace para restablecer tu contraseña!',
19 | 'token' => 'El token de recuperación de contraseña es inválido.',
20 | 'user' => 'No podemos encontrar ningún usuario con ese correo electrónico.',
21 |
22 | ];
23 |
--------------------------------------------------------------------------------
/resources/lang/es/validation.php:
--------------------------------------------------------------------------------
1 | ':attribute debe ser aceptado.',
17 | 'active_url' => ':attribute no es una URL válida.',
18 | 'after' => ':attribute debe ser una fecha posterior a :date.',
19 | 'after_or_equal' => ':attribute debe ser una fecha posterior o igual a :date.',
20 | 'alpha' => ':attribute sólo debe contener letras.',
21 | 'alpha_dash' => ':attribute sólo debe contener letras, números y guiones.',
22 | 'alpha_num' => ':attribute sólo debe contener letras y números.',
23 | 'array' => ':attribute debe ser un conjunto.',
24 | 'before' => ':attribute debe ser una fecha anterior a :date.',
25 | 'before_or_equal' => ':attribute debe ser una fecha anterior o igual a :date.',
26 | 'between' => [
27 | 'numeric' => ':attribute tiene que estar entre :min - :max.',
28 | 'file' => ':attribute debe pesar entre :min - :max kilobytes.',
29 | 'string' => ':attribute tiene que tener entre :min - :max caracteres.',
30 | 'array' => ':attribute tiene que tener entre :min - :max ítems.',
31 | ],
32 | 'boolean' => 'El campo :attribute debe tener un valor verdadero o falso.',
33 | 'confirmed' => 'La confirmación de :attribute no coincide.',
34 | 'date' => ':attribute no es una fecha válida.',
35 | 'date_format' => ':attribute no corresponde al formato :format.',
36 | 'different' => ':attribute y :other deben ser diferentes.',
37 | 'digits' => ':attribute debe tener :digits dígitos.',
38 | 'digits_between' => ':attribute debe tener entre :min y :max dígitos.',
39 | 'dimensions' => 'Las dimensiones de la imagen :attribute no son válidas.',
40 | 'distinct' => 'El campo :attribute contiene un valor duplicado.',
41 | 'email' => ':attribute no es un correo válido',
42 | 'exists' => ':attribute es inválido.',
43 | 'file' => 'El campo :attribute debe ser un archivo.',
44 | 'filled' => 'El campo :attribute es obligatorio.',
45 | 'image' => ':attribute debe ser una imagen.',
46 | 'in' => ':attribute es inválido.',
47 | 'in_array' => 'El campo :attribute no existe en :other.',
48 | 'integer' => ':attribute debe ser un número entero.',
49 | 'ip' => ':attribute debe ser una dirección IP válida.',
50 | 'ipv4' => ':attribute debe ser un dirección IPv4 válida',
51 | 'ipv6' => ':attribute debe ser un dirección IPv6 válida.',
52 | 'json' => 'El campo :attribute debe tener una cadena JSON válida.',
53 | 'max' => [
54 | 'numeric' => ':attribute no debe ser mayor a :max.',
55 | 'file' => ':attribute no debe ser mayor que :max kilobytes.',
56 | 'string' => ':attribute no debe ser mayor que :max caracteres.',
57 | 'array' => ':attribute no debe tener más de :max elementos.',
58 | ],
59 | 'mimes' => ':attribute debe ser un archivo con formato: :values.',
60 | 'mimetypes' => ':attribute debe ser un archivo con formato: :values.',
61 | 'min' => [
62 | 'numeric' => 'El tamaño de :attribute debe ser de al menos :min.',
63 | 'file' => 'El tamaño de :attribute debe ser de al menos :min kilobytes.',
64 | 'string' => ':attribute debe contener al menos :min caracteres.',
65 | 'array' => ':attribute debe tener al menos :min elementos.',
66 | ],
67 | 'not_in' => ':attribute es inválido.',
68 | 'numeric' => ':attribute debe ser numérico.',
69 | 'present' => 'El campo :attribute debe estar presente.',
70 | 'regex' => 'El formato de :attribute es inválido.',
71 | 'required' => 'El campo :attribute es obligatorio.',
72 | 'required_if' => 'El campo :attribute es obligatorio cuando :other es :value.',
73 | 'required_unless' => 'El campo :attribute es obligatorio a menos que :other esté en :values.',
74 | 'required_with' => 'El campo :attribute es obligatorio cuando :values está presente.',
75 | 'required_with_all' => 'El campo :attribute es obligatorio cuando :values está presente.',
76 | 'required_without' => 'El campo :attribute es obligatorio cuando :values no está presente.',
77 | 'required_without_all' => 'El campo :attribute es obligatorio cuando ninguno de :values estén presentes.',
78 | 'same' => ':attribute y :other deben coincidir.',
79 | 'size' => [
80 | 'numeric' => 'El tamaño de :attribute debe ser :size.',
81 | 'file' => 'El tamaño de :attribute debe ser :size kilobytes.',
82 | 'string' => ':attribute debe contener :size caracteres.',
83 | 'array' => ':attribute debe contener :size elementos.',
84 | ],
85 | 'string' => 'El campo :attribute debe ser una cadena de caracteres.',
86 | 'timezone' => 'El :attribute debe ser una zona válida.',
87 | 'unique' => ':attribute ya ha sido registrado.',
88 | 'uploaded' => 'Subir :attribute ha fallado.',
89 | 'url' => 'El formato :attribute es inválido.',
90 |
91 | /*
92 | |--------------------------------------------------------------------------
93 | | Custom Validation Language Lines
94 | |--------------------------------------------------------------------------
95 | |
96 | | Here you may specify custom validation messages for attributes using the
97 | | convention "attribute.rule" to name the lines. This makes it quick to
98 | | specify a specific custom language line for a given attribute rule.
99 | |
100 | */
101 |
102 | 'custom' => [
103 | 'password' => [
104 | 'min' => 'La :attribute debe contener más de :min caracteres',
105 | ],
106 | 'email' => [
107 | 'unique' => 'El :attribute ya ha sido registrado.',
108 | ],
109 | ],
110 |
111 | /*
112 | |--------------------------------------------------------------------------
113 | | Custom Validation Attributes
114 | |--------------------------------------------------------------------------
115 | |
116 | | The following language lines are used to swap attribute place-holders
117 | | with something more reader friendly such as E-Mail Address instead
118 | | of "email". This simply helps us make messages a little cleaner.
119 | |
120 | */
121 |
122 | 'attributes' => [
123 | 'name' => 'nombre',
124 | 'username' => 'usuario',
125 | 'email' => 'correo electrónico',
126 | 'first_name' => 'nombre',
127 | 'last_name' => 'apellido',
128 | 'password' => 'contraseña',
129 | 'password_confirmation' => 'confirmación de la contraseña',
130 | 'city' => 'ciudad',
131 | 'country' => 'país',
132 | 'address' => 'dirección',
133 | 'phone' => 'teléfono',
134 | 'mobile' => 'móvil',
135 | 'age' => 'edad',
136 | 'sex' => 'sexo',
137 | 'gender' => 'género',
138 | 'year' => 'año',
139 | 'month' => 'mes',
140 | 'day' => 'día',
141 | 'hour' => 'hora',
142 | 'minute' => 'minuto',
143 | 'second' => 'segundo',
144 | 'title' => 'título',
145 | 'content' => 'contenido',
146 | 'body' => 'contenido',
147 | 'description' => 'descripción',
148 | 'excerpt' => 'extracto',
149 | 'date' => 'fecha',
150 | 'time' => 'hora',
151 | 'subject' => 'asunto',
152 | 'message' => 'mensaje',
153 | ],
154 |
155 | ];
156 |
--------------------------------------------------------------------------------
/resources/lang/zh-CN/auth.php:
--------------------------------------------------------------------------------
1 | '用户名或手机号与密码不匹配或用户被禁用',
15 | 'throttle' => '失败次数太多,请在:seconds秒后再尝试',
16 | ];
17 |
--------------------------------------------------------------------------------
/resources/lang/zh-CN/pagination.php:
--------------------------------------------------------------------------------
1 | '« 上一页',
15 | 'next' => '下一页 »',
16 | ];
17 |
--------------------------------------------------------------------------------
/resources/lang/zh-CN/passwords.php:
--------------------------------------------------------------------------------
1 | '密码长度至少包含6个字符并且两次输入密码要一致',
15 | 'reset' => '密码已经被重置!',
16 | 'sent' => '我们已经发送密码重置链接到您的邮箱',
17 | 'token' => '密码重置令牌无效',
18 | 'user' => '抱歉,该邮箱对应的用户不存在!',
19 | ];
20 |
--------------------------------------------------------------------------------
/resources/lang/zh-CN/validation.php:
--------------------------------------------------------------------------------
1 | ':attribute 已存在',
15 | 'accepted' => ':attribute 是被接受的',
16 | 'active_url' => ':attribute 必须是一个合法的 URL',
17 | 'after' => ':attribute 必须是 :date 之后的一个日期',
18 | 'alpha' => ':attribute 必须全部由字母字符构成。',
19 | 'alpha_dash' => ':attribute 必须全部由字母、数字、中划线或下划线字符构成',
20 | 'alpha_num' => ':attribute 必须全部由字母和数字构成',
21 | 'array' => ':attribute 必须是个数组',
22 | 'before' => ':attribute 必须是 :date 之前的一个日期',
23 | 'between' => [
24 | 'numeric' => ':attribute 必须在 :min 到 :max 之间',
25 | 'file' => ':attribute 必须在 :min 到 :max KB之间',
26 | 'string' => ':attribute 必须在 :min 到 :max 个字符之间',
27 | 'array' => ':attribute 必须在 :min 到 :max 项之间',
28 | ],
29 | 'boolean' => ':attribute 字符必须是 true 或 false',
30 | 'confirmed' => ':attribute 两次确认不匹配',
31 | 'date' => ':attribute 必须是一个合法的日期',
32 | 'date_format' => ':attribute 与给定的格式 :format 不符合',
33 | 'different' => ':attribute 必须不同于:other',
34 | 'digits' => ':attribute 必须是 :digits 位',
35 | 'digits_between' => ':attribute 必须在 :min and :max 位之间',
36 | 'email' => ':attribute 必须是一个合法的电子邮件地址。',
37 | 'filled' => ':attribute 的字段是必填的',
38 | 'exists' => '选定的 :attribute 是无效的',
39 | 'image' => ':attribute 必须是一个图片 (jpeg, png, bmp 或者 gif)',
40 | 'in' => '选定的 :attribute 是无效的',
41 | 'integer' => ':attribute 必须是个整数',
42 | 'ip' => ':attribute 必须是一个合法的 IP 地址。',
43 | 'max' => [
44 | 'numeric' => ':attribute 的最大长度为 :max 位',
45 | 'file' => ':attribute 的最大为 :max',
46 | 'string' => ':attribute 的最大长度为 :max 字符',
47 | 'array' => ':attribute 的最大个数为 :max 个',
48 | ],
49 | 'mimes' => ':attribute 的文件类型必须是:values',
50 | 'mimetypes' => ':attribute 的文件类型必须是: :values.',
51 | 'min' => [
52 | 'numeric' => ':attribute 的最小长度为 :min 位',
53 | 'string' => ':attribute 的最小长度为 :min 字符',
54 | 'file' => ':attribute 大小至少为:min KB',
55 | 'array' => ':attribute 至少有 :min 项',
56 | ],
57 | 'not_in' => '选定的 :attribute 是无效的',
58 | 'numeric' => ':attribute 必须是数字',
59 | 'regex' => ':attribute 格式是无效的',
60 | 'required' => ':attribute 字段必须填写',
61 | 'required_if' => ':attribute 字段是必须的当 :other 是 :value',
62 | 'required_with' => ':attribute 字段是必须的当 :values 是存在的',
63 | 'required_with_all' => ':attribute 字段是必须的当 :values 是存在的',
64 | 'required_without' => ':attribute 字段是必须的当 :values 是不存在的',
65 | 'required_without_all' => ':attribute 字段是必须的当 没有一个 :values 是存在的',
66 | 'same' => ':attribute 和 :other 必须匹配',
67 | 'size' => [
68 | 'numeric' => ':attribute 必须是 :size 位',
69 | 'file' => ':attribute 必须是 :size KB',
70 | 'string' => ':attribute 必须是 :size 个字符',
71 | 'array' => ':attribute 必须包括 :size 项',
72 | ],
73 | 'url' => ':attribute 无效的格式',
74 | 'timezone' => ':attribute 必须个有效的时区',
75 | /*
76 | |--------------------------------------------------------------------------
77 | | Custom Validation Language Lines
78 | |--------------------------------------------------------------------------
79 | |
80 | | Here you may specify custom validation messages for attributes using the
81 | | convention "attribute.rule" to name the lines. This makes it quick to
82 | | specify a specific custom language line for a given attribute rule.
83 | |
84 | */
85 | 'custom' => [],
86 | /*
87 | |--------------------------------------------------------------------------
88 | | Custom Validation Attributes
89 | |--------------------------------------------------------------------------
90 | |
91 | | The following language lines are used to swap attribute place-holders
92 | | with something more reader friendly such as E-Mail Address instead
93 | | of "email". This simply helps us make messages a little cleaner.
94 | |
95 | */
96 | 'attributes' => [],
97 | ];
98 |
--------------------------------------------------------------------------------
/resources/views/errors/layout.blade.php:
--------------------------------------------------------------------------------
1 | {{-- Illuminate/Foundation/Exceptions/views --}}
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | @yield('title')
10 |
11 |
12 |
13 |
14 |
15 |
48 |
49 |
50 |
51 |
52 |
53 | @yield('message')
54 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/resources/views/oauth/callback.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{ config('app.name') }}
5 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/resources/views/oauth/emailTaken.blade.php:
--------------------------------------------------------------------------------
1 | @extends('errors.layout')
2 |
3 | @section('title', 'Login Error')
4 |
5 | @section('message', 'Email already taken.')
6 |
--------------------------------------------------------------------------------
/routes/api.php:
--------------------------------------------------------------------------------
1 | 'auth:api'], function () {
17 | Route::post('logout', 'Auth\LoginController@logout');
18 |
19 | Route::get('/user', function (Request $request) {
20 | return $request->user();
21 | });
22 |
23 | Route::patch('settings/profile', 'Settings\ProfileController@update');
24 | Route::patch('settings/password', 'Settings\PasswordController@update');
25 |
26 | Route::resource('users', 'UserController');
27 |
28 | Route::resource('companies', 'CompanyController');
29 |
30 | Route::resource('providers', 'ProviderController');
31 |
32 | Route::resource('layouts', 'LayoutController');
33 | Route::group(['prefix' => 'layouts/{layout}'], function () {
34 | Route::resource('data', 'DataController');
35 | });
36 |
37 | Route::resource('columns', 'ColumnController');
38 |
39 | });
40 |
41 | Route::group(['middleware' => 'guest:api'], function () {
42 | Route::post('login', 'Auth\LoginController@login');
43 | Route::post('register', 'Auth\RegisterController@register');
44 |
45 | Route::post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail');
46 | Route::post('password/reset', 'Auth\ResetPasswordController@reset');
47 |
48 | Route::post('oauth/{provider}', 'Auth\OAuthController@redirectToProvider');
49 | Route::get('oauth/{provider}/callback', 'Auth\OAuthController@handleProviderCallback')->name('oauth.callback');
50 | });
51 |
--------------------------------------------------------------------------------
/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 | where('path', '(.*)');
17 |
--------------------------------------------------------------------------------
/server.php:
--------------------------------------------------------------------------------
1 |
7 | */
8 | $uri = urldecode(
9 | parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
10 | );
11 |
12 | // This file allows us to emulate Apache's "mod_rewrite" functionality from the
13 | // built-in PHP web server. This provides a convenient way to test a Laravel
14 | // application without having installed a "real" web server software here.
15 | if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
16 | return false;
17 | }
18 |
19 | require_once __DIR__.'/public/index.php';
20 |
--------------------------------------------------------------------------------
/storage/app/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !public/
3 | !.gitignore
4 |
--------------------------------------------------------------------------------
/storage/app/public/.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
--------------------------------------------------------------------------------
/storage/framework/cache/data/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/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/CreatesApplication.php:
--------------------------------------------------------------------------------
1 | make(Kernel::class)->bootstrap();
20 |
21 | Hash::setRounds(4);
22 |
23 | return $app;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/tests/Feature/LocaleTest.php:
--------------------------------------------------------------------------------
1 | withHeaders(['Accept-Language' => 'zh-CN'])
13 | ->postJson('/login');
14 |
15 | $this->assertEquals('zh-CN', $this->app->getLocale());
16 | }
17 |
18 | /** @test */
19 | public function set_locale_from_header_short()
20 | {
21 | $this->withHeaders(['Accept-Language' => 'en-US'])
22 | ->postJson('/login');
23 |
24 | $this->assertEquals('en', $this->app->getLocale());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/tests/Feature/LoginTest.php:
--------------------------------------------------------------------------------
1 | user = factory(User::class)->create();
18 | }
19 |
20 | /** @test */
21 | public function authenticate()
22 | {
23 | $this->postJson('/login', [
24 | 'email' => $this->user->email,
25 | 'password' => 'secret',
26 | ])
27 | ->assertSuccessful()
28 | ->assertJsonStructure(['token', 'expires_in'])
29 | ->assertJson(['token_type' => 'bearer']);
30 | }
31 |
32 | /** @test */
33 | public function fetch_the_current_user()
34 | {
35 | $this->actingAs($this->user)
36 | ->getJson('/user')
37 | ->assertSuccessful()
38 | ->assertJsonStructure(['id', 'name', 'email']);
39 | }
40 |
41 | /** @test */
42 | public function log_out()
43 | {
44 | $token = $this->postJson('/login', [
45 | 'email' => $this->user->email,
46 | 'password' => 'secret',
47 | ])->json()['token'];
48 |
49 | $this->postJson("/logout?token=$token")
50 | ->assertSuccessful();
51 |
52 | $this->getJson("/user?token=$token")
53 | ->assertStatus(401);
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/tests/Feature/OAuthTest.php:
--------------------------------------------------------------------------------
1 | getContent(), $text), "Expected text [{$text}] not found.");
21 |
22 | return $this;
23 | });
24 |
25 | TestResponse::macro('assertTextMissing', function ($text) {
26 | PHPUnit::assertFalse(str_contains($this->getContent(), $text), "Expected missing text [{$text}] found.");
27 |
28 | return $this;
29 | });
30 | }
31 |
32 | /** @test */
33 | public function redirect_to_provider()
34 | {
35 | $this->mockSocialite('github');
36 |
37 | $this->postJson('/oauth/github')
38 | ->assertSuccessful()
39 | ->assertJson(['url' => 'https://url-to-provider']);
40 | }
41 |
42 | /** @test */
43 | public function create_user_and_return_token()
44 | {
45 | $this->mockSocialite('github', [
46 | 'id' => '123',
47 | 'name' => 'Test User',
48 | 'email' => 'test@example.com',
49 | 'token' => 'access-token',
50 | 'refreshToken' => 'refresh-token',
51 | ]);
52 |
53 | $this->withoutExceptionHandling();
54 |
55 | $this->get('/oauth/github/callback')
56 | ->assertText('token')
57 | ->assertSuccessful();
58 |
59 | $this->assertDatabaseHas('users', [
60 | 'name' => 'Test User',
61 | 'email' => 'test@example.com',
62 | ]);
63 |
64 | $this->assertDatabaseHas('oauth_providers', [
65 | 'user_id' => User::first()->id,
66 | 'provider' => 'github',
67 | 'provider_user_id' => '123',
68 | 'access_token' => 'access-token',
69 | 'refresh_token' => 'refresh-token',
70 | ]);
71 | }
72 |
73 | /** @test */
74 | public function update_user_and_return_token()
75 | {
76 | $user = factory(User::class)->create(['email' => 'test@example.com']);
77 | $user->oauthProviders()->create([
78 | 'provider' => 'github',
79 | 'provider_user_id' => '123',
80 | ]);
81 |
82 | $this->mockSocialite('github', [
83 | 'id' => '123',
84 | 'email' => 'test@example.com',
85 | 'token' => 'updated-access-token',
86 | 'refreshToken' => 'updated-refresh-token',
87 | ]);
88 |
89 | $this->get('/oauth/github/callback')
90 | ->assertText('token')
91 | ->assertSuccessful();
92 |
93 | $this->assertDatabaseHas('oauth_providers', [
94 | 'user_id' => $user->id,
95 | 'access_token' => 'updated-access-token',
96 | 'refresh_token' => 'updated-refresh-token',
97 | ]);
98 | }
99 |
100 | /** @test */
101 | public function can_not_create_user_if_email_is_taken()
102 | {
103 | factory(User::class)->create(['email' => 'test@example.com']);
104 |
105 | $this->mockSocialite('github', ['email' => 'test@example.com']);
106 |
107 | $this->get('/oauth/github/callback')
108 | ->assertText('Email already taken.')
109 | ->assertTextMissing('token')
110 | ->assertStatus(400);
111 | }
112 |
113 | protected function mockSocialite($provider, $user = null)
114 | {
115 | $mock = Socialite::shouldReceive('stateless')
116 | ->andReturn(m::self())
117 | ->shouldReceive('driver')
118 | ->with($provider)
119 | ->andReturn(m::self());
120 |
121 | if ($user) {
122 | $mock->shouldReceive('user')
123 | ->andReturn((new SocialiteUser)->setRaw($user)->map($user));
124 | } else {
125 | $mock->shouldReceive('redirect')
126 | ->andReturn(redirect('https://url-to-provider'));
127 | }
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/tests/Feature/RegisterTest.php:
--------------------------------------------------------------------------------
1 | postJson('/register', [
13 | 'name' => 'Test User',
14 | 'email' => 'test@test.app',
15 | 'password' => 'secret',
16 | 'password_confirmation' => 'secret',
17 | ])
18 | ->assertSuccessful()
19 | ->assertJsonStructure(['id', 'name', 'email']);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/tests/Feature/SettingsTest.php:
--------------------------------------------------------------------------------
1 | user = factory(User::class)->create();
19 | }
20 |
21 | /** @test */
22 | public function update_profile_info()
23 | {
24 | $this->actingAs($this->user)
25 | ->patchJson('/settings/profile', [
26 | 'name' => 'Test User',
27 | 'email' => 'test@test.app',
28 | ])
29 | ->assertSuccessful()
30 | ->assertJsonStructure(['id', 'name', 'email']);
31 |
32 | $this->assertDatabaseHas('users', [
33 | 'id' => $this->user->id,
34 | 'name' => 'Test User',
35 | 'email' => 'test@test.app',
36 | ]);
37 | }
38 |
39 | /** @test */
40 | public function update_password()
41 | {
42 | $this->actingAs($this->user)
43 | ->patchJson('/settings/password', [
44 | 'password' => 'updated',
45 | 'password_confirmation' => 'updated',
46 | ])
47 | ->assertSuccessful();
48 |
49 | $this->assertTrue(Hash::check('updated', $this->user->password));
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/tests/Feature/UserControllerTest.php:
--------------------------------------------------------------------------------
1 | state('admin')->create();
17 |
18 | $request = $this->getValidRequestData(['role' => User::ROLE_ADMIN]);
19 |
20 | $response = $this
21 | ->actingAs($admin)
22 | ->postJson(route('users.store'), $request)
23 | ->assertSuccessful();
24 |
25 | $newUser = User::find($response->json('id'));
26 |
27 | collect($request)->each(function ($value, $attrib) use ($newUser) {
28 | if ($attrib === 'password') {
29 | $this->assertTrue(Hash::check($value, $newUser->{$attrib}));
30 | } else {
31 | $this->assertEquals($value, $newUser->{$attrib});
32 | }
33 | });
34 | }
35 |
36 | /** @test */
37 | public function an_admin_cannot_store_an_user_with_a_role_of_root()
38 | {
39 | $admin = factory(User::class)->state('admin')->create();
40 |
41 | $request = $this->getValidRequestData(['role' => User::ROLE_ROOT]);
42 |
43 | $response = $this
44 | ->actingAs($admin)
45 | ->postJson(route('users.store'), $request)
46 | ->assertJsonValidationErrors('role');
47 | }
48 |
49 | /** @test */
50 | public function a_root_can_store_an_user_with_a_role_of_root()
51 | {
52 | $rootUser = factory(User::class)->state('root')->create();
53 |
54 | $request = $this->getValidRequestData(['role' => User::ROLE_ROOT]);
55 |
56 | $response = $this
57 | ->actingAs($rootUser)
58 | ->postJson(route('users.store'), $request)
59 | ->assertSuccessful();
60 |
61 | $newUser = User::find($response->json('id'));
62 |
63 | collect($request)->each(function ($value, $attrib) use ($newUser) {
64 | if ($attrib === 'password') {
65 | $this->assertTrue(Hash::check($value, $newUser->{$attrib}));
66 | } else {
67 | $this->assertEquals($value, $newUser->{$attrib});
68 | }
69 | });
70 | }
71 |
72 | /** @test */
73 | public function an_admin_can_update_an_user()
74 | {
75 | $admin = factory(User::class)->state('admin')->create();
76 | $userToEdit = factory(User::class)->state('admin')->create();
77 | $request = $this->getValidRequestData(['role' => User::ROLE_ADMIN]);
78 |
79 | $response = $this
80 | ->actingAs($admin)
81 | ->putJson(route('users.update', $userToEdit), $request)
82 | ->assertSuccessful();
83 |
84 | $userToEdit = $userToEdit->fresh();
85 | collect($request)->each(function ($value, $attrib) use ($userToEdit) {
86 | if ($attrib === 'password') {
87 | $this->assertTrue(Hash::check($value, $userToEdit->{$attrib}));
88 | } else {
89 | $this->assertEquals($value, $userToEdit->{$attrib});
90 | }
91 | });
92 | }
93 |
94 | /** @test */
95 | public function an_admin_cannot_update_a_root_user()
96 | {
97 | $admin = factory(User::class)->state('admin')->create();
98 | $userToEdit = factory(User::class)->state('root')->create();
99 | $request = $this->getValidRequestData(['role' => User::ROLE_ADMIN]);
100 |
101 | $response = $this
102 | ->actingAs($admin)
103 | ->putJson(route('users.update', $userToEdit), $request)
104 | ->assertForbidden();
105 | }
106 |
107 | /** @test */
108 | public function an_admin_can_delete_an_user()
109 | {
110 | $admin = factory(User::class)->state('admin')->create();
111 | $userToDelete = factory(User::class)->state('admin')->create();
112 |
113 | $response = $this
114 | ->actingAs($admin)
115 | ->deleteJson(route('users.destroy', $userToDelete))
116 | ->assertSuccessful();
117 |
118 | $this->assertTrue($userToDelete->fresh()->trashed());
119 | }
120 |
121 | /** @test */
122 | public function an_admin_cannot_delete_a_root_user()
123 | {
124 | $admin = factory(User::class)->state('admin')->create();
125 | $userToDelete = factory(User::class)->state('root')->create();
126 |
127 | $response = $this
128 | ->actingAs($admin)
129 | ->deleteJson(route('users.destroy', $userToDelete))
130 | ->assertForbidden();
131 | }
132 |
133 | /** @test */
134 | public function an_admin_can_view_a_single_user()
135 | {
136 | $admin = factory(User::class)->state('admin')->create();
137 | $userToShow = factory(User::class)->state('root')->create();
138 |
139 | $response = $this
140 | ->actingAs($admin)
141 | ->getJson(route('users.show', $userToShow))
142 | ->assertJson(['id' => $userToShow->id]);
143 | }
144 |
145 | /** @test */
146 | public function an_admin_can_list_the_users()
147 | {
148 | $admin = factory(User::class)->state('admin')->create();
149 | factory(User::class, 9)->create();
150 |
151 | $response = $this
152 | ->actingAs($admin)
153 | ->getJson(route('users.index'))
154 | ->assertJson(['total' => 10]);
155 | }
156 |
157 | /** @test */
158 | public function a_guest_cannot_view_an_user()
159 | {
160 | $userToShow = factory(User::class)->state('root')->create();
161 |
162 | $response = $this
163 | ->getJson(route('users.show', $userToShow))
164 | ->assertStatus(401);
165 | }
166 |
167 | /** @test */
168 | public function a_guest_cannot_list_the_users()
169 | {
170 | $userToShow = factory(User::class)->state('root')->create();
171 |
172 | $response = $this
173 | ->getJson(route('users.index', $userToShow))
174 | ->assertStatus(401);
175 | }
176 |
177 | private function getValidRequestData($override = [])
178 | {
179 | return array_filter(factory(User::class)->state('store')->raw($override));
180 | }
181 | }
182 |
--------------------------------------------------------------------------------
/tests/TestCase.php:
--------------------------------------------------------------------------------
1 |