commit 0830274a05f7d2b5d61ece4d9c6afd680aef3550 Author: Andrey Pokidov Date: Sun Apr 5 16:36:34 2020 +0700 Registration module in development state diff --git a/Config/.gitkeep b/Config/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Config/config.php b/Config/config.php new file mode 100644 index 0000000..772a5d8 --- /dev/null +++ b/Config/config.php @@ -0,0 +1,5 @@ + 'Register' +]; diff --git a/Console/.gitkeep b/Console/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Database/Migrations/.gitkeep b/Database/Migrations/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Database/Seeders/.gitkeep b/Database/Seeders/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Database/factories/.gitkeep b/Database/factories/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Http/Controllers/.gitkeep b/Http/Controllers/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Http/Controllers/RegisterController.php b/Http/Controllers/RegisterController.php new file mode 100644 index 0000000..34c37e0 --- /dev/null +++ b/Http/Controllers/RegisterController.php @@ -0,0 +1,35 @@ + $form + ]); + } + + /** + * Store a newly created resource in storage. + * @param Request $request + * @return Response + */ + public function store(Request $request) + { + // + } +} diff --git a/Http/Forms/RegistrationForm.php b/Http/Forms/RegistrationForm.php new file mode 100644 index 0000000..d650257 --- /dev/null +++ b/Http/Forms/RegistrationForm.php @@ -0,0 +1,43 @@ + + */ +class RegistrationForm extends Form +{ + const MINIMAL_PASSWORD_LENGTH = 6; + + public function __construct() + { + $this->newEmail('email')->setId('email') + ->setLabelText(__('register::register.email_field')) + ->setRequired() + ->setMaxLength(255); + + $this->newText('phone')->setId('phone') + ->setLabelText(__('register::register.phone_field')) + ->setMaxLength(25); + + $this->newPassword('password')->setId('password') + ->setLabelText(__('register::register.password_field')) + ->setRequired() + ->setMaxLength(255); + + $this->newPassword('password_confirm')->setId('password_confirm') + ->setLabelText(__('register::register.password_confirm_field')) + ->setRequired() + ->setMaxLength(255); + + $this->newCheckbox('agree')->setId('agree') + ->setLabelText(__('register::register.agree')) + ->setRequired(); + } +} diff --git a/Http/Middleware/.gitkeep b/Http/Middleware/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Http/Requests/.gitkeep b/Http/Requests/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Providers/.gitkeep b/Providers/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Providers/RegisterServiceProvider.php b/Providers/RegisterServiceProvider.php new file mode 100644 index 0000000..f20ed78 --- /dev/null +++ b/Providers/RegisterServiceProvider.php @@ -0,0 +1,106 @@ +registerTranslations(); + $this->registerConfig(); + $this->registerViews(); + $this->registerFactories(); + $this->loadMigrationsFrom(module_path('Register', 'Database/Migrations')); + } + + /** + * Register the service provider. + * + * @return void + */ + public function register() + { + $this->app->register(RouteServiceProvider::class); + } + + /** + * Register config. + * + * @return void + */ + protected function registerConfig() + { + $this->publishes([ + module_path('Register', 'Config/config.php') => config_path('register.php'), + ], 'config'); + $this->mergeConfigFrom( + module_path('Register', 'Config/config.php'), 'register' + ); + } + + /** + * Register views. + * + * @return void + */ + public function registerViews() + { + $viewPath = resource_path('views/modules/register'); + + $sourcePath = module_path('Register', 'Resources/views'); + + $this->publishes([ + $sourcePath => $viewPath + ],'views'); + + $this->loadViewsFrom(array_merge(array_map(function ($path) { + return $path . '/modules/register'; + }, \Config::get('view.paths')), [$sourcePath]), 'register'); + } + + /** + * Register translations. + * + * @return void + */ + public function registerTranslations() + { + $langPath = resource_path('lang/modules/register'); + + if (is_dir($langPath)) { + $this->loadTranslationsFrom($langPath, 'register'); + } else { + $this->loadTranslationsFrom(module_path('Register', 'Resources/lang'), 'register'); + } + } + + /** + * Register an additional directory of factories. + * + * @return void + */ + public function registerFactories() + { + if (! app()->environment('production') && $this->app->runningInConsole()) { + app(Factory::class)->load(module_path('Register', 'Database/factories')); + } + } + + /** + * Get the services provided by the provider. + * + * @return array + */ + public function provides() + { + return []; + } +} diff --git a/Providers/RouteServiceProvider.php b/Providers/RouteServiceProvider.php new file mode 100644 index 0000000..171c340 --- /dev/null +++ b/Providers/RouteServiceProvider.php @@ -0,0 +1,57 @@ +mapApiRoutes(); + + $this->mapWebRoutes(); + } + + /** + * Define the "web" routes for the application. + * + * These routes all receive session state, CSRF protection, etc. + * + * @return void + */ + protected function mapWebRoutes() + { + Route::middleware('web') + ->namespace($this->moduleNamespace) + ->group(module_path('Register', '/Routes/web.php')); + } + + /** + * Define the "api" routes for the application. + * + * These routes are typically stateless. + * + * @return void + */ + protected function mapApiRoutes() + { + Route::prefix('api') + ->middleware('api') + ->namespace($this->moduleNamespace) + ->group(module_path('Register', '/Routes/api.php')); + } +} diff --git a/Resources/assets/.gitkeep b/Resources/assets/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Resources/assets/js/app.js b/Resources/assets/js/app.js new file mode 100644 index 0000000..e69de29 diff --git a/Resources/assets/sass/app.scss b/Resources/assets/sass/app.scss new file mode 100644 index 0000000..e69de29 diff --git a/Resources/lang/.gitkeep b/Resources/lang/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Resources/lang/en/register.php b/Resources/lang/en/register.php new file mode 100644 index 0000000..a002a4f --- /dev/null +++ b/Resources/lang/en/register.php @@ -0,0 +1,13 @@ + 'Registration', + + 'email_field' => 'E-mail', + 'phone_field' => 'Mobile phone number', + 'password_field' => 'Password', + 'password_confirm_field' => 'Password confirmation', + 'agree' => 'Agree with terms of service', + + 'open_login_form' => 'Log into the personal cabinet', +]; \ No newline at end of file diff --git a/Resources/lang/ru/register.php b/Resources/lang/ru/register.php new file mode 100644 index 0000000..14fe8fd --- /dev/null +++ b/Resources/lang/ru/register.php @@ -0,0 +1,13 @@ + 'Регистрация', + + 'email_field' => 'Адрес электронной почты', + 'phone_field' => 'Номер мобильного телефона', + 'password_field' => 'Пароль', + 'password_confirm_field' => 'Повтор пароля', + 'agree' => 'Принимаю пользовтельское соглашение', + + 'open_login_form' => 'Вход в личный кабинет', +]; \ No newline at end of file diff --git a/Resources/views/.gitkeep b/Resources/views/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Resources/views/form.blade.php b/Resources/views/form.blade.php new file mode 100644 index 0000000..81d4d71 --- /dev/null +++ b/Resources/views/form.blade.php @@ -0,0 +1,50 @@ +@extends('common') + +@section('content') +@form_begin($form) +@csrf +@method('post') +
+
+ {{ __('register::register.title') }} + @if(Session::has('message.registration_error')) +
{!! Session::get('message.registration_error') !!}
+ @endif + +
+ +

@form_label($form->field('email'))

+ @form_field($form->field('email')) +
+ +
+ +

@form_label($form->field('phone'))

+ @form_field($form->field('phone')) +
+ +
+ +

@form_label($form->field('password'))

+ @form_field($form->field('password')) +
+ +
+ +

@form_label($form->field('password_confirm'))

+ @form_field($form->field('password_confirm')) +
+ +
+ + @form_field($form->field('agree')) @form_label($form->field('agree'), '') +
+ + +
+ +
+@form_end() +@endsection diff --git a/Routes/.gitkeep b/Routes/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/Routes/api.php b/Routes/api.php new file mode 100644 index 0000000..7c1e4e9 --- /dev/null +++ b/Routes/api.php @@ -0,0 +1,20 @@ +get('/register', function (Request $request) { + return $request->user(); +}); + + */ \ No newline at end of file diff --git a/Routes/web.php b/Routes/web.php new file mode 100644 index 0000000..b130577 --- /dev/null +++ b/Routes/web.php @@ -0,0 +1,14 @@ +