Registration module in development state
commit
0830274a05
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'name' => 'Register'
|
||||
];
|
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Register\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
use Modules\Register\Http\Forms\RegistrationForm;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
/**
|
||||
* Отображение формы регистрации
|
||||
* @return Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$form = new RegistrationForm();
|
||||
|
||||
return view('register::form', [
|
||||
'form' => $form
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Register\Http\Forms;
|
||||
|
||||
use Artmark\Forms\Form;
|
||||
|
||||
//use App\Models\User;
|
||||
|
||||
/**
|
||||
* Description of RegistrationForm
|
||||
*
|
||||
* @author Andrey Pokidov <pokidov@e-traffic.ru>
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Register\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Database\Eloquent\Factory;
|
||||
|
||||
class RegisterServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Boot the application events.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->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 [];
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Register\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The module namespace to assume when generating URLs to actions.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $moduleNamespace = 'Modules\Register\Http\Controllers';
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function map()
|
||||
{
|
||||
//$this->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'));
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'title' => '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',
|
||||
];
|
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'title' => 'Регистрация',
|
||||
|
||||
'email_field' => 'Адрес электронной почты',
|
||||
'phone_field' => 'Номер мобильного телефона',
|
||||
'password_field' => 'Пароль',
|
||||
'password_confirm_field' => 'Повтор пароля',
|
||||
'agree' => 'Принимаю пользовтельское соглашение',
|
||||
|
||||
'open_login_form' => 'Вход в личный кабинет',
|
||||
];
|
@ -0,0 +1,50 @@
|
||||
@extends('common')
|
||||
|
||||
@section('content')
|
||||
@form_begin($form)
|
||||
@csrf
|
||||
@method('post')
|
||||
<div class="auth">
|
||||
<div class="auth__form form">
|
||||
<span class="form__caption">{{ __('register::register.title') }}</span>
|
||||
@if(Session::has('message.registration_error'))
|
||||
<div class="validation-summary-errors">{!! Session::get('message.registration_error') !!}</div>
|
||||
@endif
|
||||
|
||||
<div class="form__field field">
|
||||
<span class="field-validation-error"></span>
|
||||
<p>@form_label($form->field('email'))</p>
|
||||
@form_field($form->field('email'))
|
||||
</div>
|
||||
|
||||
<div class="form__field field">
|
||||
<span class="field-validation-error"></span>
|
||||
<p>@form_label($form->field('phone'))</p>
|
||||
@form_field($form->field('phone'))
|
||||
</div>
|
||||
|
||||
<div class="form__field field">
|
||||
<span class="field-validation-error"></span>
|
||||
<p>@form_label($form->field('password'))</p>
|
||||
@form_field($form->field('password'))
|
||||
</div>
|
||||
|
||||
<div class="form__field field">
|
||||
<span class="field-validation-error"></span>
|
||||
<p>@form_label($form->field('password_confirm'))</p>
|
||||
@form_field($form->field('password_confirm'))
|
||||
</div>
|
||||
|
||||
<div class="form__field field">
|
||||
<span class="field-validation-error"></span>
|
||||
@form_field($form->field('agree')) @form_label($form->field('agree'), '')
|
||||
</div>
|
||||
|
||||
<button class="btn log-in-btn" type="submit">{{ __('common.continue') }}</button>
|
||||
</div>
|
||||
<div class="auth__links">
|
||||
<a href="/login" class="btn btn_gray btn_gray__reg_1">{{ __('register::register.open_login_form') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
@form_end()
|
||||
@endsection
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| API Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you can register API routes for your application. These
|
||||
| routes are loaded by the RouteServiceProvider within a group which
|
||||
| is assigned the "api" middleware group. Enjoy building your API!
|
||||
|
|
||||
*/
|
||||
/*
|
||||
Route::middleware('auth:api')->get('/register', function (Request $request) {
|
||||
return $request->user();
|
||||
});
|
||||
|
||||
*/
|
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Web Routes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here is where you can register web routes for your application. These
|
||||
| routes are loaded by the RouteServiceProvider within a group which
|
||||
| contains the "web" middleware group. Now create something great!
|
||||
|
|
||||
*/
|
||||
|
||||
Route::get('register', 'RegisterController@index');
|
@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "artmark/laravel-module-register",
|
||||
"description": "User registration module",
|
||||
"type": "package",
|
||||
"license": "Proprietary",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Andrey Pokidov",
|
||||
"email": "pokidov@e-traffic.ru"
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Modules\\Register\\Providers\\RegisterServiceProvider"
|
||||
],
|
||||
"aliases": {
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Modules\\Register\\": ""
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
{
|
||||
"name": "Register",
|
||||
"alias": "register",
|
||||
"description": "",
|
||||
"keywords": [],
|
||||
"order": 0,
|
||||
"providers": [
|
||||
"Modules\\Register\\Providers\\RegisterServiceProvider"
|
||||
],
|
||||
"aliases": {},
|
||||
"files": [],
|
||||
"requires": []
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
{
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "npm run development",
|
||||
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||
"watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
|
||||
"watch-poll": "npm run watch -- --watch-poll",
|
||||
"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",
|
||||
"prod": "npm run production",
|
||||
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"cross-env": "^5.1.4",
|
||||
"laravel-mix": "^4.0.7",
|
||||
"laravel-mix-merge-manifest": "^0.1.2"
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
const mix = require('laravel-mix');
|
||||
require('laravel-mix-merge-manifest');
|
||||
|
||||
mix.setPublicPath('../../public').mergeManifest();
|
||||
|
||||
mix.js(__dirname + '/Resources/assets/js/app.js', 'js/register.js')
|
||||
.sass( __dirname + '/Resources/assets/sass/app.scss', 'css/register.css');
|
||||
|
||||
if (mix.inProduction()) {
|
||||
mix.version();
|
||||
}
|
Loading…
Reference in New Issue