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

Commit

Permalink
Now supports custom namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
mlantz committed Apr 16, 2016
1 parent 07186dc commit 7084d29
Show file tree
Hide file tree
Showing 61 changed files with 284 additions and 266 deletions.
8 changes: 4 additions & 4 deletions src/API/app/Http/Controllers/Api/AuthController.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

namespace App\Http\Controllers\Api;
namespace {{App\}}Http\Controllers\Api;

use DB;
use Validator;
use Illuminate\Http\Request;
use App\Services\UserService;
use App\Repositories\User\User;
use {{App\}}Services\UserService;
use {{App\}}Repositories\User\User;
use Tymon\JWTAuth\Facades\JWTAuth;
use App\Http\Controllers\Controller;
use {{App\}}Http\Controllers\Controller;

class AuthController extends Controller
{
Expand Down
10 changes: 5 additions & 5 deletions src/API/app/Http/Controllers/Api/UserController.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

namespace App\Http\Controllers\Api;
namespace {{App\}}Http\Controllers\Api;

use Auth;
use App\Http\Requests;
use {{App\}}Http\Requests;
use Illuminate\Http\Request;
use App\Services\UserService;
use {{App\}}Services\UserService;
use Tymon\JWTAuth\Facades\JWTAuth;
use App\Http\Controllers\Controller;
use App\Http\Requests\UpdateUserRequest;
use {{App\}}Http\Controllers\Controller;
use {{App\}}Http\Requests\UpdateUserRequest;

class UserController extends Controller
{
Expand Down
6 changes: 3 additions & 3 deletions src/Billing/app/Http/Controllers/User/BillingController.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

namespace App\Http\Controllers\User;
namespace {{App\}}Http\Controllers\User;

use Auth;
use Activity;
use Carbon\Carbon;
use App\Http\Requests;
use {{App\}}Http\Requests;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use {{App\}}Http\Controllers\Controller;

class BillingController extends Controller
{
Expand Down
4 changes: 2 additions & 2 deletions src/Billing/app/Repositories/UserMeta/UserMeta.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace App\Repositories\UserMeta;
namespace {{App\}}Repositories\UserMeta;

use Laravel\Cashier\Billable;
use App\Repositories\User\User;
use {{App\}}Repositories\User\User;
use Illuminate\Database\Eloquent\Model;

class UserMeta extends Model
Expand Down
6 changes: 3 additions & 3 deletions src/Billing/tests/BillingIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class BillingIntegrationTest extends TestCase
public function setUp()
{
parent::setUp();
$this->user = factory(App\Repositories\User\User::class)->create([ 'id' => rand(1000, 9999) ]);
$this->user->meta = factory(App\Repositories\UserMeta\UserMeta::class)->create([ 'id' => $this->user->id ]);
$this->role = factory(App\Repositories\Role\Role::class)->create(['name' => 'admin']);
$this->user = factory({{App\}}Repositories\User\User::class)->create([ 'id' => rand(1000, 9999) ]);
$this->user->meta = factory({{App\}}Repositories\UserMeta\UserMeta::class)->create([ 'id' => $this->user->id ]);
$this->role = factory({{App\}}Repositories\Role\Role::class)->create(['name' => 'admin']);
$this->user->roles()->attach($this->role);
$this->actor = $this->actingAs($this->user);
$subscription = Mockery::mock('subscription')->shouldReceive('upcomingInvoice')->withAnyArgs()->andReturn([])->getMock();
Expand Down
14 changes: 4 additions & 10 deletions src/Console/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Yab\Laracogs\Generators\FileMakerTrait;

class Api extends Command
{
use FileMakerTrait;

/**
* The console command name.
*
Expand Down Expand Up @@ -46,16 +49,7 @@ public function handle()
$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(__DIR__.'/../Api/', '', $file);
$this->line("Copying ".$newFileName."...");
if (is_dir($file)) {
$fileSystem->copyDirectory($file, base_path($newFileName));
} else {
@mkdir(base_path(str_replace(basename($newFileName), '', $newFileName)), 0755, true);
$fileSystem->copy($file, base_path($newFileName));
}
}
$this->copyPreparedFiles(__DIR__.'/../Api/', base_path());

$this->info("\n\n You will need to run: composer require tymon/jwt-auth");
$this->info("\n\n Then follow the directions regarding installation on: https://github.com/tymondesigns/jwt-auth/wiki/Installation");
Expand Down
14 changes: 4 additions & 10 deletions src/Console/Billing.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Yab\Laracogs\Generators\FileMakerTrait;

class Billing extends Command
{
use FileMakerTrait;

/**
* The console command name.
*
Expand Down Expand Up @@ -46,16 +49,7 @@ public function handle()
$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(__DIR__.'/../Billing/', '', $file);
$this->line("Copying ".$newFileName."...");
if (is_dir($file)) {
$fileSystem->copyDirectory($file, base_path($newFileName));
} else {
@mkdir(base_path(str_replace(basename($newFileName), '', $newFileName)), 0755, true);
$fileSystem->copy($file, base_path($newFileName));
}
}
$this->copyPreparedFiles(__DIR__.'/../Billing/', base_path());

$this->info("\n\n You will need to run: composer require laravel/cashier");
$this->info("\n\n Then follow the directions regarding billing on: https://laravel.com/docs/");
Expand Down
14 changes: 4 additions & 10 deletions src/Console/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Yab\Laracogs\Generators\FileMakerTrait;

class Bootstrap extends Command
{
use FileMakerTrait;

/**
* The console command name.
*
Expand Down Expand Up @@ -46,16 +49,7 @@ public function handle()
$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(__DIR__.'/../Bootstrap/', '', $file);
$this->line("Copying ".$newFileName."...");
if (is_dir($file)) {
$fileSystem->copyDirectory($file, base_path($newFileName));
} else {
@mkdir(base_path(str_replace(basename($newFileName), '', $newFileName)), 0755, true);
$fileSystem->copy($file, base_path($newFileName));
}
}
$this->copyPreparedFiles(__DIR__.'/../Bootstrap/', base_path());

$this->info("\n\nMake sure you set the PagesController@dashboard to use the following view: 'dashboard.main'\n\n");
$this->info("Finished bootstrapping your app");
Expand Down
33 changes: 19 additions & 14 deletions src/Console/Crud.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
use Artisan;
use Illuminate\Console\Command;
use Yab\Laracogs\Generators\CrudGenerator;
use Illuminate\Console\AppNamespaceDetectorTrait;

class Crud extends Command
{
use AppNamespaceDetectorTrait;

/**
* The console command name.
*
Expand Down Expand Up @@ -56,13 +59,14 @@ public function handle()
'_path_api_routes_' => app_path('Http/api-routes.php'),
'routes_prefix' => '',
'routes_suffix' => '',
'_namespace_services_' => 'App\Services',
'_namespace_facade_' => 'App\Facades',
'_namespace_repository_' => 'App\Repositories\_table_',
'_namespace_model_' => 'App\Repositories\_table_',
'_namespace_controller_' => 'App\Http\Controllers',
'_namespace_api_controller_' => 'App\Http\Controllers\Api',
'_namespace_request_' => 'App\Http\Requests',
'_app_namespace_' => $this->getAppNamespace(),
'_namespace_services_' => $this->getAppNamespace().'Services',
'_namespace_facade_' => $this->getAppNamespace().'Facades',
'_namespace_repository_' => $this->getAppNamespace().'Repositories\_table_',
'_namespace_model_' => $this->getAppNamespace().'Repositories\_table_',
'_namespace_controller_' => $this->getAppNamespace().'Http\Controllers',
'_namespace_api_controller_' => $this->getAppNamespace().'Http\Controllers\Api',
'_namespace_request_' => $this->getAppNamespace().'Http\Requests',
'_table_name_' => str_plural(strtolower($table)),
'_lower_case_' => strtolower($table),
'_lower_casePlural_' => str_plural(strtolower($table)),
Expand Down Expand Up @@ -93,13 +97,14 @@ public function handle()
'_path_api_routes_' => app_path('Http/api-routes.php'),
'routes_prefix' => "\n\nRoute::group(['namespace' => '".ucfirst($section)."', 'prefix' => '".strtolower($section)."', 'middleware' => ['web']], function () { \n",
'routes_suffix' => "\n});",
'_namespace_services_' => 'App\Services\\'.ucfirst($section),
'_namespace_facade_' => 'App\Facades',
'_namespace_repository_' => 'App\Repositories\\'.ucfirst($section).'\\'.ucfirst($table),
'_namespace_model_' => 'App\Repositories\\'.ucfirst($section).'\\'.ucfirst($table),
'_namespace_controller_' => 'App\Http\Controllers\\'.ucfirst($section),
'_namespace_api_controller_' => 'App\Http\Controllers\\'.ucfirst($section).'\Api\\',
'_namespace_request_' => 'App\Http\Requests\\'.ucfirst($section),
'_app_namespace_' => $this->getAppNamespace(),
'_namespace_services_' => $this->getAppNamespace().'Services\\'.ucfirst($section),
'_namespace_facade_' => $this->getAppNamespace().'Facades',
'_namespace_repository_' => $this->getAppNamespace().'Repositories\\'.ucfirst($section).'\\'.ucfirst($table),
'_namespace_model_' => $this->getAppNamespace().'Repositories\\'.ucfirst($section).'\\'.ucfirst($table),
'_namespace_controller_' => $this->getAppNamespace().'Http\Controllers\\'.ucfirst($section),
'_namespace_api_controller_' => $this->getAppNamespace().'Http\Controllers\\'.ucfirst($section).'\Api\\',
'_namespace_request_' => $this->getAppNamespace().'Http\Requests\\'.ucfirst($section),
'_table_name_' => str_plural(strtolower(implode('_', $splitTable))),
'_lower_case_' => strtolower($table),
'_lower_casePlural_' => str_plural(strtolower($table)),
Expand Down
3 changes: 3 additions & 0 deletions src/Console/Docs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

use Markdown;
use Illuminate\Console\Command;
use Illuminate\Console\AppNamespaceDetectorTrait;

class Docs extends Command
{
use AppNamespaceDetectorTrait;

/**
* The console command name.
*
Expand Down
48 changes: 32 additions & 16 deletions src/Console/Notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Yab\Laracogs\Generators\FileMakerTrait;

class Notifications extends Command
{
use FileMakerTrait;

/**
* The console command name.
*
Expand Down Expand Up @@ -46,22 +49,8 @@ public function handle()
$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(__DIR__.'/../Notifications/', '', $file);
$this->line("Copying ".$newFileName."...");
if (is_dir($file)) {
$fileSystem->copyDirectory($file, base_path($newFileName));
} else {
@mkdir(base_path(str_replace(basename($newFileName), '', $newFileName)), 0755, true);
if (! stristr($file, 'Factory.txt') ) {
$fileSystem->copy($file, base_path($newFileName));
} else {
$factory = file_get_contents($file);
$factoryMaster = base_path('database/factories/ModelFactory.php');
file_put_contents($factoryMaster, $factory, FILE_APPEND);
}
}
}
$this->copyPreparedFiles(__DIR__.'/../Notifications', base_path());
$this->appendTheFactory();

$this->info("\n\n You will need to run: composer require laravel/cashier");
$this->info("\n\n Then follow the directions regarding notifications on: https://laravel.com/docs/");
Expand All @@ -84,4 +73,31 @@ public function handle()
}
}
}

public function appendTheFactory()
{
$factory = file_get_contents(__DIR__.'/../Starter/Factory.txt');
$factoryPrepared = "
/*
|--------------------------------------------------------------------------
| Notification Factory
|--------------------------------------------------------------------------
*/
\$factory->define(".$this->getAppNamespace()."Repositories\Notification\Notification::class, function (Faker\Generator \$faker) {
return [
'id' => 1,
'user_id' => 1,
'flag' => 'info',
'uuid' => 'lksjdflaskhdf',
'title' => 'Testing',
'details' => 'Your car has been impounded!',
'is_read' => 0,
];
});
";

$factoryMaster = base_path('database/factories/ModelFactory.php');
return file_put_contents($factoryMaster, $factoryPrepared, FILE_APPEND);
}
}
14 changes: 4 additions & 10 deletions src/Console/Socialite.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Yab\Laracogs\Generators\FileMakerTrait;

class Socialite extends Command
{
use FileMakerTrait;

/**
* The console command name.
*
Expand Down Expand Up @@ -46,16 +49,7 @@ public function handle()
$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(__DIR__.'/../Socialite/', '', $file);
$this->line("Copying ".$newFileName."...");
if (is_dir($file)) {
$fileSystem->copyDirectory($file, base_path($newFileName));
} else {
@mkdir(base_path(str_replace(basename($newFileName), '', $newFileName)), 0755, true);
$fileSystem->copy($file, base_path($newFileName));
}
}
$this->copyPreparedFiles(__DIR__.'/../Socialite', base_path());

$this->info("\n\n You will need to run: composer require laravel/socialite");
$this->info("\n\n Then follow the directions regarding billing on: https://laravel.com/docs/");
Expand Down
Loading

0 comments on commit 7084d29

Please sign in to comment.