Skip to content
This repository has been archived by the owner on Jan 10, 2020. It is now read-only.

Commit

Permalink
Merge pull request #14 from YABhq/analysis-XkYo5y
Browse files Browse the repository at this point in the history
Applied fixes from StyleCI
  • Loading branch information
mlantz committed Jun 25, 2016
2 parents 1da0adc + 8bacb30 commit 2e514b3
Show file tree
Hide file tree
Showing 111 changed files with 1,680 additions and 1,733 deletions.
24 changes: 12 additions & 12 deletions src/Console/ModuleCrud.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Yab\Quarx\Console;

use Config;
use Artisan;
use Config;
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Yab\Laracogs\Generators\CrudGenerator;
Expand All @@ -25,25 +25,25 @@ class ModuleCrud extends Command
protected $description = 'Generate a CRUD module for Quarx';

/**
* Generate a CRUD stack
* Generate a CRUD stack.
*
* @return mixed
*/
public function handle()
{
$filesystem = new Filesystem;
$filesystem = new Filesystem();

$crudGenerator = new CrudGenerator();

$table = ucfirst(str_singular($this->argument('table')));

$moduleDirectory = base_path('quarx/modules/'.ucfirst(str_plural($table)));

if (! is_dir(base_path('quarx'))) {
if (!is_dir(base_path('quarx'))) {
@mkdir(base_path('quarx'));
}

if (! is_dir(base_path('quarx/modules'))) {
if (!is_dir(base_path('quarx/modules'))) {
@mkdir(base_path('quarx/modules'));
}

Expand All @@ -63,7 +63,7 @@ public function handle()
@mkdir($moduleDirectory.'/Tests');

file_put_contents($moduleDirectory.'/config.php', "<?php \n\n\n return [];");
file_put_contents($moduleDirectory.'/Views/menu.blade.php', "<li><a href=\"<?= URL::to('quarx/".strtolower(str_plural($table))."'); ?>\"><span class=\"fa fa-file\"></span> ".ucfirst(str_plural($table))."</a></li>");
file_put_contents($moduleDirectory.'/Views/menu.blade.php', "<li><a href=\"<?= URL::to('quarx/".strtolower(str_plural($table))."'); ?>\"><span class=\"fa fa-file\"></span> ".ucfirst(str_plural($table)).'</a></li>');

$config = [
'bootstrap' => false,
Expand Down Expand Up @@ -146,24 +146,24 @@ public function handle()
$this->info('Add this to your `app/Providers/RouteServiceProver.php` in the `mapWebRoutes` method:');
$this->comment("\nrequire app_path('Http/".$config['_lower_casePlural_']."-routes.php');\n");
} catch (Exception $e) {
throw new Exception("Unable to generate your Module", 1);
throw new Exception('Unable to generate your Module', 1);
}

if ($this->option('migration')) {
Artisan::call('make:migration', [
'name' => 'create_'.str_plural(strtolower($table)).'_table',
'--path' => 'quarx/modules/'.ucfirst(str_plural($table)).'/Publishes/database/migrations',
'--table' => str_plural(strtolower($table)),
'name' => 'create_'.str_plural(strtolower($table)).'_table',
'--path' => 'quarx/modules/'.ucfirst(str_plural($table)).'/Publishes/database/migrations',
'--table' => str_plural(strtolower($table)),
'--create' => true,
]);

if ($this->option('schema')) {
$migrationFiles = $filesystem->allFiles(base_path('quarx/modules/'.ucfirst(str_plural($table)).'/Publishes/database/migrations'));
$migrationName = 'create_'.str_plural(strtolower($table)).'_table';
foreach ($migrationFiles as $file) {
if (stristr($file->getBasename(), $migrationName) ) {
if (stristr($file->getBasename(), $migrationName)) {
$migrationData = file_get_contents($file->getPathname());
$parsedTable = "";
$parsedTable = '';

foreach (explode(',', $this->option('schema')) as $key => $column) {
$columnDefinition = explode(':', $column);
Expand Down
14 changes: 7 additions & 7 deletions src/Console/ModuleMake.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Yab\Quarx\Console;

use Config;
use Artisan;
use Config;
use Illuminate\Console\Command;
use Yab\Laracogs\Generators\CrudGenerator;

Expand All @@ -24,7 +24,7 @@ class ModuleMake extends Command
protected $description = 'Generate a module for Quarx';

/**
* Generate a CRUD stack
* Generate a CRUD stack.
*
* @return mixed
*/
Expand All @@ -36,11 +36,11 @@ public function handle()

$moduleDirectory = base_path('quarx/modules/'.ucfirst(($name)));

if (! is_dir(base_path('quarx'))) {
if (!is_dir(base_path('quarx'))) {
@mkdir(base_path('quarx'));
}

if (! is_dir(base_path('quarx/modules'))) {
if (!is_dir(base_path('quarx/modules'))) {
@mkdir(base_path('quarx/modules'));
}

Expand All @@ -56,7 +56,7 @@ public function handle()
@mkdir($moduleDirectory.'/Tests');

file_put_contents($moduleDirectory.'/config.php', "<?php \n\n\n return [];");
file_put_contents($moduleDirectory.'/Views/menu.blade.php', "<li><a href=\"<?= URL::to('quarx/".strtolower(($name))."'); ?>\"><span class=\"fa fa-file\"></span> ".ucfirst(($name))."</a></li>");
file_put_contents($moduleDirectory.'/Views/menu.blade.php', "<li><a href=\"<?= URL::to('quarx/".strtolower(($name))."'); ?>\"><span class=\"fa fa-file\"></span> ".ucfirst(($name)).'</a></li>');

$config = [
'bootstrap' => false,
Expand All @@ -71,7 +71,7 @@ public function handle()
'_app_namespace_' => app()->getInstance()->getNamespace(),
'_namespace_services_' => 'Quarx\Modules\\'.ucfirst(($name)).'\Services',
'_namespace_controller_' => 'Quarx\Modules\\'.ucfirst(($name)).'\Controllers',
'_name_name_' => (strtolower($name)),
'_name_name_' => (strtolower($name)),
'_lower_case_' => strtolower($name),
'_lower_casePlural_' => (strtolower($name)),
'_camel_case_' => ucfirst(camel_case($name)),
Expand Down Expand Up @@ -121,7 +121,7 @@ public function handle()
$this->info('Add this to your `app/Providers/RouteServiceProver.php` in the `mapWebRoutes` method:');
$this->comment("\nrequire app_path('Http/".$config['_lower_casePlural_']."-routes.php');\n");
} catch (Exception $e) {
throw new Exception("Unable to generate your Module", 1);
throw new Exception('Unable to generate your Module', 1);
}

$this->info('Module for '.$name.' is done.');
Expand Down
20 changes: 8 additions & 12 deletions src/Console/ModulePublish.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

namespace Yab\Quarx\Console;

use Illuminate\Support\Str;
use Illuminate\Support\Schema;
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\Config;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Illuminate\Filesystem\Filesystem;

class ModulePublish extends Command
{
Expand Down Expand Up @@ -43,28 +40,28 @@ public function __construct()
*/
public function fire()
{
$fileSystem = new Filesystem;
$fileSystem = new Filesystem();

$files = $fileSystem->allFiles(base_path(Config::get('quarx.module-directory')).'/'.ucfirst($this->argument('module')).'/Publishes');
$this->line("\n");
foreach ($files as $file) {
if ($file->getType() == "file") {
if ($file->getType() == 'file') {
$this->line(str_replace(base_path(Config::get('quarx.module-directory')).'/'.ucfirst($this->argument('module')).'/Publishes/', '', $file));
}
}

$this->info("\n\nThese files will be published\n");

$result = $this->confirm("Are you sure you want to overwrite any files of the same name?");
$result = $this->confirm('Are you sure you want to overwrite any files of the same name?');

if ($result) {
foreach ($files as $file) {
$newFileName = str_replace(base_path('quarx/modules/'.ucfirst($this->argument('module')).'/Publishes/'), '', $file);
if (strstr($newFileName, 'resources/themes/')) {
$newFileName = str_replace('/default/', '/'.Config::get('quarx.frontend-theme').'/', $newFileName);
$this->line("Copying ".$newFileName." using current Quarx theme...");
$this->line('Copying '.$newFileName.' using current Quarx theme...');
} else {
$this->line("Copying ".$newFileName."...");
$this->line('Copying '.$newFileName.'...');
}
if (is_dir($file)) {
$fileSystem->copyDirectory($file, base_path($newFileName));
Expand All @@ -74,9 +71,9 @@ public function fire()
}
}

$this->info("Finished publishing this module.");
$this->info('Finished publishing this module.');
} else {
$this->info("You cancelled publishing this module");
$this->info('You cancelled publishing this module');
}
}

Expand All @@ -101,5 +98,4 @@ protected function getOptions()
{
return [];
}

}
53 changes: 24 additions & 29 deletions src/Console/Setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
namespace Yab\Quarx\Console;

use Artisan;
use Illuminate\Support\Str;
use Illuminate\Support\Schema;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Config;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\Config;

class Setup extends Command
{
Expand Down Expand Up @@ -39,18 +35,17 @@ public function fire()
$cssReady = $this->confirm('Please confirm that you have gulp fully installed.');

if ($cssReady) {

Artisan::call('vendor:publish', [
'--provider' => 'Yab\Quarx\QuarxProvider',
'--force' => true
'--force' => true,
]);

Artisan::call('vendor:publish', [
'--provider' => 'Yab\Laracogs\LaracogsProvider',
'--force' => true
'--force' => true,
]);

$this->line("Are you sure you want to run the setup? (yes/no)");
$this->line('Are you sure you want to run the setup? (yes/no)');

Artisan::call('laracogs:starter');

Expand Down Expand Up @@ -79,7 +74,7 @@ public function fire()
$routeContents = str_replace("'auth' => \App\Http\Middleware\Authenticate::class,", "'auth' => \App\Http\Middleware\Authenticate::class,\n\t\t'quarx' => \App\Http\Middleware\Quarx::class,\n\t\t'admin' => \App\Http\Middleware\Admin::class,", $routeContents);
file_put_contents(app_path('Http/Kernel.php'), $routeContents);

$fileSystem = new Filesystem;
$fileSystem = new Filesystem();

$files = $fileSystem->allFiles(__DIR__.'/../PublishedAssets/Setup');

Expand All @@ -95,7 +90,7 @@ public function fire()

// AuthProviders
$authProviderContents = file_get_contents(app_path('Providers/AuthServiceProvider.php'));
$authProviderContents = str_replace("\$this->registerPolicies(\$gate);", "\$this->registerPolicies(\$gate);\n\t\t\$gate->define('quarx', function (\$user) {\n\t\t\treturn (\$user->roles->first()->name === 'admin');\n\t\t});\n\t\t\$gate->define('admin', function (\$user) {\n\t\t\treturn (\$user->roles->first()->name === 'admin');\n\t\t});", $authProviderContents);
$authProviderContents = str_replace('$this->registerPolicies($gate);', "\$this->registerPolicies(\$gate);\n\t\t\$gate->define('quarx', function (\$user) {\n\t\t\treturn (\$user->roles->first()->name === 'admin');\n\t\t});\n\t\t\$gate->define('admin', function (\$user) {\n\t\t\treturn (\$user->roles->first()->name === 'admin');\n\t\t});", $authProviderContents);
file_put_contents(app_path('Providers/AuthServiceProvider.php'), $authProviderContents);

// Remove the teams
Expand Down Expand Up @@ -129,7 +124,7 @@ public function fire()
Route::resource('teams', 'TeamController', ['except' => ['show']]);
Route::post('teams/search', 'TeamController@search');
Route::post('teams/{id}/invite', 'TeamController@inviteMember');
Route::get('teams/{id}/remove/{userId}', 'TeamController@removeMember');", "", $mainRoutes);
Route::get('teams/{id}/remove/{userId}', 'TeamController@removeMember');", '', $mainRoutes);
file_put_contents(app_path('Http/routes.php'), $mainRoutes);

$userModel = file_get_contents(app_path('Repositories/User/User.php'));
Expand Down Expand Up @@ -168,30 +163,30 @@ public function isTeamAdmin(\$id)
{
\$team = \$this->teams->find(\$id);
return (int)\$team->user_id === (int)\$this->id;
}", "", $userModel);
}", '', $userModel);
file_put_contents(app_path('Repositories/User/User.php'), $userModel);

$userService = file_get_contents(app_path('Services/UserService.php'));
$userService = str_replace("/*
$userService = str_replace('/*
|--------------------------------------------------------------------------
| Teams
|--------------------------------------------------------------------------
*/
public function joinTeam(\$teamId, \$userId)
public function joinTeam($teamId, $userId)
{
return \$this->userRepo->joinTeam(\$teamId, \$userId);
return $this->userRepo->joinTeam($teamId, $userId);
}
public function leaveTeam(\$teamId, \$userId)
public function leaveTeam($teamId, $userId)
{
return \$this->userRepo->leaveTeam(\$teamId, \$userId);
return $this->userRepo->leaveTeam($teamId, $userId);
}
public function leaveAllTeams(\$userId)
public function leaveAllTeams($userId)
{
return \$this->userRepo->leaveAllTeams(\$userId);
}", "", $userService);
return $this->userRepo->leaveAllTeams($userId);
}', '', $userService);
file_put_contents(app_path('Services/UserService.php'), $userService);

exec('composer dump');
Expand All @@ -207,22 +202,22 @@ public function leaveAllTeams(\$userId)
file_put_contents(base_path('composer.json'), $composer);

Artisan::call('theme:publish', [
'name' => 'default'
'name' => 'default',
]);

Artisan::call('migrate:reset', [
'--force' => true
'--force' => true,
]);

Artisan::call('migrate', [
'--seed' => true,
'--force' => true
'--seed' => true,
'--force' => true,
]);

$this->info("Finished setting up your site with Quarx");
$this->line("You can now login with the following username and password:");
$this->comment("admin@admin.com");
$this->comment("admin");
$this->info('Finished setting up your site with Quarx');
$this->line('You can now login with the following username and password:');
$this->comment('admin@admin.com');
$this->comment('admin');
} else {
$this->info('Please run:');
$this->comment('npm install');
Expand Down

0 comments on commit 2e514b3

Please sign in to comment.