Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
railken committed Jul 23, 2018
1 parent 9570575 commit 0c6ae4e
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 42 deletions.
22 changes: 15 additions & 7 deletions config/ore.tax.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| Table
Expand All @@ -13,14 +12,23 @@
'table' => 'ore_taxes',

'attributes' => [

],

'router' => [
'prefix' => '/admin/taxes',
'middlewares' => [
\Railken\LaraOre\RequestLoggerMiddleware::class,
'auth:api',
/*
|--------------------------------------------------------------------------
| Http configuration
|--------------------------------------------------------------------------
|
| Here you may configure the routes
|
*/
'http' => [
'admin' => [
'enabled' => true,
'controller' => Railken\LaraOre\Http\Controllers\Admin\TaxesController::class,
'router' => [
'prefix' => '/admin/taxes',
],
],
],
];
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ class CreateTaxesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Expand All @@ -26,8 +24,6 @@ public function up()

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Railken\LaraOre\Http\Controllers;
namespace Railken\LaraOre\Http\Controllers\Admin;

use Illuminate\Support\Facades\Config;
use Railken\LaraOre\Api\Http\Controllers\RestController;
Expand Down
4 changes: 2 additions & 2 deletions src/Tax/TaxFaker.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Railken\LaraOre\Tax;

use Railken\Bag;
use Faker\Factory;
use Railken\Bag;
use Railken\Laravel\Manager\BaseFaker;

class TaxFaker extends BaseFaker
Expand All @@ -21,7 +21,7 @@ public function parameters()
$faker = Factory::create();

$bag = new Bag();
$bag->set('name', "VAT 22%");
$bag->set('name', 'VAT 22%');
$bag->set('description', $faker->realText);
$bag->set('calculator', 'x*0.22');

Expand Down
29 changes: 14 additions & 15 deletions src/TaxServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Railken\LaraOre;

use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\ServiceProvider;
use Railken\LaraOre\Api\Support\Router;
Expand All @@ -10,8 +11,6 @@ class TaxServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Expand All @@ -27,8 +26,6 @@ public function boot()

/**
* Register any application services.
*
* @return void
*/
public function register()
{
Expand All @@ -39,19 +36,21 @@ public function register()

/**
* Load routes.
*
* @return void
*/
public function loadRoutes()
{
Router::group(array_merge(Config::get('ore.tax.router'), [
'namespace' => 'Railken\LaraOre\Http\Controllers',
]), function ($router) {
$router->get('/', ['uses' => 'TaxesController@index']);
$router->post('/', ['uses' => 'TaxesController@create']);
$router->put('/{id}', ['uses' => 'TaxesController@update']);
$router->delete('/{id}', ['uses' => 'TaxesController@remove']);
$router->get('/{id}', ['uses' => 'TaxesController@show']);
});
$config = Config::get('ore.tax.http.admin');

if (Arr::get($config, 'enabled')) {
Router::group('admin', Arr::get($config, 'router'), function ($router) use ($config) {
$controller = Arr::get($config, 'controller');

$router->get('/', ['uses' => $controller.'@index']);
$router->post('/', ['uses' => $controller.'@create']);
$router->put('/{id}', ['uses' => $controller.'@update']);
$router->delete('/{id}', ['uses' => $controller.'@remove']);
$router->get('/{id}', ['uses' => $controller.'@show']);
});
}
}
}
4 changes: 1 addition & 3 deletions tests/Tax/ApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ class ApiTest extends BaseTest
*/
public function getBaseUrl()
{
return Config::get('ore.api.router.prefix').Config::get('ore.tax.router.prefix');
return Config::get('ore.api.router.prefix').Config::get('ore.tax.http.admin.router.prefix');
}

/**
* Test common requests.
*
* @return void
*/
public function testSuccessCommon()
{
Expand Down
16 changes: 7 additions & 9 deletions tests/Tax/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,8 @@

namespace Railken\LaraOre\Tests\Tax;

use Railken\Bag;

abstract class BaseTest extends \Orchestra\Testbench\TestCase
{
protected function getPackageProviders($app)
{
return [
\Railken\LaraOre\TaxServiceProvider::class,
];
}

/**
* Setup the test environment.
*/
Expand All @@ -27,4 +18,11 @@ public function setUp()
$this->artisan('vendor:publish', ['--provider' => 'Railken\LaraOre\TaxServiceProvider', '--force' => true]);
$this->artisan('migrate');
}

protected function getPackageProviders($app)
{
return [
\Railken\LaraOre\TaxServiceProvider::class,
];
}
}
2 changes: 1 addition & 1 deletion tests/Tax/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Railken\LaraOre\Tests\Tax;

use Railken\LaraOre\Support\Testing\ManagerTestableTrait;
use Railken\LaraOre\Tax\TaxManager;
use Railken\LaraOre\Tax\TaxFaker;
use Railken\LaraOre\Tax\TaxManager;

class ManagerTest extends BaseTest
{
Expand Down

0 comments on commit 0c6ae4e

Please sign in to comment.