-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from doroshenko-misha-90/module_activation_1113…
…829266047656 Develop abstract logic for activation features
- Loading branch information
Showing
34 changed files
with
501 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
return [ | ||
'name' => 'Main' | ||
]; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Modules\Main\Contracts\Activation; | ||
|
||
interface ActivationContract | ||
{ | ||
public static function push(); | ||
|
||
public static function confirm(); | ||
} |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Modules\Main\Database\Seeders; | ||
|
||
use Illuminate\Database\Seeder; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class MainDatabaseSeeder extends Seeder | ||
{ | ||
/** | ||
* Run the database seeds. | ||
* | ||
* @return void | ||
*/ | ||
public function run() | ||
{ | ||
Model::unguard(); | ||
|
||
// $this->call("OthersTableSeeder"); | ||
} | ||
} |
Empty file.
Empty file.
11 changes: 11 additions & 0 deletions
11
modules/Main/Factory/Activation/ActivationServiceFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Modules\Main\Factory\Activation; | ||
|
||
class ActivationServiceFactory | ||
{ | ||
public static function driver($driver) | ||
{ | ||
return app(__NAMESPACE__ . '\\' . ucfirst($driver) . 'Provider'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Modules\Main\Factory\Activation; | ||
|
||
use Modules\Main\Contracts\Activation\ActivationContract; | ||
|
||
class EmailProvider implements ActivationContract | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public static function push() | ||
{ | ||
//TODO Need implement create token via redis | ||
|
||
return 'This push method'; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public static function confirm() | ||
{ | ||
//TODO Need implement check token via redis | ||
|
||
return 'This confirm method'; | ||
} | ||
} |
Empty file.
23 changes: 23 additions & 0 deletions
23
modules/Main/Http/Controllers/Activation/ConfirmController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Modules\Main\Http\Controllers\Activation; | ||
|
||
use Illuminate\Http\Response; | ||
use Illuminate\Routing\Controller; | ||
use Modules\Main\Factory\Activation\ActivationServiceFactory; | ||
|
||
class ConfirmController extends Controller | ||
{ | ||
/** | ||
* Display a listing of the resource. | ||
* | ||
* @param $type string | ||
* @param $token string | ||
* | ||
* @return Response | ||
*/ | ||
public function __invoke($type, $token) | ||
{ | ||
return ActivationServiceFactory::driver($type)->confirm($token); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
|
||
namespace Modules\Main\Http\Controllers; | ||
|
||
use Illuminate\Http\Request; | ||
use Illuminate\Http\Response; | ||
use Illuminate\Routing\Controller; | ||
|
||
class MainController extends Controller | ||
{ | ||
/** | ||
* Display a listing of the resource. | ||
* @return Response | ||
*/ | ||
public function index() | ||
{ | ||
return view('main::index'); | ||
} | ||
|
||
/** | ||
* Show the form for creating a new resource. | ||
* @return Response | ||
*/ | ||
public function create() | ||
{ | ||
return view('main::create'); | ||
} | ||
|
||
/** | ||
* Store a newly created resource in storage. | ||
* @param Request $request | ||
* @return Response | ||
*/ | ||
public function store(Request $request) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Show the specified resource. | ||
* @param int $id | ||
* @return Response | ||
*/ | ||
public function show($id) | ||
{ | ||
return view('main::show'); | ||
} | ||
|
||
/** | ||
* Show the form for editing the specified resource. | ||
* @param int $id | ||
* @return Response | ||
*/ | ||
public function edit($id) | ||
{ | ||
return view('main::edit'); | ||
} | ||
|
||
/** | ||
* Update the specified resource in storage. | ||
* @param Request $request | ||
* @param int $id | ||
* @return Response | ||
*/ | ||
public function update(Request $request, $id) | ||
{ | ||
// | ||
} | ||
|
||
/** | ||
* Remove the specified resource from storage. | ||
* @param int $id | ||
* @return Response | ||
*/ | ||
public function destroy($id) | ||
{ | ||
// | ||
} | ||
} |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<?php | ||
|
||
namespace Modules\Main\Providers; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
use Illuminate\Database\Eloquent\Factory; | ||
use Modules\Main\Http\Controllers\Contracts\Activation\ActivationContract; | ||
|
||
class MainServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Indicates if loading of the provider is deferred. | ||
* | ||
* @var bool | ||
*/ | ||
protected $defer = false; | ||
|
||
/** | ||
* Boot the application events. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
$this->registerTranslations(); | ||
$this->registerConfig(); | ||
$this->registerViews(); | ||
$this->registerFactories(); | ||
$this->loadMigrationsFrom(__DIR__ . '/../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([ | ||
__DIR__.'/../Config/config.php' => config_path('main.php'), | ||
], 'config'); | ||
$this->mergeConfigFrom( | ||
__DIR__.'/../Config/config.php', 'main' | ||
); | ||
} | ||
|
||
/** | ||
* Register views. | ||
* | ||
* @return void | ||
*/ | ||
public function registerViews() | ||
{ | ||
$viewPath = resource_path('views/modules/main'); | ||
|
||
$sourcePath = __DIR__.'/../Resources/views'; | ||
|
||
$this->publishes([ | ||
$sourcePath => $viewPath | ||
],'views'); | ||
|
||
$this->loadViewsFrom(array_merge(array_map(function ($path) { | ||
return $path . '/modules/main'; | ||
}, \Config::get('view.paths')), [$sourcePath]), 'main'); | ||
} | ||
|
||
/** | ||
* Register translations. | ||
* | ||
* @return void | ||
*/ | ||
public function registerTranslations() | ||
{ | ||
$langPath = resource_path('lang/modules/main'); | ||
|
||
if (is_dir($langPath)) { | ||
$this->loadTranslationsFrom($langPath, 'main'); | ||
} else { | ||
$this->loadTranslationsFrom(__DIR__ .'/../Resources/lang', 'main'); | ||
} | ||
} | ||
|
||
/** | ||
* Register an additional directory of factories. | ||
* | ||
* @return void | ||
*/ | ||
public function registerFactories() | ||
{ | ||
if (! app()->environment('production')) { | ||
app(Factory::class)->load(__DIR__ . '/../Database/factories'); | ||
} | ||
} | ||
|
||
/** | ||
* Get the services provided by the provider. | ||
* | ||
* @return array | ||
*/ | ||
public function provides() | ||
{ | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
namespace Modules\Main\Providers; | ||
|
||
use Illuminate\Support\Facades\Route; | ||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; | ||
|
||
class RouteServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* The root namespace to assume when generating URLs to actions. | ||
* | ||
* @var string | ||
*/ | ||
protected $namespace = 'Modules\Main\Http\Controllers'; | ||
|
||
/** | ||
* Called before routes are registered. | ||
* | ||
* Register any model bindings or pattern based filters. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
parent::boot(); | ||
} | ||
|
||
/** | ||
* 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->namespace) | ||
->group(__DIR__ . '/../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->namespace) | ||
->group(__DIR__ . '/../Routes/api.php'); | ||
} | ||
} |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@extends('main::layouts.master') | ||
|
||
@section('content') | ||
<h1>Hello World</h1> | ||
|
||
<p> | ||
This view is loaded from module: {!! config('main.name') !!} | ||
</p> | ||
@stop |
Oops, something went wrong.