#355 Calculate distance button (#366)

* #355 Calculate distance button in add/edit Flight page

* Styling

* Move add/edit flight logic out of controller and into service layer

* Styling

* Formatting

* Run styleci against modules dir

* Styleci config

* Style fixes in /modules
This commit is contained in:
Nabeel S
2019-08-26 12:32:46 -04:00
committed by GitHub
parent 25999d55a3
commit bbec276da8
57 changed files with 9819 additions and 7522 deletions

View File

@@ -2,7 +2,7 @@
return [
'php' => [
'version' => '7.2'
'version' => '7.2',
],
'cache' => [
@@ -10,7 +10,7 @@ return [
'default' => 'file',
'drivers' => [
'Zend OPcache' => 'opcache',
'apc' => 'apc',
'apc' => 'apc',
],
],
@@ -23,7 +23,7 @@ return [
'curl',
],
# Make sure these are writable
// Make sure these are writable
'permissions' => [
'bootstrap/cache',
'public/uploads',

View File

@@ -2,8 +2,8 @@
namespace Modules\Installer\Http\Controllers;
use App\Facades\Utils;
use App\Contracts\Controller;
use App\Facades\Utils;
use App\Models\User;
use App\Repositories\AirlineRepository;
use App\Services\AnalyticsService;
@@ -23,29 +23,29 @@ use Symfony\Component\HttpFoundation\File\Exception\FileException;
/**
* Class InstallerController
* @package Modules\Installer\Http\Controllers
*/
class InstallerController extends Controller
{
private $airlineRepo,
$analyticsSvc,
$dbSvc,
$envSvc,
$migrationSvc,
$reqSvc,
$seederSvc,
$userService;
private $airlineRepo;
private $analyticsSvc;
private $dbSvc;
private $envSvc;
private $migrationSvc;
private $reqSvc;
private $seederSvc;
private $userService;
/**
* InstallerController constructor.
* @param AirlineRepository $airlineRepo
* @param AnalyticsService $analyticsSvc
* @param DatabaseService $dbService
* @param ConfigService $envService
* @param MigrationService $migrationSvc
*
* @param AirlineRepository $airlineRepo
* @param AnalyticsService $analyticsSvc
* @param DatabaseService $dbService
* @param ConfigService $envService
* @param MigrationService $migrationSvc
* @param RequirementsService $reqSvc
* @param SeederService $seederSvc
* @param UserService $userService
* @param SeederService $seederSvc
* @param UserService $userService
*/
public function __construct(
AirlineRepository $airlineRepo,
@@ -66,12 +66,13 @@ class InstallerController extends Controller
$this->seederSvc = $seederSvc;
$this->userService = $userService;
}
/**
* Display a listing of the resource.
*/
public function index()
{
if(config('app.key') !== 'base64:zdgcDqu9PM8uGWCtMxd74ZqdGJIrnw812oRMmwDF6KY=') {
if (config('app.key') !== 'base64:zdgcDqu9PM8uGWCtMxd74ZqdGJIrnw812oRMmwDF6KY=') {
return view('installer::errors/already-installed');
}
@@ -95,31 +96,33 @@ class InstallerController extends Controller
*/
public function dbtest(Request $request)
{
$status = 'success'; # success|warn|danger
$status = 'success'; // success|warn|danger
$message = 'Database connection looks good!';
try {
$this->testDb($request);
} catch (\Exception $e) {
$status = 'danger';
$message = 'Failed! ' . $e->getMessage();
$message = 'Failed! '.$e->getMessage();
}
return view('installer::flash/dbtest', [
'status' => $status,
'status' => $status,
'message' => $message,
]);
}
/**
* Check if any of the items has been marked as failed
*
* @param array $arr
*
* @return bool
*/
protected function allPassed(array $arr): bool
{
foreach($arr as $item) {
if($item['passed'] === false) {
foreach ($arr as $item) {
if ($item['passed'] === false) {
return false;
}
}
@@ -140,21 +143,21 @@ class InstallerController extends Controller
$extensions = $this->reqSvc->checkExtensions();
$directories = $this->reqSvc->checkPermissions();
# Only pass if all the items in the ext and dirs are passed
// Only pass if all the items in the ext and dirs are passed
$statuses = [
$php_version['passed'] === true,
$this->allPassed($extensions) === true,
$this->allPassed($directories) === true
$this->allPassed($directories) === true,
];
# Make sure there are no false values
// Make sure there are no false values
$passed = !\in_array(false, $statuses, true);
return view('installer::install/steps/step1-requirements', [
'php' => $php_version,
'extensions' => $extensions,
'php' => $php_version,
'extensions' => $extensions,
'directories' => $directories,
'passed' => $passed,
'passed' => $passed,
]);
}
@@ -175,7 +178,9 @@ class InstallerController extends Controller
/**
* Step 2a. Create the .env
*
* @param Request $request
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function envsetup(Request $request)
@@ -209,14 +214,14 @@ class InstallerController extends Controller
'DB_PREFIX' => $request->post('db_prefix'),
];
/**
/*
* Create the config files and then redirect so that the
* framework can pickup all those configs, etc, before we
* setup the database and stuff
*/
try {
$this->envSvc->createConfigFiles($attrs);
} catch(FileException $e) {
} catch (FileException $e) {
Log::error('Config files failed to write');
Log::error($e->getMessage());
@@ -224,14 +229,16 @@ class InstallerController extends Controller
return redirect(route('installer.step2'))->withInput();
}
# Needs to redirect so it can load the new .env
// Needs to redirect so it can load the new .env
Log::info('Redirecting to database setup');
return redirect(route('installer.dbsetup'));
}
/**
* Step 2b. Setup the database
*
* @param Request $request
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
*/
public function dbsetup(Request $request)
@@ -242,8 +249,8 @@ class InstallerController extends Controller
$console_out .= $this->dbSvc->setupDB();
$console_out .= $this->migrationSvc->runAllMigrations();
$this->seederSvc->syncAllSeeds();
} catch(QueryException $e) {
Log::error('Error on db setup: ' . $e->getMessage());
} catch (QueryException $e) {
Log::error('Error on db setup: '.$e->getMessage());
$this->envSvc->removeConfigFiles();
flash()->error($e->getMessage());
@@ -253,7 +260,7 @@ class InstallerController extends Controller
$console_out = trim($console_out);
return view('installer::install/steps/step2a-db_output', [
'console_output' => $console_out
'console_output' => $console_out,
]);
}
@@ -269,11 +276,14 @@ class InstallerController extends Controller
/**
* Step 3 submit
*
* @param Request $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*
* @throws \RuntimeException
* @throws \Prettus\Validator\Exceptions\ValidatorException
* @throws \Exception
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function usersetup(Request $request)
{
@@ -283,7 +293,7 @@ class InstallerController extends Controller
'airline_country' => 'required',
'name' => 'required',
'email' => 'required|email|unique:users,email',
'password' => 'required|confirmed'
'password' => 'required|confirmed',
]);
if ($validator->fails()) {
@@ -295,7 +305,6 @@ class InstallerController extends Controller
/**
* Create the first airline
*/
$attrs = [
'icao' => $request->get('airline_icao'),
'name' => $request->get('airline_name'),
@@ -309,20 +318,19 @@ class InstallerController extends Controller
* Ensure the seed data at least has one airport
* KAUS, for giggles, though.
*/
$attrs = [
'name' => $request->get('name'),
'email' => $request->get('email'),
'api_key' => Utils::generateApiKey(),
'airline_id' => $airline->id,
'password' => Hash::make($request->get('password'))
'name' => $request->get('name'),
'email' => $request->get('email'),
'api_key' => Utils::generateApiKey(),
'airline_id' => $airline->id,
'password' => Hash::make($request->get('password')),
];
$user = User::create($attrs);
$user = $this->userService->createUser($user, ['admin']);
Log::info('User registered: ', $user->toArray());
# Set the intial admin e-mail address
// Set the intial admin e-mail address
setting('general.admin_email', $user->email);
$this->analyticsSvc->sendInstall();
@@ -332,7 +340,9 @@ class InstallerController extends Controller
/**
* Final step
*
* @param Request $request
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function complete(Request $request)

View File

@@ -9,10 +9,8 @@ use function count;
use Illuminate\Http\Request;
use Log;
/**
* Class UpdaterController
* @package Modules\Installer\Http\Controllers
*/
class UpdaterController extends Controller
{
@@ -21,6 +19,7 @@ class UpdaterController extends Controller
/**
* UpdaterController constructor.
*
* @param MigrationService $migrationSvc
* @param SeederService $seederSvc
*/
@@ -51,7 +50,7 @@ class UpdaterController extends Controller
public function step1(Request $request)
{
$migrations = $this->migrationSvc->migrationsAvailable();
if(count($migrations) > 0) {
if (count($migrations) > 0) {
Log::info('No migrations found');
}
@@ -70,7 +69,7 @@ class UpdaterController extends Controller
Log::info('Update: run_migrations', $request->post());
$migrations = $this->migrationSvc->migrationsAvailable();
if(count($migrations) === 0) {
if (count($migrations) === 0) {
$this->seederSvc->syncAllSeeds();
return view('installer::update/steps/step3-update-complete');
}

View File

@@ -24,7 +24,7 @@ class InstallerServiceProvider extends ServiceProvider
$this->registerViews();
$this->registerFactories();
$this->loadMigrationsFrom(__DIR__ . '/../Database/migrations');
$this->loadMigrationsFrom(__DIR__.'/../Database/migrations');
}
/**
@@ -33,22 +33,22 @@ class InstallerServiceProvider extends ServiceProvider
protected function registerRoutes()
{
Route::group([
'as' => 'installer.',
'prefix' => 'install',
'as' => 'installer.',
'prefix' => 'install',
'middleware' => ['web'],
'namespace' => 'Modules\Installer\Http\Controllers'
], function() {
$this->loadRoutesFrom(__DIR__ . '/../Http/Routes/install.php');
'namespace' => 'Modules\Installer\Http\Controllers',
], function () {
$this->loadRoutesFrom(__DIR__.'/../Http/Routes/install.php');
});
Route::group([
'as' => 'update.',
'prefix' => 'update',
'as' => 'update.',
'prefix' => 'update',
'middleware' => ['web'],
'namespace' => 'Modules\Installer\Http\Controllers'
'namespace' => 'Modules\Installer\Http\Controllers',
], function () {
$this->loadRoutesFrom(__DIR__ . '/../Http/Routes/update.php');
});
$this->loadRoutesFrom(__DIR__.'/../Http/Routes/update.php');
});
}
/**
@@ -74,8 +74,8 @@ class InstallerServiceProvider extends ServiceProvider
$sourcePath = __DIR__.'/../Resources/views';
$this->publishes([
$sourcePath => $viewPath
],'views');
$sourcePath => $viewPath,
], 'views');
$paths = array_map(
function ($path) {
@@ -98,18 +98,19 @@ class InstallerServiceProvider extends ServiceProvider
if (is_dir($langPath)) {
$this->loadTranslationsFrom($langPath, 'installer');
} else {
$this->loadTranslationsFrom(__DIR__ .'/../Resources/lang', 'installer');
$this->loadTranslationsFrom(__DIR__.'/../Resources/lang', 'installer');
}
}
/**
* Register an additional directory of factories.
*
* @source https://github.com/sebastiaanluca/laravel-resource-flow/blob/develop/src/Modules/ModuleServiceProvider.php#L66
*/
public function registerFactories()
{
if (! app()->environment('production')) {
app(Factory::class)->load(__DIR__ . '/../Database/factories');
if (!app()->environment('production')) {
app(Factory::class)->load(__DIR__.'/../Database/factories');
}
}

View File

@@ -15,15 +15,17 @@ use Symfony\Component\HttpFoundation\File\Exception\FileException;
/**
* Class ConfigService
* @package Modules\Installer\Services
*/
class ConfigService extends Service
{
/**
* Create the .env file
*
* @param $attrs
* @return boolean
*
* @throws \Symfony\Component\HttpFoundation\File\Exception\FileException
*
* @return bool
*/
public function createConfigFiles($attrs): bool
{
@@ -56,7 +58,9 @@ class ConfigService extends Service
/**
* Update the environment file and update certain keys/values
*
* @param array $kvp
*
* @return void
*/
public function updateKeysInEnv(array $kvp)
@@ -64,25 +68,24 @@ class ConfigService extends Service
$app = app();
$env_file = file_get_contents($app->environmentFilePath());
foreach($kvp as $key => $value) {
foreach ($kvp as $key => $value) {
$key = strtoupper($key);
# cast for any boolean values
if(is_bool($value)) {
// cast for any boolean values
if (is_bool($value)) {
$value = $value === true ? 'true' : 'false';
}
# surround by quotes if there are any spaces in the value
if(strpos($value, ' ') !== false) {
// surround by quotes if there are any spaces in the value
if (strpos($value, ' ') !== false) {
$value = '"'.$value.'"';
}
Log::info('Replacing "' . $key . '" with ' . $value);
Log::info('Replacing "'.$key.'" with '.$value);
$env_file = preg_replace(
'/^' . $key . '(.*)?/m',
$key . '=' . $value,
'/^'.$key.'(.*)?/m',
$key.'='.$value,
$env_file
);
}
@@ -92,6 +95,7 @@ class ConfigService extends Service
/**
* Generate a fresh new APP_KEY
*
* @return string
*/
protected function createAppKey(): string
@@ -102,26 +106,28 @@ class ConfigService extends Service
/**
* Change a few options within the PDO driver, depending on the version
* of mysql/maria, etc used. ATM, only make a change for MariaDB
*
* @param $opts
*
* @return mixed
*/
protected function determinePdoOptions($opts)
{
if($opts['DB_CONN'] !== 'mysql') {
if ($opts['DB_CONN'] !== 'mysql') {
return $opts;
}
$dsn = "mysql:host=$opts[DB_HOST];port=$opts[DB_PORT];";
Log::info('Connection string: ' . $dsn);
Log::info('Connection string: '.$dsn);
$conn = new PDO($dsn, $opts['DB_USER'], $opts['DB_PASS']);
$version = strtolower($conn->getAttribute(PDO::ATTR_SERVER_VERSION));
Log::info('Detected DB Version: '.$version);
# If it's mariadb, enable the emulation for prepared statements
# seems to be throwing a problem on 000webhost
# https://github.com/nabeelio/phpvms/issues/132
if(strpos($version, 'mariadb') !== false) {
// If it's mariadb, enable the emulation for prepared statements
// seems to be throwing a problem on 000webhost
// https://github.com/nabeelio/phpvms/issues/132
if (strpos($version, 'mariadb') !== false) {
Log::info('Detected MariaDB, setting DB_EMULATE_PREPARES to true');
$opts['DB_EMULATE_PREPARES'] = true;
}
@@ -131,7 +137,9 @@ class ConfigService extends Service
/**
* Determine is APC is installed, if so, then use it as a cache driver
*
* @param $opts
*
* @return mixed
*/
protected function configCacheDriver($opts)
@@ -157,13 +165,15 @@ class ConfigService extends Service
/**
* Setup a queue driver that's not the default "sync"
* driver, if a database is being used
*
* @param $opts
*
* @return mixed
*/
protected function configQueueDriver($opts)
{
# If we're setting up a database, then also setup
# the default queue driver to use the database
// If we're setting up a database, then also setup
// the default queue driver to use the database
if ($opts['DB_CONN'] === 'mysql' || $opts['DB_CONN'] === 'postgres') {
$opts['QUEUE_DRIVER'] = 'database';
} else {
@@ -189,7 +199,7 @@ class ConfigService extends Service
}
}
if(file_exists($config_file)) {
if (file_exists($config_file)) {
try {
unlink($config_file);
} catch (Exception $e) {
@@ -200,7 +210,9 @@ class ConfigService extends Service
/**
* Get the template file name and write it out
*
* @param $opts
*
* @throws \Symfony\Component\HttpFoundation\File\Exception\FileException
*/
protected function writeConfigFiles($opts)
@@ -209,23 +221,24 @@ class ConfigService extends Service
$env_file = App::environmentFilePath();
if(file_exists($env_file) && !is_writable($env_file)) {
if (file_exists($env_file) && !is_writable($env_file)) {
Log::error('Permissions on existing env.php is not writable');
throw new FileException('Can\'t write to the env.php file! Check the permissions');
}
/**
/*
* First write out the env file
*/
try {
$stub = new Stub('/env.stub', $opts);
$stub->render();
$stub->saveTo(App::environmentPath(), App::environmentFile());
} catch(Exception $e) {
throw new FileException('Couldn\'t write env.php. (' . $e . ')');
} catch (Exception $e) {
throw new FileException('Couldn\'t write env.php. ('.$e.')');
}
/**
/*
* Next write out the config file. If there's an error here,
* then throw an exception but delete the env file first
*/
@@ -234,8 +247,9 @@ class ConfigService extends Service
$stub->render();
$stub->saveTo(App::environmentPath(), 'config.php');
} catch (Exception $e) {
unlink(App::environmentPath().'/'. App::environmentFile());
throw new FileException('Couldn\'t write config.php. (' . $e . ')');
unlink(App::environmentPath().'/'.App::environmentFile());
throw new FileException('Couldn\'t write config.php. ('.$e.')');
}
}
}

View File

@@ -10,21 +10,24 @@ class DatabaseService extends Service
{
/**
* Check the PHP version that it meets the minimum requirement
*
* @param $driver
* @param $host
* @param $port
* @param $name
* @param $user
* @param $pass
* @return boolean
*
* @return bool
*/
public function checkDbConnection($driver, $host, $port, $name, $user, $pass)
{
Log::info('Testing Connection: '.$driver.'::'.$user.':<hidden>@'.$host.':'.$port.';'.$name);
if($driver === 'mysql') {
if ($driver === 'mysql') {
$dsn = "mysql:host=$host;port=$port;dbname=$name";
Log::info('Connection string: '. $dsn);
Log::info('Connection string: '.$dsn);
try {
$conn = new PDO($dsn, $user, $pass);
} catch (\PDOException $e) {
@@ -35,6 +38,7 @@ class DatabaseService extends Service
// TODO: Needs testing
elseif ($driver === 'postgres') {
$dsn = "pgsql:host=$host;port=$port;dbname=$name";
try {
$conn = new PDO($dsn, $user, $pass);
} catch (\PDOException $e) {
@@ -54,7 +58,7 @@ class DatabaseService extends Service
{
$output = '';
if(config('database.default') === 'sqlite') {
if (config('database.default') === 'sqlite') {
\Artisan::call('database:create');
$output .= \Artisan::output();
}

View File

@@ -2,20 +2,19 @@
namespace Modules\Installer\Services;
use App\Contracts\Service;
class RequirementsService extends Service
{
/**
* Check the PHP version that it meets the minimum requirement
*
* @return array
*/
public function checkPHPVersion(): array
{
$passed = false;
if(version_compare(PHP_VERSION, config('installer.php.version')) >= 0) {
if (version_compare(PHP_VERSION, config('installer.php.version')) >= 0) {
$passed = true;
}
@@ -24,19 +23,20 @@ class RequirementsService extends Service
/**
* Make sure the minimal extensions required are loaded
*
* @return array
*/
public function checkExtensions(): array
{
$extensions = [];
foreach(config('installer.extensions') as $ext) {
foreach (config('installer.extensions') as $ext) {
$pass = true;
if(!\extension_loaded($ext)) {
if (!\extension_loaded($ext)) {
$pass = false;
}
$extensions[] = [
'ext' => $ext,
'ext' => $ext,
'passed' => $pass,
];
}
@@ -47,6 +47,7 @@ class RequirementsService extends Service
/**
* Check the permissions for the directories specified
* Make sure they exist and are writable
*
* @return array
*/
public function checkPermissions(): array
@@ -54,21 +55,20 @@ class RequirementsService extends Service
clearstatcache();
$directories = [];
foreach (config('installer.permissions') as $dir)
{
foreach (config('installer.permissions') as $dir) {
$pass = true;
$path = base_path($dir);
if(!file_exists($path)) {
if (!file_exists($path)) {
$pass = false;
}
if(!is_writable($path)) {
if (!is_writable($path)) {
$pass = false;
}
$directories[] = [
'dir' => $dir,
'dir' => $dir,
'passed' => $pass,
];
}

View File

@@ -6,7 +6,6 @@ use App\Contracts\Award;
/**
* Class SampleAward
* @package Modules\Sample\Awards
*/
class SampleAward extends Award
{
@@ -16,7 +15,9 @@ class SampleAward extends Award
* This is the method that needs to be implemented.
* You have access to $this->user, which holds the current
* user the award is being checked against
*
* @param null $params Parameters passed in from the UI
*
* @return bool
*/
public function check($params = null): bool

View File

@@ -1,5 +1,5 @@
<?php
return [
'name' => 'Sample'
'name' => 'Sample',
];

View File

@@ -2,8 +2,8 @@
namespace Modules\Sample\Database\Seeders;
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;
class SampleDatabaseSeeder extends Seeder
{

View File

@@ -7,7 +7,6 @@ use Illuminate\Http\Request;
/**
* Class AdminController
* @package Modules\Sample\Http\Controllers\Admin
*/
class AdminController extends Controller
{

View File

@@ -7,13 +7,14 @@ use Illuminate\Http\Request;
/**
* Class SampleController
* @package Modules\Sample\Http\Controllers\Api
*/
class SampleController extends Controller
{
/**
* Just send out a message
*
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function index(Request $request)
@@ -23,6 +24,7 @@ class SampleController extends Controller
/**
* @param Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function hello(Request $request)
@@ -33,5 +35,4 @@ class SampleController extends Controller
'name' => Auth::user()->name,
]);
}
}

View File

@@ -7,7 +7,6 @@ use Illuminate\Http\Request;
/**
* Class SampleController
* @package Modules\Sample\Http\Controllers
*/
class SampleController extends Controller
{
@@ -29,7 +28,8 @@ class SampleController extends Controller
/**
* Store a newly created resource in storage.
* @param Request $request
*
* @param Request $request
*/
public function store(Request $request)
{

View File

@@ -1,7 +1,7 @@
<?php
# This is the admin path. Comment this out if you don't have
# an admin panel component.
// This is the admin path. Comment this out if you don't have
// an admin panel component.
Route::group([], function () {
Route::get('/', 'AdminController@index');
Route::get('/create', 'AdminController@create');

View File

@@ -3,15 +3,15 @@
/**
* This is publicly accessible
*/
Route::group(['middleware' => []], function() {
Route::group(['middleware' => []], function () {
Route::get('/', 'SampleController@index');
});
/**
/*
* This is required to have a valid API key
*/
Route::group(['middleware' => [
'api.auth'
]], function() {
'api.auth',
]], function () {
Route::get('/hello', 'SampleController@hello');
});

View File

@@ -1,9 +1,9 @@
<?php
Route::group(['middleware' => [
'role:user' # leave blank to make this public
]], function() {
# all your routes are prefixed with the above prefix
# e.g. yoursite.com/sample
'role:user', // leave blank to make this public
]], function () {
// all your routes are prefixed with the above prefix
// e.g. yoursite.com/sample
Route::get('/', 'SampleController@index');
});

View File

@@ -10,7 +10,8 @@ class TestEventListener
/**
* Handle the event.
*/
public function handle(TestEvent $event) {
public function handle(TestEvent $event)
{
Log::info('Received event', [$event]);
}
}

View File

@@ -6,7 +6,6 @@ use App\Contracts\Model;
/**
* Class SampleTable
* @package Modules\Sample\Models
*/
class SampleTable extends Model
{

View File

@@ -3,8 +3,8 @@
namespace Modules\Sample\Providers;
use App\Events\TestEvent;
use Modules\Sample\Listeners\TestEventListener;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Modules\Sample\Listeners\TestEventListener;
class EventServiceProvider extends ServiceProvider
{

View File

@@ -3,8 +3,8 @@
namespace Modules\Sample\Providers;
use App\Services\ModuleService;
use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Eloquent\Factory;
use Illuminate\Support\ServiceProvider;
use Route;
class SampleServiceProvider extends ServiceProvider
@@ -26,7 +26,7 @@ class SampleServiceProvider extends ServiceProvider
$this->registerLinks();
$this->registerFactories();
$this->loadMigrationsFrom(__DIR__ . '/../Database/migrations');
$this->loadMigrationsFrom(__DIR__.'/../Database/migrations');
}
/**
@@ -54,43 +54,43 @@ class SampleServiceProvider extends ServiceProvider
*/
protected function registerRoutes()
{
/**
/*
* Routes for the frontend
*/
Route::group([
'as' => 'sample.',
'as' => 'sample.',
'prefix' => 'sample',
// If you want a RESTful module, change this to 'api'
'middleware' => ['web'],
'namespace' => 'Modules\Sample\Http\Controllers'
], function() {
$this->loadRoutesFrom(__DIR__ . '/../Http/Routes/web.php');
'namespace' => 'Modules\Sample\Http\Controllers',
], function () {
$this->loadRoutesFrom(__DIR__.'/../Http/Routes/web.php');
});
/**
/*
* Routes for the admin
*/
Route::group([
'as' => 'sample.',
'as' => 'sample.',
'prefix' => 'admin/sample',
// If you want a RESTful module, change this to 'api'
'middleware' => ['web', 'role:admin'],
'namespace' => 'Modules\Sample\Http\Controllers\Admin'
], function() {
$this->loadRoutesFrom(__DIR__ . '/../Http/Routes/admin.php');
'namespace' => 'Modules\Sample\Http\Controllers\Admin',
], function () {
$this->loadRoutesFrom(__DIR__.'/../Http/Routes/admin.php');
});
/**
/*
* Routes for an API
*/
Route::group([
'as' => 'sample.',
'as' => 'sample.',
'prefix' => 'api/sample',
// If you want a RESTful module, change this to 'api'
'middleware' => ['api'],
'namespace' => 'Modules\Sample\Http\Controllers\Api'
], function() {
$this->loadRoutesFrom(__DIR__ . '/../Http/Routes/api.php');
'namespace' => 'Modules\Sample\Http\Controllers\Api',
], function () {
$this->loadRoutesFrom(__DIR__.'/../Http/Routes/api.php');
});
}
@@ -117,8 +117,8 @@ class SampleServiceProvider extends ServiceProvider
$sourcePath = __DIR__.'/../Resources/views';
$this->publishes([
$sourcePath => $viewPath
],'views');
$sourcePath => $viewPath,
], 'views');
$paths = array_map(
function ($path) {
@@ -141,18 +141,19 @@ class SampleServiceProvider extends ServiceProvider
if (is_dir($langPath)) {
$this->loadTranslationsFrom($langPath, 'sample');
} else {
$this->loadTranslationsFrom(__DIR__ .'/../Resources/lang', 'sample');
$this->loadTranslationsFrom(__DIR__.'/../Resources/lang', 'sample');
}
}
/**
* Register an additional directory of factories.
*
* @source https://github.com/sebastiaanluca/laravel-resource-flow/blob/develop/src/Modules/ModuleServiceProvider.php#L66
*/
public function registerFactories()
{
if (! app()->environment('production')) {
app(Factory::class)->load(__DIR__ . '/../Database/factories');
if (!app()->environment('production')) {
app(Factory::class)->load(__DIR__.'/../Database/factories');
}
}

View File

@@ -1,7 +1,7 @@
<?php
return [
'name' => 'vacentral',
'name' => 'vacentral',
'address' => 'https://api.vacentral.net',
'api_key' => ''
'api_key' => '',
];

View File

@@ -10,7 +10,8 @@ class PirepAcceptedEventListener
/**
* Handle the event.
*/
public function handle(PirepAccepted $pirep) {
public function handle(PirepAccepted $pirep)
{
Log::info('Received PIREP accepted event', [$pirep]);
}
}

View File

@@ -2,8 +2,8 @@
namespace Modules\Vacentral\Providers;
use Illuminate\Support\ServiceProvider;
use App\Services\ModuleService;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{

View File

@@ -3,8 +3,8 @@
namespace Modules\Vacentral\Providers;
use App\Events\PirepAccepted;
use Modules\Vacentral\Listeners\PirepAcceptedEventListener;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Modules\Vacentral\Listeners\PirepAcceptedEventListener;
class EventServiceProvider extends ServiceProvider
{