6 |
7 | # I am currently working on a new [Laravel Vue 3 project](https://github.com/Yurich84/laravel-vue3-spa) with Composition Api, Vite and Pinia as store manager.
8 |
9 | [](LICENSE)
10 |
11 | #### This is a basement for a large modular SPA, that utilises Laravel, Vue, ElementUI.
12 | #### CRUD generator is integrated in project creates standalone modules on the frontend and backend.
13 |
14 |
15 |
16 |
17 |
18 | The main goals of the project are:
19 | - to avoid hard cohesion between modules
20 | - to form the basis for writing clean code
21 | - to be easy to expand
22 | - to avoid code duplication
23 | - to reduce the start time of the project
24 | - to reduce the time of project support and code navigation
25 | - to be understandable for an inexperienced programmer
26 |
27 | ## Extensions
28 |
29 | - BackEnd: [Laravel 8](https://laravel.com/)
30 | - FrontEnd: [Vue](https://vuejs.org) + [VueRouter](https://router.vuejs.org) + [Vuex](https://vuex.vuejs.org) + [VueI18n](https://kazupon.github.io/vue-i18n/)
31 | - Login using [JWT](https://jwt.io/) with [Vue-Auth](https://websanova.com/docs/vue-auth/home), [Axios](https://github.com/mzabriskie/axios) and [Sanctum](https://laravel.com/docs/8.x/sanctum).
32 | - The api routes, are separate for each module, in **Modules/{ModuleName}/routes_api.php**
33 | - [ElementUI](http://element.eleme.io/) UI Kit
34 | - [Lodash](https://lodash.com) js utilities
35 | - [Moment](https://momentjs.com) time manipulations
36 | - [FontAwesome 5](http://fontawesome.io/icons/) icons
37 |
38 | ## Install
39 | - `git clone https://github.com/Yurich84/laravel-vue-spa-skeleton.git`
40 | - `cd laravel-vue-spa-skeleton`
41 | - `composer install`
42 | - `cp .env.example .env` - copy .env file
43 | - set your DB credentials in `.env`
44 | - `php artisan key:generate`
45 | - `php artisan migrate`
46 | - `yarn install`
47 |
48 | ## Testing
49 |
50 | ### Unit Testing
51 | `php artisan test`
52 |
53 | ## Usage
54 | - `npm run watch` or `npm run hot` - for hot reloading
55 | - `php artisan serve` and go [127.0.0.1:8000](http://127.0.0.1:8000)
56 | - Create new user and login.
57 |
58 | ### Creating module
59 | You can easily create module with CRUD functionality.
60 |
61 | `php artisan make:module {ModuleName}`
62 |
63 | This will create:
64 |
65 | - **migration** `database/migrations/000_00_00_000000_create_{ModuleName}_table.php`
66 |
67 | - **model** `app/Models/{ModuleName}.php`
68 |
69 | - **factory** `database/factories/{ModuleName}Factory.php`
70 |
71 | - **tests** `tests/Feature/{ModuleName}Test.php`
72 |
73 | - **backend module** `app/Modules/{ModuleName}/`
74 | ```
75 | {ModuleName}/
76 | │
77 | ├── routes_api.php
78 | │
79 | ├── Controllers/
80 | │ └── {ModuleName}Controller.php
81 | │
82 | ├── Requests/
83 | │ └── {ModuleName}Request.php
84 | │
85 | └── Resources/
86 | └── {ModuleName}Resource.php
87 | ```
88 |
89 | - **frontend module** `resources/js/modules/{moduleName}/`
90 | ```
91 | {moduleName}/
92 | │
93 | ├── routes.js
94 | │
95 | ├── api/
96 | │ └── index.js
97 | │
98 | ├── components/
99 | │ ├── {ModuleName}List.vue
100 | │ ├── {ModuleName}View.vue
101 | │ └── {ModuleName}Form.vue
102 | │
103 | └── store/
104 | ├── store.js
105 | ├── types.js
106 | └── actions.js
107 | ```
108 |
109 |
110 | > After creating module, you can edit model and migration by adding fields you need.
111 | > Also you can add this fields into view.
112 | > Don't forget run php artisan migrate.
113 |
114 | Every module loads dynamically.
115 |
116 | ## [Video](https://www.youtube.com/watch?v=0qKNlrmhgNg)
117 |
--------------------------------------------------------------------------------
/app/Console/Commands/MakeBackEndModule.php:
--------------------------------------------------------------------------------
1 | output = new ConsoleOutput();
18 | }
19 |
20 | /**
21 | * @var string
22 | */
23 | private $module_path;
24 |
25 | /**
26 | * @param $module
27 | * @throws FileNotFoundException
28 | */
29 | protected function create($module) {
30 | $this->files = new Filesystem();
31 | $this->module = $module;
32 | $this->module_path = app_path('Modules/'.$this->module);
33 |
34 | $this->createController();
35 | $this->createRoutes();
36 | $this->createRequest();
37 | $this->createResource();
38 | }
39 |
40 | /**
41 | * Create a controller for the module.
42 | *
43 | * @return void
44 | * @throws FileNotFoundException
45 | */
46 | private function createController()
47 | {
48 | $path = $this->module_path."/Controllers/{$this->module}Controller.php";
49 |
50 | if ($this->alreadyExists($path)) {
51 | $this->error('Controller already exists!');
52 | } else {
53 | $stub = $this->files->get(base_path('stubs/backEnd/controller.api.stub'));
54 |
55 | $this->createFileWithStub($stub, $path);
56 |
57 | $this->info('Controller created successfully.');
58 | }
59 | }
60 |
61 | /**
62 | * Create a Routes for the module.
63 | *
64 | * @throws FileNotFoundException
65 | */
66 | private function createRoutes() {
67 | $path = $this->module_path.'/routes_api.php';
68 |
69 | if ($this->alreadyExists($path)) {
70 | $this->error('Routes already exists!');
71 | } else {
72 | $stub = $this->files->get(base_path('stubs/backEnd/routes.api.stub'));
73 |
74 | $this->createFileWithStub($stub, $path);
75 |
76 | $this->info('Routes created successfully.');
77 | }
78 | }
79 |
80 | /**
81 | * Create a Request for the module.
82 | *
83 | * @throws FileNotFoundException
84 | */
85 | private function createRequest()
86 | {
87 | $path = $this->module_path."/Requests/{$this->module}Request.php";
88 |
89 | if ($this->alreadyExists($path)) {
90 | $this->error('Request already exists!');
91 | } else {
92 | $stub = $this->files->get(base_path('stubs/backEnd/request.stub'));
93 |
94 | $this->createFileWithStub($stub, $path);
95 |
96 | $this->info('Request created successfully.');
97 | }
98 | }
99 |
100 | /**
101 | * Create a Resource for the module.
102 | *
103 | * @throws FileNotFoundException
104 | */
105 | private function createResource()
106 | {
107 | $path = $this->module_path."/Resources/{$this->module}Resource.php";
108 |
109 | if ($this->alreadyExists($path)) {
110 | $this->error('Resource already exists!');
111 | } else {
112 | $stub = $this->files->get(base_path('stubs/backEnd/resource.stub'));
113 |
114 | $this->createFileWithStub($stub, $path);
115 |
116 | $this->info('Resource created successfully.');
117 | }
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/app/Console/Commands/MakeModuleCommand.php:
--------------------------------------------------------------------------------
1 | files = $files;
59 |
60 | $this->module = Str::of(class_basename($this->argument('name')))->studly()->singular();
61 |
62 | $this->createModel();
63 |
64 | $this->createMigration();
65 |
66 | $backEndModule->create($this->module);
67 |
68 | $frontEndModule->create($this->module);
69 |
70 | $this->createFactory();
71 |
72 | $this->createTest();
73 |
74 | }
75 |
76 | /**
77 | * Create a model file for the module.
78 | *
79 | * @return void
80 | */
81 | protected function createModel()
82 | {
83 | $this->call('make:model', [
84 | 'name' => $this->module,
85 | ]);
86 | }
87 |
88 | /**
89 | * Create a migration file for the module.
90 | *
91 | * @return void
92 | */
93 | protected function createMigration()
94 | {
95 | $table = $this->module->plural()->snake();
96 |
97 | try {
98 | $this->call('make:migration', [
99 | 'name' => "create_{$table}_table",
100 | '--create' => $table,
101 | ]);
102 | } catch (Exception $e) {
103 | $this->error($e->getMessage());
104 | }
105 | }
106 |
107 | /**
108 | * Create a factory file for the module.
109 | *
110 | * @return void
111 | */
112 | protected function createFactory()
113 | {
114 | $this->call('make:factory', [
115 | 'name' => $this->module.'Factory',
116 | '--model' => "$this->module",
117 | ]);
118 | }
119 |
120 | /**
121 | * Create a test file for the module.
122 | *
123 | * @return void
124 | * @throws FileNotFoundException
125 | */
126 | protected function createTest()
127 | {
128 | $path = base_path('tests/Feature/'.$this->module.'Test.php');
129 |
130 | if ($this->alreadyExists($path)) {
131 | $this->error('Test file already exists!');
132 | } else {
133 | $stub = (new Filesystem)->get(base_path('stubs/test.stub'));
134 |
135 | $this->createFileWithStub($stub, $path);
136 |
137 | $this->info('Tests created successfully.');
138 | }
139 | }
140 |
141 | /**
142 | * Determine if the class already exists.
143 | *
144 | * @param string $path
145 | * @return bool
146 | */
147 | protected function alreadyExists($path)
148 | {
149 | return $this->files->exists($path);
150 | }
151 |
152 | /**
153 | * Build the directory for the class if necessary.
154 | *
155 | * @param string $path
156 | * @return string
157 | */
158 | protected function makeDirectory($path)
159 | {
160 | if (! $this->files->isDirectory(dirname($path))) {
161 | $this->files->makeDirectory(dirname($path), 0777, true, true);
162 | }
163 |
164 | return $path;
165 | }
166 |
167 | /**
168 | * @param $stub
169 | * @param $path
170 | * @return void
171 | */
172 | protected function createFileWithStub($stub, $path)
173 | {
174 | $this->makeDirectory($path);
175 |
176 | $content = str_replace([
177 | 'DummyRootNamespace',
178 | 'DummySingular',
179 | 'DummyPlural',
180 | 'DUMMY_VARIABLE_SINGULAR',
181 | 'DUMMY_VARIABLE_PLURAL',
182 | 'dummyVariableSingular',
183 | 'dummyVariablePlural',
184 | 'dummy-plural',
185 | ], [
186 | App::getNamespace(),
187 | $this->module,
188 | $this->module->pluralStudly(),
189 | $this->module->snake()->upper(),
190 | $this->module->plural()->snake()->upper(),
191 | lcfirst($this->module),
192 | lcfirst($this->module->pluralStudly()),
193 | lcfirst($this->module->plural()->snake('-')),
194 | ],
195 | $stub
196 | );
197 |
198 | $this->files->put($path, $content);
199 | }
200 | }
201 |
--------------------------------------------------------------------------------
/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/Contracts/RepositoryInterface.php:
--------------------------------------------------------------------------------
1 | [__('You must :linkOpen verify :linkClose your email first.', [
18 | 'linkOpen' => '',
19 | 'linkClose' => '',
20 | ])],
21 | ]);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/app/Http/Controllers/Controller.php:
--------------------------------------------------------------------------------
1 | [
31 | \App\Http\Middleware\EncryptCookies::class,
32 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
33 | \Illuminate\Session\Middleware\StartSession::class,
34 | // \Illuminate\Session\Middleware\AuthenticateSession::class,
35 | \Illuminate\View\Middleware\ShareErrorsFromSession::class,
36 | \App\Http\Middleware\VerifyCsrfToken::class,
37 | \Illuminate\Routing\Middleware\SubstituteBindings::class,
38 | ],
39 |
40 | 'api' => [
41 | // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, // check if using the same domain
42 | // 'throttle:api',
43 | \Illuminate\Routing\Middleware\SubstituteBindings::class,
44 | ],
45 | ];
46 |
47 | /**
48 | * The application's route middleware.
49 | *
50 | * These middleware may be assigned to groups or used individually.
51 | *
52 | * @var array
53 | */
54 | protected $routeMiddleware = [
55 | 'auth' => \App\Http\Middleware\Authenticate::class,
56 | 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
57 | 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
58 | 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
59 | 'can' => \Illuminate\Auth\Middleware\Authorize::class,
60 | 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
61 | 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
62 | 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
63 | 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
64 | 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
65 | ];
66 |
67 | /**
68 | * The priority-sorted list of middleware.
69 | *
70 | * This forces non-global middleware to always be in the given order.
71 | *
72 | * @var array
73 | */
74 | protected $middlewarePriority = [
75 | \Illuminate\Session\Middleware\StartSession::class,
76 | \Illuminate\View\Middleware\ShareErrorsFromSession::class,
77 | \App\Http\Middleware\Authenticate::class,
78 | \Illuminate\Routing\Middleware\ThrottleRequests::class,
79 | \Illuminate\Session\Middleware\AuthenticateSession::class,
80 | \Illuminate\Routing\Middleware\SubstituteBindings::class,
81 | \Illuminate\Auth\Middleware\Authorize::class,
82 | ];
83 | }
84 |
--------------------------------------------------------------------------------
/app/Http/Middleware/Authenticate.php:
--------------------------------------------------------------------------------
1 | expectsJson()) {
18 | abort(403);
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/app/Http/Middleware/CheckForMaintenanceMode.php:
--------------------------------------------------------------------------------
1 | check()) {
22 | return redirect(RouteServiceProvider::HOME);
23 | }
24 |
25 | return $next($request);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/Http/Middleware/TrimStrings.php:
--------------------------------------------------------------------------------
1 | 'datetime',
51 | ];
52 |
53 | /**
54 | * The accessors to append to the model's array form.
55 | *
56 | * @var array
57 | */
58 | protected $appends = [
59 | 'avatar',
60 | ];
61 |
62 | /**
63 | * Get the profile photo URL attribute.
64 | *
65 | * @return string
66 | */
67 | public function getAvatarAttribute()
68 | {
69 | return 'https://www.gravatar.com/avatar/'.md5(strtolower($this->email)).'.jpg?s=200&d=mm';
70 | }
71 |
72 | /**
73 | * Send the password reset notification.
74 | *
75 | * @param string $token
76 | * @return void
77 | */
78 | public function sendPasswordResetNotification($token)
79 | {
80 | $this->notify(new ResetPassword($token));
81 | }
82 |
83 | /**
84 | * Send the email verification notification.
85 | *
86 | * @return void
87 | */
88 | public function sendEmailVerificationNotification()
89 | {
90 | $this->notify(new VerifyEmail);
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/app/Modules/Auth/Controllers/ForgotPasswordController.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
41 | */
42 | protected function sendResetLinkFailedResponse(Request $request, $response)
43 | {
44 | return response()->json(['email' => trans($response)], 400);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/app/Modules/Auth/Controllers/LoginController.php:
--------------------------------------------------------------------------------
1 | middleware('guest')->except('logout');
29 | }
30 |
31 | protected function setToken(string $token): void
32 | {
33 | $this->token = $token;
34 | }
35 |
36 | /**
37 | * Attempt to log the user into the application.
38 | *
39 | * @param Request $request
40 | * @return bool
41 | */
42 | protected function attemptLogin(Request $request)
43 | {
44 | $user = User::where('email', strtolower($request->input($this->username())))->first();
45 |
46 | if (! $user || ! Hash::check($request->password, $user->password)) {
47 | return false;
48 | }
49 |
50 | $this->guard()->setUser($user);
51 |
52 | if ($user instanceof MustVerifyEmail && ! $user->hasVerifiedEmail()) {
53 | return false;
54 | }
55 |
56 | $this->setToken($user->createToken($request->device_name)->plainTextToken);
57 |
58 | return true;
59 | }
60 |
61 | /**
62 | * Send the response after the user was authenticated.
63 | *
64 | * @param Request $request
65 | * @return JsonResponse
66 | */
67 | protected function sendLoginResponse(Request $request)
68 | {
69 | $this->clearLoginAttempts($request);
70 |
71 | return response()->json([
72 | 'token' => $this->token,
73 | ])->header('Authorization', $this->token);
74 | }
75 |
76 | /**
77 | * Get the failed login response instance.
78 | *
79 | * @param Request $request
80 | * @return void
81 | *
82 | * @throws ValidationException
83 | * @throws VerifyEmailException
84 | */
85 | protected function sendFailedLoginResponse(Request $request)
86 | {
87 | $user = $this->guard()->user();
88 | if ($user instanceof MustVerifyEmail && ! $user->hasVerifiedEmail()) {
89 | throw VerifyEmailException::forUser($user);
90 | }
91 |
92 | throw ValidationException::withMessages([
93 | $this->username() => [trans('auth.failed')],
94 | ]);
95 | }
96 |
97 | /**
98 | * Log the user out of the application.
99 | *
100 | * @param Request $request
101 | * @return void
102 | */
103 | public function logout(Request $request)
104 | {
105 | $request->user()->currentAccessToken()->delete();
106 | app()->get('auth')->forgetGuards();
107 | auth('web')->logout();
108 | }
109 |
110 | /**
111 | * Validate the user login request.
112 | *
113 | * @param Request $request
114 | * @return void
115 | */
116 | protected function validateLogin(Request $request): void
117 | {
118 | $request->validate([
119 | $this->username() => 'required|string',
120 | 'password' => 'required|string',
121 | 'device_name' => 'required|string',
122 | ]);
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/app/Modules/Auth/Controllers/RegisterController.php:
--------------------------------------------------------------------------------
1 | middleware('guest');
25 | }
26 |
27 | /**
28 | * The user has been registered.
29 | *
30 | * @param Request $request
31 | * @param User $user
32 | * @return JsonResponse
33 | */
34 | protected function registered(Request $request, User $user)
35 | {
36 | if ($user instanceof MustVerifyEmail) {
37 | return response()->json(['status' => trans('verification.sent')]);
38 | }
39 |
40 | return response()->json($user);
41 | }
42 |
43 | /**
44 | * Get a validator for an incoming registration request.
45 | *
46 | * @param array $data
47 | * @return \Illuminate\Contracts\Validation\Validator
48 | */
49 | protected function validator(array $data)
50 | {
51 | return Validator::make($data, [
52 | 'name' => 'required|max:255',
53 | 'email' => 'required|email|max:255|unique:users',
54 | 'password' => 'required|min:6|confirmed',
55 | ]);
56 | }
57 |
58 | /**
59 | * Create a new user instance after a valid registration.
60 | *
61 | * @param array $data
62 | * @return User
63 | */
64 | protected function create(array $data)
65 | {
66 | return User::create([
67 | 'name' => $data['name'],
68 | 'email' => $data['email'],
69 | 'password' => bcrypt($data['password']),
70 | ]);
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/app/Modules/Auth/Controllers/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
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
41 | */
42 | protected function sendResetFailedResponse(Request $request, $response)
43 | {
44 | return response()->json(['email' => trans($response)], 400);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/app/Modules/Auth/Controllers/UserController.php:
--------------------------------------------------------------------------------
1 | json([
18 | 'data' => auth()->user(),
19 | ]);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/app/Modules/Auth/Controllers/VerificationController.php:
--------------------------------------------------------------------------------
1 | middleware('throttle:6,1')->only('verify', 'resend');
23 | }
24 |
25 | /**
26 | * Mark the user's email address as verified.
27 | *
28 | * @param Request $request
29 | * @param User $user
30 | * @return JsonResponse
31 | */
32 | public function verify(Request $request, User $user)
33 | {
34 | if (! URL::hasValidSignature($request)) {
35 | return response()->json([
36 | 'status' => trans('verification.invalid'),
37 | ], 400);
38 | }
39 |
40 | if ($user->hasVerifiedEmail()) {
41 | return response()->json([
42 | 'status' => trans('verification.already_verified'),
43 | ], 400);
44 | }
45 |
46 | $user->markEmailAsVerified();
47 |
48 | event(new Verified($user));
49 |
50 | return response()->json([
51 | 'status' => trans('verification.verified'),
52 | ]);
53 | }
54 |
55 | /**
56 | * Resend the email verification notification.
57 | *
58 | * @param Request $request
59 | * @return JsonResponse
60 | * @throws ValidationException
61 | */
62 | public function resend(Request $request)
63 | {
64 | $this->validate($request, ['email' => 'required|email']);
65 |
66 | /** @var User $user */
67 | $user = User::where('email', $request->email)->first();
68 |
69 | if (is_null($user)) {
70 | throw ValidationException::withMessages([
71 | 'email' => [trans('verification.user')],
72 | ]);
73 | }
74 |
75 | if ($user->hasVerifiedEmail()) {
76 | throw ValidationException::withMessages([
77 | 'email' => [trans('verification.already_verified')],
78 | ]);
79 | }
80 |
81 | $user->sendEmailVerificationNotification();
82 |
83 | return response()->json(['status' => trans('verification.sent')]);
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/app/Modules/Auth/routes_api.php:
--------------------------------------------------------------------------------
1 | group(function () {
6 | Route::withoutMiddleware('auth:sanctum')->group(function () {
7 | Route::post('login', 'LoginController@login')->name('login');
8 | Route::post('register', 'RegisterController@register')->name('register');
9 |
10 | Route::post('password/email', 'ForgotPasswordController@sendResetLinkEmail')->name('password.reset-email');
11 | Route::post('password/reset', 'ResetPasswordController@reset')->name('password.reset');
12 |
13 | Route::post('email/verify/{user}', 'VerificationController@verify')->name('verification.verify');
14 | Route::post('email/resend', 'VerificationController@resend')->name('verification.resend');
15 | });
16 |
17 | Route::post('logout', 'LoginController@logout')->name('logout');
18 | Route::post('me', 'UserController@me')->name('me');
19 | });
20 |
--------------------------------------------------------------------------------
/app/Modules/Setting/Controllers/ProfileController.php:
--------------------------------------------------------------------------------
1 | user();
22 |
23 | $data = $profileRequest->validated();
24 | $user->fill($data)->save();
25 |
26 | return response()->json([
27 | 'type' => self::RESPONSE_TYPE_SUCCESS,
28 | 'message' => 'Successfully updated',
29 | ]);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/Modules/Setting/Requests/ProfileRequest.php:
--------------------------------------------------------------------------------
1 | 'required|string',
29 | User::COLUMN_EMAIL => 'required|email|unique:users,email,'.auth()->id(),
30 | ];
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/app/Modules/Setting/routes_api.php:
--------------------------------------------------------------------------------
1 | group(function () {
6 | Route::patch('profile', 'ProfileController@update')->name('profile.update');
7 | });
8 |
--------------------------------------------------------------------------------
/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.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/Notifications/VerifyEmail.php:
--------------------------------------------------------------------------------
1 | addMinutes(60), ['user' => $notifiable->id]
21 | );
22 |
23 | return str_replace('/api/v1/auth', '', $url);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/app/Providers/AppServiceProvider.php:
--------------------------------------------------------------------------------
1 | 'App\Policies\ModelPolicy',
16 | ];
17 |
18 | /**
19 | * Register any authentication / authorization services.
20 | *
21 | * @return void
22 | */
23 | public function boot()
24 | {
25 | $this->registerPolicies();
26 |
27 | //
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/Providers/BroadcastServiceProvider.php:
--------------------------------------------------------------------------------
1 | ['auth:sanctum']]);
18 |
19 | require base_path('routes/channels.php');
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/app/Providers/EventServiceProvider.php:
--------------------------------------------------------------------------------
1 | [
19 | SendEmailVerificationNotification::class,
20 | ],
21 | ];
22 |
23 | /**
24 | * Register any events for your application.
25 | *
26 | * @return void
27 | */
28 | public function boot()
29 | {
30 | parent::boot();
31 |
32 | //
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/Providers/RouteServiceProvider.php:
--------------------------------------------------------------------------------
1 | mapApiRoutes();
53 |
54 | $this->mapModulesRoutes();
55 |
56 | $this->mapWebRoutes();
57 |
58 | $this->mapSPARoutes();
59 | }
60 |
61 | /**
62 | * Define the "web" routes for the application.
63 | *
64 | * These routes all receive session state, CSRF protection, etc.
65 | *
66 | * @return void
67 | */
68 | protected function mapWebRoutes()
69 | {
70 | Route::middleware('web')
71 | ->namespace($this->namespace)
72 | ->group(base_path('routes/web.php'));
73 | }
74 |
75 | /**
76 | * Define the "api" routes for the application.
77 | *
78 | * These routes are typically stateless.
79 | *
80 | * @return void
81 | */
82 | protected function mapApiRoutes()
83 | {
84 | Route::prefix(self::API_PREFIX)
85 | ->middleware('api')
86 | ->namespace($this->namespace)
87 | ->group(base_path('routes/api.php'));
88 | }
89 |
90 | /**
91 | * All non matchable resources we will show standard Vue page,.
92 | *
93 | * and redirect it through VueRoutes on client side
94 | *
95 | * @return void
96 | */
97 | protected function mapSPARoutes()
98 | {
99 | Route::namespace($this->namespace)
100 | ->middleware('web')
101 | ->group(function () {
102 | Route::view('/{any}', 'spa')
103 | ->where('any', '.*');
104 | });
105 | }
106 |
107 | /**
108 | * Define the "modules" routes for the application.
109 | *
110 | * These routes are typically stateless.
111 | *
112 | * @return void
113 | */
114 | protected function mapModulesRoutes()
115 | {
116 | $modules_folder = app_path('Modules');
117 | $modules = $this->getModulesList($modules_folder);
118 |
119 | foreach ($modules as $module) {
120 | $routesPath = $modules_folder.DIRECTORY_SEPARATOR.$module.DIRECTORY_SEPARATOR.'routes_api.php';
121 |
122 | if (file_exists($routesPath)) {
123 | Route::prefix(self::API_PREFIX)
124 | ->middleware(['api', 'auth:sanctum'])
125 | ->namespace("\\App\\Modules\\$module\Controllers")
126 | ->group($routesPath);
127 | }
128 | }
129 | }
130 |
131 | /**
132 | * @param string $modules_folder
133 | * @return array
134 | */
135 | private function getModulesList(string $modules_folder): array
136 | {
137 | return
138 | array_values(
139 | array_filter(
140 | scandir($modules_folder),
141 | function ($item) use ($modules_folder) {
142 | return is_dir($modules_folder.DIRECTORY_SEPARATOR.$item) && ! in_array($item, ['.', '..']);
143 | }
144 | )
145 | );
146 | }
147 | }
148 |
--------------------------------------------------------------------------------
/app/Repositories/AbstractRepository.php:
--------------------------------------------------------------------------------
1 | class) {
26 | $this->model = new $this->class();
27 | }
28 | }
29 |
30 | /**
31 | * @param int $id
32 | * @return Model|null
33 | */
34 | public function get(int $id): ?Model
35 | {
36 | return $this->model::find($id);
37 | }
38 |
39 | /**
40 | * @param array $data
41 | * @return Model|null
42 | */
43 | public function create(array $data): ?Model
44 | {
45 | return $this->model::create($data);
46 | }
47 |
48 | /**
49 | * @param array $data
50 | * @param Model $model
51 | * @return Model
52 | */
53 | public function update(array $data, Model $model): Model
54 | {
55 | $model->fill($data)->save();
56 |
57 | return $model;
58 | }
59 |
60 | /**
61 | * @param $id
62 | * @return bool
63 | * @throws \Exception
64 | */
65 | public function delete(int $id): bool
66 | {
67 | return $this->model::destroy($id);
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/app/Repositories/UserRepository.php:
--------------------------------------------------------------------------------
1 | make(Illuminate\Contracts\Console\Kernel::class);
34 |
35 | $status = $kernel->handle(
36 | $input = new Symfony\Component\Console\Input\ArgvInput,
37 | new Symfony\Component\Console\Output\ConsoleOutput
38 | );
39 |
40 | /*
41 | |--------------------------------------------------------------------------
42 | | Shutdown The Application
43 | |--------------------------------------------------------------------------
44 | |
45 | | Once Artisan has finished running, we will fire off the shutdown events
46 | | so that any final work may be done by the application before we shut
47 | | down the process. This is the last thing to happen to the request.
48 | |
49 | */
50 |
51 | $kernel->terminate($input, $status);
52 |
53 | exit($status);
54 |
--------------------------------------------------------------------------------
/bootstrap/app.php:
--------------------------------------------------------------------------------
1 | singleton(
30 | Illuminate\Contracts\Http\Kernel::class,
31 | App\Http\Kernel::class
32 | );
33 |
34 | $app->singleton(
35 | Illuminate\Contracts\Console\Kernel::class,
36 | App\Console\Kernel::class
37 | );
38 |
39 | $app->singleton(
40 | Illuminate\Contracts\Debug\ExceptionHandler::class,
41 | App\Exceptions\Handler::class
42 | );
43 |
44 | /*
45 | |--------------------------------------------------------------------------
46 | | Return The Application
47 | |--------------------------------------------------------------------------
48 | |
49 | | This script returns the application instance. The instance is given to
50 | | the calling script so we can separate the building of the instances
51 | | from the actual running of the application and sending responses.
52 | |
53 | */
54 |
55 | return $app;
56 |
--------------------------------------------------------------------------------
/bootstrap/cache/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "laravel/laravel",
3 | "type": "project",
4 | "description": "The Laravel Framework.",
5 | "keywords": [
6 | "framework",
7 | "laravel"
8 | ],
9 | "license": "MIT",
10 | "require": {
11 | "php": "^8.0",
12 | "ext-json": "*",
13 | "fideloper/proxy": "^4.2",
14 | "fruitcake/laravel-cors": "^2.0",
15 | "guzzlehttp/guzzle": "^7.0.1",
16 | "laravel/framework": "^8.77",
17 | "laravel/sanctum": "^2.14",
18 | "laravel/tinker": "^v2.4.2",
19 | "laravel/ui": "^3.3"
20 | },
21 | "require-dev": {
22 | "brianium/paratest": "^6.4",
23 | "facade/ignition": "^2.17",
24 | "fakerphp/faker": "^1.9.1",
25 | "matt-allan/laravel-code-style": "^0.7.0",
26 | "mockery/mockery": "^1.4",
27 | "nunomaduro/collision": "^5.0",
28 | "phpunit/phpunit": "^9.5"
29 | },
30 | "config": {
31 | "optimize-autoloader": true,
32 | "preferred-install": "dist",
33 | "sort-packages": true
34 | },
35 | "extra": {
36 | "laravel": {
37 | "dont-discover": []
38 | }
39 | },
40 | "autoload": {
41 | "psr-4": {
42 | "App\\": "app/",
43 | "Database\\Factories\\": "database/factories/",
44 | "Database\\Seeders\\": "database/seeders/"
45 | }
46 | },
47 | "autoload-dev": {
48 | "psr-4": {
49 | "Tests\\": "tests/"
50 | }
51 | },
52 | "minimum-stability": "dev",
53 | "prefer-stable": true,
54 | "scripts": {
55 | "post-autoload-dump": [
56 | "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
57 | "@php artisan package:discover --ansi"
58 | ],
59 | "post-root-package-install": [
60 | "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
61 | ],
62 | "post-create-project-cmd": [
63 | "@php artisan key:generate --ansi"
64 | ],
65 | "clear-all": [
66 | "@php artisan clear-compiled",
67 | "@php artisan cache:clear",
68 | "@php artisan route:clear",
69 | "@php artisan view:clear",
70 | "@php artisan config:clear",
71 | "composer dumpautoload -o"
72 | ],
73 | "cache-all": [
74 | "@php artisan config:cache",
75 | "@php artisan route:cache"
76 | ],
77 | "test": "@php artisan test --parallel",
78 | "check-style": "php-cs-fixer fix --dry-run --diff",
79 | "fix-style": "php-cs-fixer fix"
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/config/auth.php:
--------------------------------------------------------------------------------
1 | [
17 | 'guard' => 'web',
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' => 'sanctum',
46 | 'provider' => 'users',
47 | 'hash' => false,
48 | ],
49 | ],
50 |
51 | /*
52 | |--------------------------------------------------------------------------
53 | | User Providers
54 | |--------------------------------------------------------------------------
55 | |
56 | | All authentication drivers have a user provider. This defines how the
57 | | users are actually retrieved out of your database or other storage
58 | | mechanisms used by this application to persist your user's data.
59 | |
60 | | If you have multiple user tables or models you may configure multiple
61 | | sources which represent each model / table. These sources may then
62 | | be assigned to any extra authentication guards you have defined.
63 | |
64 | | Supported: "database", "eloquent"
65 | |
66 | */
67 |
68 | 'providers' => [
69 | 'users' => [
70 | 'driver' => 'eloquent',
71 | 'model' => App\Models\User::class,
72 | ],
73 |
74 | // 'users' => [
75 | // 'driver' => 'database',
76 | // 'table' => 'users',
77 | // ],
78 | ],
79 |
80 | /*
81 | |--------------------------------------------------------------------------
82 | | Resetting Passwords
83 | |--------------------------------------------------------------------------
84 | |
85 | | You may specify multiple password reset configurations if you have more
86 | | than one user table or model in the application and you want to have
87 | | separate password reset settings based on the specific user types.
88 | |
89 | | The expire time is the number of minutes that the reset token should be
90 | | considered valid. This security feature keeps tokens short-lived so
91 | | they have less time to be guessed. You may change this as needed.
92 | |
93 | */
94 |
95 | 'passwords' => [
96 | 'users' => [
97 | 'provider' => 'users',
98 | 'table' => 'password_resets',
99 | 'expire' => 60,
100 | 'throttle' => 60,
101 | ],
102 | ],
103 |
104 | /*
105 | |--------------------------------------------------------------------------
106 | | Password Confirmation Timeout
107 | |--------------------------------------------------------------------------
108 | |
109 | | Here you may define the amount of seconds before a password confirmation
110 | | times out and the user is prompted to re-enter their password via the
111 | | confirmation screen. By default, the timeout lasts for three hours.
112 | |
113 | */
114 |
115 | 'password_timeout' => 10800,
116 |
117 | ];
118 |
--------------------------------------------------------------------------------
/config/broadcasting.php:
--------------------------------------------------------------------------------
1 | env('BROADCAST_DRIVER', 'null'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Broadcast Connections
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may define all of the broadcast connections that will be used
26 | | to broadcast events to other systems or over websockets. Samples of
27 | | each available type of connection are provided inside this array.
28 | |
29 | */
30 |
31 | 'connections' => [
32 |
33 | 'pusher' => [
34 | 'driver' => 'pusher',
35 | 'key' => env('PUSHER_APP_KEY'),
36 | 'secret' => env('PUSHER_APP_SECRET'),
37 | 'app_id' => env('PUSHER_APP_ID'),
38 | 'options' => [
39 | 'cluster' => env('PUSHER_APP_CLUSTER'),
40 | 'useTLS' => true,
41 | ],
42 | ],
43 |
44 | 'redis' => [
45 | 'driver' => 'redis',
46 | 'connection' => 'default',
47 | ],
48 |
49 | 'log' => [
50 | 'driver' => 'log',
51 | ],
52 |
53 | 'null' => [
54 | 'driver' => 'null',
55 | ],
56 |
57 | ],
58 |
59 | ];
60 |
--------------------------------------------------------------------------------
/config/cache.php:
--------------------------------------------------------------------------------
1 | env('CACHE_DRIVER', 'file'),
22 |
23 | /*
24 | |--------------------------------------------------------------------------
25 | | Cache Stores
26 | |--------------------------------------------------------------------------
27 | |
28 | | Here you may define all of the cache "stores" for your application as
29 | | well as their drivers. You may even define multiple stores for the
30 | | same cache driver to group types of items stored in your caches.
31 | |
32 | */
33 |
34 | 'stores' => [
35 |
36 | 'apc' => [
37 | 'driver' => 'apc',
38 | ],
39 |
40 | 'array' => [
41 | 'driver' => 'array',
42 | ],
43 |
44 | 'database' => [
45 | 'driver' => 'database',
46 | 'table' => 'cache',
47 | 'connection' => null,
48 | ],
49 |
50 | 'file' => [
51 | 'driver' => 'file',
52 | 'path' => storage_path('framework/cache/data'),
53 | ],
54 |
55 | 'memcached' => [
56 | 'driver' => 'memcached',
57 | 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'),
58 | 'sasl' => [
59 | env('MEMCACHED_USERNAME'),
60 | env('MEMCACHED_PASSWORD'),
61 | ],
62 | 'options' => [
63 | // Memcached::OPT_CONNECT_TIMEOUT => 2000,
64 | ],
65 | 'servers' => [
66 | [
67 | 'host' => env('MEMCACHED_HOST', '127.0.0.1'),
68 | 'port' => env('MEMCACHED_PORT', 11211),
69 | 'weight' => 100,
70 | ],
71 | ],
72 | ],
73 |
74 | 'redis' => [
75 | 'driver' => 'redis',
76 | 'connection' => 'cache',
77 | ],
78 |
79 | 'dynamodb' => [
80 | 'driver' => 'dynamodb',
81 | 'key' => env('AWS_ACCESS_KEY_ID'),
82 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
83 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
84 | 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
85 | 'endpoint' => env('DYNAMODB_ENDPOINT'),
86 | ],
87 |
88 | ],
89 |
90 | /*
91 | |--------------------------------------------------------------------------
92 | | Cache Key Prefix
93 | |--------------------------------------------------------------------------
94 | |
95 | | When utilizing a RAM based store such as APC or Memcached, there might
96 | | be other applications utilizing the same cache. So, we'll specify a
97 | | value to get prefixed to all our keys so we can avoid collisions.
98 | |
99 | */
100 |
101 | 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'),
102 |
103 | ];
104 |
--------------------------------------------------------------------------------
/config/database.php:
--------------------------------------------------------------------------------
1 | env('DB_CONNECTION', 'mysql'),
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Database Connections
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here are each of the database connections setup for your application.
26 | | Of course, examples of configuring each database platform that is
27 | | supported by Laravel is shown below to make development simple.
28 | |
29 | |
30 | | All database work in Laravel is done through the PHP PDO facilities
31 | | so make sure you have the driver for your particular database of
32 | | choice installed on your machine before you begin development.
33 | |
34 | */
35 |
36 | 'connections' => [
37 |
38 | 'sqlite' => [
39 | 'driver' => 'sqlite',
40 | 'url' => env('DATABASE_URL'),
41 | 'database' => env('DB_DATABASE', database_path('database.sqlite')),
42 | 'prefix' => '',
43 | 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
44 | ],
45 |
46 | 'sqlite_dusk' => [
47 | 'driver' => 'sqlite',
48 | 'url' => env('DATABASE_URL'),
49 | 'database' => env('DB_DATABASE', database_path('database.sqlite')),
50 | 'prefix' => '',
51 | 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
52 | ],
53 |
54 | 'mysql' => [
55 | 'driver' => 'mysql',
56 | 'url' => env('DATABASE_URL'),
57 | 'host' => env('DB_HOST', '127.0.0.1'),
58 | 'port' => env('DB_PORT', '3306'),
59 | 'database' => env('DB_DATABASE', 'forge'),
60 | 'username' => env('DB_USERNAME', 'forge'),
61 | 'password' => env('DB_PASSWORD', ''),
62 | 'unix_socket' => env('DB_SOCKET', ''),
63 | 'charset' => 'utf8mb4',
64 | 'collation' => 'utf8mb4_unicode_ci',
65 | 'prefix' => '',
66 | 'prefix_indexes' => true,
67 | 'strict' => true,
68 | 'engine' => null,
69 | 'options' => extension_loaded('pdo_mysql') ? array_filter([
70 | PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
71 | ]) : [],
72 | ],
73 |
74 | 'pgsql' => [
75 | 'driver' => 'pgsql',
76 | 'url' => env('DATABASE_URL'),
77 | 'host' => env('DB_HOST', '127.0.0.1'),
78 | 'port' => env('DB_PORT', '5432'),
79 | 'database' => env('DB_DATABASE', 'forge'),
80 | 'username' => env('DB_USERNAME', 'forge'),
81 | 'password' => env('DB_PASSWORD', ''),
82 | 'charset' => 'utf8',
83 | 'prefix' => '',
84 | 'prefix_indexes' => true,
85 | 'schema' => 'public',
86 | 'sslmode' => 'prefer',
87 | ],
88 |
89 | 'sqlsrv' => [
90 | 'driver' => 'sqlsrv',
91 | 'url' => env('DATABASE_URL'),
92 | 'host' => env('DB_HOST', 'localhost'),
93 | 'port' => env('DB_PORT', '1433'),
94 | 'database' => env('DB_DATABASE', 'forge'),
95 | 'username' => env('DB_USERNAME', 'forge'),
96 | 'password' => env('DB_PASSWORD', ''),
97 | 'charset' => 'utf8',
98 | 'prefix' => '',
99 | 'prefix_indexes' => true,
100 | ],
101 |
102 | ],
103 |
104 | /*
105 | |--------------------------------------------------------------------------
106 | | Migration Repository Table
107 | |--------------------------------------------------------------------------
108 | |
109 | | This table keeps track of all the migrations that have already run for
110 | | your application. Using this information, we can determine which of
111 | | the migrations on disk haven't actually been run in the database.
112 | |
113 | */
114 |
115 | 'migrations' => 'migrations',
116 |
117 | /*
118 | |--------------------------------------------------------------------------
119 | | Redis Databases
120 | |--------------------------------------------------------------------------
121 | |
122 | | Redis is an open source, fast, and advanced key-value store that also
123 | | provides a richer body of commands than a typical key-value system
124 | | such as APC or Memcached. Laravel makes it easy to dig right in.
125 | |
126 | */
127 |
128 | 'redis' => [
129 |
130 | 'client' => env('REDIS_CLIENT', 'phpredis'),
131 |
132 | 'options' => [
133 | 'cluster' => env('REDIS_CLUSTER', 'redis'),
134 | 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
135 | ],
136 |
137 | 'default' => [
138 | 'url' => env('REDIS_URL'),
139 | 'host' => env('REDIS_HOST', '127.0.0.1'),
140 | 'password' => env('REDIS_PASSWORD', null),
141 | 'port' => env('REDIS_PORT', '6379'),
142 | 'database' => env('REDIS_DB', '0'),
143 | ],
144 |
145 | 'cache' => [
146 | 'url' => env('REDIS_URL'),
147 | 'host' => env('REDIS_HOST', '127.0.0.1'),
148 | 'password' => env('REDIS_PASSWORD', null),
149 | 'port' => env('REDIS_PORT', '6379'),
150 | 'database' => env('REDIS_CACHE_DB', '1'),
151 | ],
152 |
153 | ],
154 |
155 | ];
156 |
--------------------------------------------------------------------------------
/config/filesystems.php:
--------------------------------------------------------------------------------
1 | env('FILESYSTEM_DRIVER', 'local'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Default Cloud Filesystem Disk
21 | |--------------------------------------------------------------------------
22 | |
23 | | Many applications store files both locally and in the cloud. For this
24 | | reason, you may specify a default "cloud" driver here. This driver
25 | | will be bound as the Cloud disk implementation in the container.
26 | |
27 | */
28 |
29 | 'cloud' => env('FILESYSTEM_CLOUD', 's3'),
30 |
31 | /*
32 | |--------------------------------------------------------------------------
33 | | Filesystem Disks
34 | |--------------------------------------------------------------------------
35 | |
36 | | Here you may configure as many filesystem "disks" as you wish, and you
37 | | may even configure multiple disks of the same driver. Defaults have
38 | | been setup for each driver as an example of the required options.
39 | |
40 | | Supported Drivers: "local", "ftp", "sftp", "s3"
41 | |
42 | */
43 |
44 | 'disks' => [
45 |
46 | 'local' => [
47 | 'driver' => 'local',
48 | 'root' => storage_path('app'),
49 | ],
50 |
51 | 'public' => [
52 | 'driver' => 'local',
53 | 'root' => storage_path('app/public'),
54 | 'url' => env('APP_URL').'/storage',
55 | 'visibility' => 'public',
56 | ],
57 |
58 | 's3' => [
59 | 'driver' => 's3',
60 | 'key' => env('AWS_ACCESS_KEY_ID'),
61 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
62 | 'region' => env('AWS_DEFAULT_REGION'),
63 | 'bucket' => env('AWS_BUCKET'),
64 | 'url' => env('AWS_URL'),
65 | ],
66 |
67 | ],
68 |
69 | ];
70 |
--------------------------------------------------------------------------------
/config/hashing.php:
--------------------------------------------------------------------------------
1 | 'bcrypt',
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Bcrypt Options
23 | |--------------------------------------------------------------------------
24 | |
25 | | Here you may specify the configuration options that should be used when
26 | | passwords are hashed using the Bcrypt algorithm. This will allow you
27 | | to control the amount of time it takes to hash the given password.
28 | |
29 | */
30 |
31 | 'bcrypt' => [
32 | 'rounds' => env('BCRYPT_ROUNDS', 10),
33 | ],
34 |
35 | /*
36 | |--------------------------------------------------------------------------
37 | | Argon Options
38 | |--------------------------------------------------------------------------
39 | |
40 | | Here you may specify the configuration options that should be used when
41 | | passwords are hashed using the Argon algorithm. These will allow you
42 | | to control the amount of time it takes to hash the given password.
43 | |
44 | */
45 |
46 | 'argon' => [
47 | 'memory' => 1024,
48 | 'threads' => 2,
49 | 'time' => 2,
50 | ],
51 |
52 | ];
53 |
--------------------------------------------------------------------------------
/config/logging.php:
--------------------------------------------------------------------------------
1 | env('LOG_CHANNEL', 'stack'),
21 |
22 | /*
23 | |--------------------------------------------------------------------------
24 | | Log Channels
25 | |--------------------------------------------------------------------------
26 | |
27 | | Here you may configure the log channels for your application. Out of
28 | | the box, Laravel uses the Monolog PHP logging library. This gives
29 | | you a variety of powerful log handlers / formatters to utilize.
30 | |
31 | | Available Drivers: "single", "daily", "slack", "syslog",
32 | | "errorlog", "monolog",
33 | | "custom", "stack"
34 | |
35 | */
36 |
37 | 'channels' => [
38 | 'stack' => [
39 | 'driver' => 'stack',
40 | 'channels' => ['single'],
41 | 'ignore_exceptions' => false,
42 | ],
43 |
44 | 'single' => [
45 | 'driver' => 'single',
46 | 'path' => storage_path('logs/laravel.log'),
47 | 'level' => 'debug',
48 | ],
49 |
50 | 'daily' => [
51 | 'driver' => 'daily',
52 | 'path' => storage_path('logs/laravel.log'),
53 | 'level' => 'debug',
54 | 'days' => 14,
55 | ],
56 |
57 | 'slack' => [
58 | 'driver' => 'slack',
59 | 'url' => env('LOG_SLACK_WEBHOOK_URL'),
60 | 'username' => 'Laravel Log',
61 | 'emoji' => ':boom:',
62 | 'level' => 'critical',
63 | ],
64 |
65 | 'papertrail' => [
66 | 'driver' => 'monolog',
67 | 'level' => 'debug',
68 | 'handler' => SyslogUdpHandler::class,
69 | 'handler_with' => [
70 | 'host' => env('PAPERTRAIL_URL'),
71 | 'port' => env('PAPERTRAIL_PORT'),
72 | ],
73 | ],
74 |
75 | 'stderr' => [
76 | 'driver' => 'monolog',
77 | 'handler' => StreamHandler::class,
78 | 'formatter' => env('LOG_STDERR_FORMATTER'),
79 | 'with' => [
80 | 'stream' => 'php://stderr',
81 | ],
82 | ],
83 |
84 | 'syslog' => [
85 | 'driver' => 'syslog',
86 | 'level' => 'debug',
87 | ],
88 |
89 | 'errorlog' => [
90 | 'driver' => 'errorlog',
91 | 'level' => 'debug',
92 | ],
93 |
94 | 'null' => [
95 | 'driver' => 'monolog',
96 | 'handler' => NullHandler::class,
97 | ],
98 |
99 | 'emergency' => [
100 | 'path' => storage_path('logs/laravel.log'),
101 | ],
102 | ],
103 |
104 | ];
105 |
--------------------------------------------------------------------------------
/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 | |--------------------------------------------------------------------------
125 | | Log Channel
126 | |--------------------------------------------------------------------------
127 | |
128 | | If you are using the "log" driver, you may specify the logging channel
129 | | if you prefer to keep mail messages separate from other log entries
130 | | for simpler reading. Otherwise, the default channel will be used.
131 | |
132 | */
133 |
134 | 'log_channel' => env('MAIL_LOG_CHANNEL'),
135 |
136 | ];
137 |
--------------------------------------------------------------------------------
/config/queue.php:
--------------------------------------------------------------------------------
1 | env('QUEUE_CONNECTION', 'sync'),
17 |
18 | /*
19 | |--------------------------------------------------------------------------
20 | | Queue Connections
21 | |--------------------------------------------------------------------------
22 | |
23 | | Here you may configure the connection information for each server that
24 | | is used by your application. A default configuration has been added
25 | | for each back-end shipped with Laravel. You are free to add more.
26 | |
27 | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
28 | |
29 | */
30 |
31 | 'connections' => [
32 |
33 | 'sync' => [
34 | 'driver' => 'sync',
35 | ],
36 |
37 | 'database' => [
38 | 'driver' => 'database',
39 | 'table' => 'jobs',
40 | 'queue' => 'default',
41 | 'retry_after' => 90,
42 | ],
43 |
44 | 'beanstalkd' => [
45 | 'driver' => 'beanstalkd',
46 | 'host' => 'localhost',
47 | 'queue' => 'default',
48 | 'retry_after' => 90,
49 | 'block_for' => 0,
50 | ],
51 |
52 | 'sqs' => [
53 | 'driver' => 'sqs',
54 | 'key' => env('AWS_ACCESS_KEY_ID'),
55 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
56 | 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
57 | 'queue' => env('SQS_QUEUE', 'your-queue-name'),
58 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
59 | ],
60 |
61 | 'redis' => [
62 | 'driver' => 'redis',
63 | 'connection' => 'default',
64 | 'queue' => env('REDIS_QUEUE', 'default'),
65 | 'retry_after' => 90,
66 | 'block_for' => null,
67 | ],
68 |
69 | ],
70 |
71 | /*
72 | |--------------------------------------------------------------------------
73 | | Failed Queue Jobs
74 | |--------------------------------------------------------------------------
75 | |
76 | | These options configure the behavior of failed queue job logging so you
77 | | can control which database and table are used to store the jobs that
78 | | have failed. You may change them to any database / table you wish.
79 | |
80 | */
81 |
82 | 'failed' => [
83 | 'driver' => env('QUEUE_FAILED_DRIVER', 'database'),
84 | 'database' => env('DB_CONNECTION', 'mysql'),
85 | 'table' => 'failed_jobs',
86 | ],
87 |
88 | ];
89 |
--------------------------------------------------------------------------------
/config/sanctum.php:
--------------------------------------------------------------------------------
1 | explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
17 | '%s%s',
18 | 'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
19 | env('APP_URL') ? ','.parse_url(env('APP_URL'), PHP_URL_HOST) : ''
20 | ))),
21 |
22 | /*
23 | |--------------------------------------------------------------------------
24 | | Sanctum Guards
25 | |--------------------------------------------------------------------------
26 | |
27 | | This array contains the authentication guards that will be checked when
28 | | Sanctum is trying to authenticate a request. If none of these guards
29 | | are able to authenticate the request, Sanctum will use the bearer
30 | | token that's present on an incoming request for authentication.
31 | |
32 | */
33 |
34 | 'guard' => ['web'],
35 |
36 | /*
37 | |--------------------------------------------------------------------------
38 | | Expiration Minutes
39 | |--------------------------------------------------------------------------
40 | |
41 | | This value controls the number of minutes until an issued token will be
42 | | considered expired. If this value is null, personal access tokens do
43 | | not expire. This won't tweak the lifetime of first-party sessions.
44 | |
45 | */
46 |
47 | 'expiration' => null,
48 |
49 | /*
50 | |--------------------------------------------------------------------------
51 | | Sanctum Middleware
52 | |--------------------------------------------------------------------------
53 | |
54 | | When authenticating your first-party SPA with Sanctum you may need to
55 | | customize some of the middleware Sanctum uses while processing the
56 | | request. You may change the middleware listed below as required.
57 | |
58 | */
59 |
60 | 'middleware' => [
61 | 'verify_csrf_token' => App\Http\Middleware\VerifyCsrfToken::class,
62 | 'encrypt_cookies' => App\Http\Middleware\EncryptCookies::class,
63 | ],
64 |
65 | ];
66 |
--------------------------------------------------------------------------------
/config/services.php:
--------------------------------------------------------------------------------
1 | [
18 | 'domain' => env('MAILGUN_DOMAIN'),
19 | 'secret' => env('MAILGUN_SECRET'),
20 | 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
21 | ],
22 |
23 | 'postmark' => [
24 | 'token' => env('POSTMARK_TOKEN'),
25 | ],
26 |
27 | 'ses' => [
28 | 'key' => env('AWS_ACCESS_KEY_ID'),
29 | 'secret' => env('AWS_SECRET_ACCESS_KEY'),
30 | 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
31 | ],
32 |
33 | ];
34 |
--------------------------------------------------------------------------------
/config/view.php:
--------------------------------------------------------------------------------
1 | [
17 | resource_path('views'),
18 | ],
19 |
20 | /*
21 | |--------------------------------------------------------------------------
22 | | Compiled View Path
23 | |--------------------------------------------------------------------------
24 | |
25 | | This option determines where all the compiled Blade templates will be
26 | | stored for your application. Typically, this is within the storage
27 | | directory. However, as usual, you are free to change this value.
28 | |
29 | */
30 |
31 | 'compiled' => env(
32 | 'VIEW_COMPILED_PATH',
33 | realpath(storage_path('framework/views'))
34 | ),
35 |
36 | ];
37 |
--------------------------------------------------------------------------------
/database/.gitignore:
--------------------------------------------------------------------------------
1 | *.sqlite
2 | *.sqlite-journal
3 |
--------------------------------------------------------------------------------
/database/factories/UserFactory.php:
--------------------------------------------------------------------------------
1 | $this->faker->name,
27 | 'email' => $this->faker->unique()->safeEmail,
28 | 'email_verified_at' => now(),
29 | 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
30 | 'remember_token' => Str::random(10),
31 | ];
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/database/migrations/2014_10_12_000000_create_users_table.php:
--------------------------------------------------------------------------------
1 | bigIncrements('id');
18 | $table->string('name');
19 | $table->string('email')->unique();
20 | $table->timestamp('email_verified_at')->nullable();
21 | $table->string('password');
22 | $table->rememberToken();
23 | $table->timestamps();
24 | });
25 | }
26 |
27 | /**
28 | * Reverse the migrations.
29 | *
30 | * @return void
31 | */
32 | public function down()
33 | {
34 | Schema::dropIfExists('users');
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/database/migrations/2014_10_12_100000_create_password_resets_table.php:
--------------------------------------------------------------------------------
1 | string('email')->index();
18 | $table->string('token');
19 | $table->timestamp('created_at')->nullable();
20 | });
21 | }
22 |
23 | /**
24 | * Reverse the migrations.
25 | *
26 | * @return void
27 | */
28 | public function down()
29 | {
30 | Schema::dropIfExists('password_resets');
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/database/migrations/2019_08_19_000000_create_failed_jobs_table.php:
--------------------------------------------------------------------------------
1 | bigIncrements('id');
18 | $table->text('connection');
19 | $table->text('queue');
20 | $table->longText('payload');
21 | $table->longText('exception');
22 | $table->timestamp('failed_at')->useCurrent();
23 | });
24 | }
25 |
26 | /**
27 | * Reverse the migrations.
28 | *
29 | * @return void
30 | */
31 | public function down()
32 | {
33 | Schema::dropIfExists('failed_jobs');
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/database/migrations/2019_12_14_000001_create_personal_access_tokens_table.php:
--------------------------------------------------------------------------------
1 | bigIncrements('id');
18 | $table->morphs('tokenable');
19 | $table->string('name');
20 | $table->string('token', 64)->unique();
21 | $table->text('abilities')->nullable();
22 | $table->timestamp('last_used_at')->nullable();
23 | $table->timestamps();
24 | });
25 | }
26 |
27 | /**
28 | * Reverse the migrations.
29 | *
30 | * @return void
31 | */
32 | public function down()
33 | {
34 | Schema::dropIfExists('personal_access_tokens');
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/database/seeders/DatabaseSeeder.php:
--------------------------------------------------------------------------------
1 | call(UsersTableSeeder::class);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "scripts": {
4 | "dev": "npm run development",
5 | "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js",
6 | "watch": "npm run development -- --watch",
7 | "watch-poll": "npm run watch -- --watch-poll",
8 | "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
9 | "prod": "npm run production",
10 | "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --config=node_modules/laravel-mix/setup/webpack.config.js",
11 | "lint": "./node_modules/.bin/eslint -c .eslintrc.js --ignore-path .gitignore resources/js/** --ext .js,.vue --max-warnings=0",
12 | "lint-fix": "./node_modules/.bin/eslint -c .eslintrc.js --ignore-path .gitignore resources/js/** --ext .js,.vue --fix"
13 | },
14 | "lint-staged": {
15 | "*.{js,vue}": [
16 | "./node_modules/.bin/eslint -c .eslintrc.js --fix --max-warnings=0"
17 | ],
18 | "*.php": [
19 | "vendor/bin/php-cs-fixer fix --diff --config=.php-cs-fixer.dist.php"
20 | ]
21 | },
22 | "husky": {
23 | "hooks": {
24 | "pre-commit": "lint-staged"
25 | }
26 | },
27 | "devDependencies": {
28 | "babel-eslint": "^10.1.0",
29 | "browser-sync": "^2.26.14",
30 | "browser-sync-webpack-plugin": "^2.0.1",
31 | "eslint": "^7.20.0",
32 | "eslint-plugin-vue": "^7.6.0",
33 | "husky": "4",
34 | "lint-staged": "11.1.2"
35 | },
36 | "dependencies": {
37 | "@fortawesome/fontawesome-free": "5.15.4",
38 | "@websanova/vue-auth": "4.1.8",
39 | "axios": "^0.24.0",
40 | "cross-env": "^7.0.3",
41 | "dayjs": "^1.10.7",
42 | "element-ui": "2.15.6",
43 | "laravel-mix": "^6.0.39",
44 | "lodash": "4.17.21",
45 | "postcss": "^8.4.5",
46 | "resolve-url-loader": "4.0.0",
47 | "sass": "1.45.2",
48 | "sass-loader": "12.4.0",
49 | "vue": "^2.6.14",
50 | "vue-axios": "^3.4.0",
51 | "vue-i18n": "8.26.8",
52 | "vue-loader": "^15.9.7",
53 | "vue-router": "3.5.3",
54 | "vue-template-compiler": "^2.6.14",
55 | "vuex": "3.6.2"
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
15 | ./tests/Unit
16 |
17 |
18 |
19 | ./tests/Feature
20 |
21 |
22 |
23 |
24 | ./app
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/public/.htaccess:
--------------------------------------------------------------------------------
1 |
2 |
3 | Options -MultiViews -Indexes
4 |
5 |
6 | RewriteEngine On
7 |
8 | # Handle Authorization Header
9 | RewriteCond %{HTTP:Authorization} .
10 | RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
11 |
12 | # Redirect Trailing Slashes If Not A Folder...
13 | RewriteCond %{REQUEST_FILENAME} !-d
14 | RewriteCond %{REQUEST_URI} (.+)/$
15 | RewriteRule ^ %1 [L,R=301]
16 |
17 | # Handle Front Controller...
18 | RewriteCond %{REQUEST_FILENAME} !-d
19 | RewriteCond %{REQUEST_FILENAME} !-f
20 | RewriteRule ^ index.php [L]
21 |
22 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Yurich84/laravel-vue-spa-skeleton/fed0b2fa6ea26a0ee17858d67117a8b6639531f9/public/favicon.ico
--------------------------------------------------------------------------------
/public/index.php:
--------------------------------------------------------------------------------
1 |
8 | */
9 |
10 | define('LARAVEL_START', microtime(true));
11 |
12 | /*
13 | |--------------------------------------------------------------------------
14 | | Register The Auto Loader
15 | |--------------------------------------------------------------------------
16 | |
17 | | Composer provides a convenient, automatically generated class loader for
18 | | our application. We just need to utilize it! We'll simply require it
19 | | into the script here so that we don't have to worry about manual
20 | | loading any of our classes later on. It feels great to relax.
21 | |
22 | */
23 |
24 | require __DIR__.'/../vendor/autoload.php';
25 |
26 | /*
27 | |--------------------------------------------------------------------------
28 | | Turn On The Lights
29 | |--------------------------------------------------------------------------
30 | |
31 | | We need to illuminate PHP development, so let us turn on the lights.
32 | | This bootstraps the framework and gets it ready for use, then it
33 | | will load up this application so that we can run it and send
34 | | the responses back to the browser and delight our users.
35 | |
36 | */
37 |
38 | $app = require_once __DIR__.'/../bootstrap/app.php';
39 |
40 | /*
41 | |--------------------------------------------------------------------------
42 | | Run The Application
43 | |--------------------------------------------------------------------------
44 | |
45 | | Once we have the application, we can handle the incoming request
46 | | through the kernel, and send the associated response back to
47 | | the client's browser allowing them to enjoy the creative
48 | | and wonderful application we have prepared for them.
49 | |
50 | */
51 |
52 | $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
53 |
54 | $response = $kernel->handle(
55 | $request = Illuminate\Http\Request::capture()
56 | );
57 |
58 | $response->send();
59 |
60 | $kernel->terminate($request, $response);
61 |
--------------------------------------------------------------------------------
/public/preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Yurich84/laravel-vue-spa-skeleton/fed0b2fa6ea26a0ee17858d67117a8b6639531f9/public/preview.png
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Disallow:
3 |
--------------------------------------------------------------------------------
/resources/js/app.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import App from './core/App'
3 | import ElementUI from 'element-ui'
4 | import i18n from './bootstrap/i18n'
5 | import router from './bootstrap/router'
6 | import store from './core/store'
7 | import globalMixin from './includes/mixins/globalMixin'
8 | import auth from './bootstrap/auth'
9 | import './bootstrap/day'
10 |
11 | Vue.use(ElementUI, {i18n: (key, value) => i18n.t(key, value)})
12 |
13 | Vue.prototype.config = window.config
14 |
15 | Vue.mixin(globalMixin)
16 |
17 | window.Vue = new Vue({
18 | router,
19 | store,
20 | auth,
21 | i18n,
22 | render: h => h(App)
23 | }).$mount('#app')
24 |
--------------------------------------------------------------------------------
/resources/js/bootstrap/auth.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import VueAxios from 'vue-axios'
3 | import axios from 'axios'
4 | import {Message} from 'element-ui'
5 | import i18n, {setI18nLanguage} from '@/bootstrap/i18n'
6 |
7 | import VueAuth from '@websanova/vue-auth/dist/v2/vue-auth.esm'
8 | import driverAuthBearer from '@websanova/vue-auth/dist/drivers/auth/bearer.esm.js'
9 | import driverHttpAxios from '@websanova/vue-auth/dist/drivers/http/axios.1.x.esm.js'
10 | import driverRouterVueRouter from '@websanova/vue-auth/dist/drivers/router/vue-router.2.x.esm.js'
11 |
12 | Vue.use(VueAxios, axios)
13 | let token = document.head.querySelector('meta[name="csrf-token"]')
14 | axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content
15 | axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'
16 | axios.defaults.baseURL = process.env.MIX_API_ENDPOINT
17 | axios.defaults.withCredentials = true
18 |
19 | // Response interceptor
20 | axios.interceptors.response.use(response => response, error => {
21 | if (error.response.data.message) {
22 | console.error('--- ', error.response.data.message)
23 | }
24 | if (error.response.status >= 500) {
25 | Message.error(i18n.t('global.unknown_server_error').toString())
26 | } else if (error.response.data.message) {
27 | Message.error(error.response.data.message)
28 | }
29 |
30 | return Promise.reject(error)
31 | })
32 |
33 | export default new VueAuth(Vue, {
34 | plugins : {
35 | http : axios,
36 | router : Vue.router
37 | },
38 | drivers : {
39 | http : driverHttpAxios,
40 | auth : driverAuthBearer,
41 | router : driverRouterVueRouter,
42 | },
43 | options : {
44 | loginData: {url: process.env.MIX_API_ENDPOINT + 'auth/login', redirect: {name: 'Dashboard'}},
45 | logoutData: {url: process.env.MIX_API_ENDPOINT + 'auth/logout', redirect: {name: 'Login'}, makeRequest: true},
46 | registerData: {url: process.env.MIX_API_ENDPOINT + 'auth/register', method: 'POST', redirect: {name: 'Login'}},
47 | fetchData: {url: process.env.MIX_API_ENDPOINT + 'auth/me', method: 'POST'},
48 | refreshData: {enabled: false},
49 | rolesKey: 'all_permissions',
50 | parseUserData: function (data) {
51 | setI18nLanguage(data.data.locale || 'en')
52 | return data.data || {}
53 | },
54 | }
55 | })
56 |
--------------------------------------------------------------------------------
/resources/js/bootstrap/day.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import * as dayjs from 'dayjs'
3 | import 'dayjs/locale/en'
4 |
5 | const dayPlugin = {
6 | install(Vue) {
7 | Vue.prototype.dayjs = dayjs
8 | }
9 | }
10 |
11 | Vue.use(dayPlugin)
12 |
13 | window.dayjs = dayjs
14 |
15 | export const changeDayjsLocale = function (locale) {
16 | dayjs.locale(locale)
17 | }
18 |
19 |
--------------------------------------------------------------------------------
/resources/js/bootstrap/i18n.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import VueI18n from 'vue-i18n'
3 | import messages from './../includes/lang'
4 | import axios from 'axios'
5 | import {changeDayjsLocale} from './day'
6 |
7 | Vue.use(VueI18n)
8 |
9 | const DEFAULT_LANGUAGE = 'en'
10 |
11 | changeDayjsLocale(DEFAULT_LANGUAGE)
12 |
13 | const i18n = new VueI18n({
14 | locale: DEFAULT_LANGUAGE,
15 | messages,
16 | silentTranslationWarn: true
17 | })
18 |
19 | setI18nLanguage(DEFAULT_LANGUAGE)
20 |
21 | export function setI18nLanguage (lang) {
22 | changeDayjsLocale(DEFAULT_LANGUAGE)
23 | i18n.locale = lang
24 | axios.defaults.headers.common['Accept-Language'] = lang
25 | document.querySelector('html').setAttribute('lang', lang)
26 | return lang
27 | }
28 |
29 | export default i18n
30 |
--------------------------------------------------------------------------------
/resources/js/bootstrap/router.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import VueRouter from 'vue-router'
3 | import {routes} from '../core/routes'
4 |
5 | Vue.use(VueRouter)
6 |
7 | const router = new VueRouter({
8 | routes,
9 | mode: 'history',
10 | scrollBehavior(to, from, savedPosition) {
11 | return new Promise((resolve) => {
12 | if (to.hash) {
13 | resolve({ selector: to.hash })
14 | } else if (savedPosition) {
15 | resolve(savedPosition)
16 | } else {
17 | resolve({x: 0, y: 0})
18 | }
19 | })
20 | }
21 | })
22 |
23 | Vue.router = router
24 |
25 | export default router
26 |
--------------------------------------------------------------------------------
/resources/js/core/App.vue:
--------------------------------------------------------------------------------
1 |
2 |