Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop abstract logic for activation features #3

Merged
1 commit merged into from
Mar 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
|
*/

'modules' => base_path('Modules'),
'modules' => base_path('modules'),
/*
|--------------------------------------------------------------------------
| Modules assets path
Expand Down
Empty file added modules/Main/Config/.gitkeep
Empty file.
5 changes: 5 additions & 0 deletions modules/Main/Config/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return [
'name' => 'Main'
];
Empty file added modules/Main/Console/.gitkeep
Empty file.
10 changes: 10 additions & 0 deletions modules/Main/Contracts/Activation/ActivationContract.php
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.
21 changes: 21 additions & 0 deletions modules/Main/Database/Seeders/MainDatabaseSeeder.php
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 added modules/Main/Entities/.gitkeep
Empty file.
11 changes: 11 additions & 0 deletions modules/Main/Factory/Activation/ActivationServiceFactory.php
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');
}
}
28 changes: 28 additions & 0 deletions modules/Main/Factory/Activation/EmailProvider.php
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 modules/Main/Http/Controllers/Activation/ConfirmController.php
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);
}
}
79 changes: 79 additions & 0 deletions modules/Main/Http/Controllers/MainController.php
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 added modules/Main/Providers/.gitkeep
Empty file.
114 changes: 114 additions & 0 deletions modules/Main/Providers/MainServiceProvider.php
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 [];
}
}
69 changes: 69 additions & 0 deletions modules/Main/Providers/RouteServiceProvider.php
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.
9 changes: 9 additions & 0 deletions modules/Main/Resources/views/index.blade.php
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
Loading