Skip to content

Commit

Permalink
Merge pull request #29 from point-red/develop
Browse files Browse the repository at this point in the history
Add new HR Modules for KPI
  • Loading branch information
martiendt committed Jun 9, 2018
2 parents b142054 + 8c5b407 commit 775da2c
Show file tree
Hide file tree
Showing 117 changed files with 3,919 additions and 141 deletions.
111 changes: 111 additions & 0 deletions app/Console/Commands/GenerateScaffoldingCommand.php
@@ -0,0 +1,111 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;

class GenerateScaffoldingCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'scaffolding:generate {module} {name} {--submodule=}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Generate scaffolding';

protected $name;

protected $module;

protected $submodule;

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->module = $this->argument('module').DIRECTORY_SEPARATOR;
$this->name = $this->argument('name');

if ($this->option('submodule')) {
$this->submodule = $this->option('submodule').DIRECTORY_SEPARATOR;
}

Artisan::call('make:model', [
'name' => 'Model\\'.$this->module.$this->submodule.$this->name,
'-m' => true,
]);

$this->line('created '.$this->name.' model');

Artisan::call('make:controller', [
'name' => 'Api\\'.$this->module.$this->submodule.$this->name.'Controller',
'-r' => true,
]);

$this->line('created '.$this->name.' controller');

Artisan::call('make:resource', [
'name' => $this->module.$this->submodule.$this->name.'\\'.$this->name.'Resource',
]);

$this->line('created '.$this->name.' resource');

Artisan::call('make:resource', [
'name' => $this->module.$this->submodule.$this->name.'\\'.$this->name.'Collection',
'--collection' => true,
]);

$this->line('created '.$this->name.' collection');

Artisan::call('make:request', [
'name' => $this->module.$this->submodule.$this->name.'\\Store'.$this->name.'Request',
]);

$this->line('created '.$this->name.' store request');

Artisan::call('make:request', [
'name' => $this->module.$this->submodule.$this->name.'\\Update'.$this->name.'Request',
]);

$this->line('created '.$this->name.' update request');

Artisan::call('make:factory', [
'name' => $this->name.'Factory',
]);

$this->line('created '.$this->name.' factory');

Artisan::call('make:test', [
'name' => $this->module.$this->submodule.$this->name.'Test',
]);

$this->line('created '.$this->name.' test class');

Artisan::call('make:test', [
'name' => $this->module.$this->submodule.$this->name.'ValidationTest',
]);

$this->line('created '.$this->name.' validation test class');
}
}
100 changes: 0 additions & 100 deletions app/Console/Commands/ScaffoldingMasterCommand.php

This file was deleted.

57 changes: 57 additions & 0 deletions app/Console/Commands/SeedDummyDatabase.php
@@ -0,0 +1,57 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Artisan;

class SeedDummyDatabase extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'tenant:seed-dummy {tenant_subdomain}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Seed dummy data for tenant';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
Artisan::call('db:seed', [
'--database' => 'mysql',
'--class' => 'DummyDatabaseSeeder',
]);

$tenantSubdomain = $this->argument('tenant_subdomain');

config()->set('database.connections.tenant.database', $tenantSubdomain);
DB::connection('tenant')->reconnect();

Artisan::call('db:seed', [
'--database' => 'tenant',
'--class' => 'DummyTenantDatabaseSeeder',
]);
}
}
8 changes: 8 additions & 0 deletions app/Console/Commands/SetupTenantDatabase.php
Expand Up @@ -3,6 +3,7 @@
namespace App\Console\Commands;

use Illuminate\Console\Command;
use Symfony\Component\Process\Process;
use Illuminate\Support\Facades\Artisan;

class SetupTenantDatabase extends Command
Expand Down Expand Up @@ -40,6 +41,13 @@ public function handle()
{
$tenantSubdomain = $this->argument('tenant_subdomain');

$process = new Process('mysql -u '.env('DB_TENANT_USERNAME').' -p'.env('DB_TENANT_PASSWORD').' -e "drop database if exists '.$tenantSubdomain.'"');
$process->run();

// create new database
$process = new Process('mysql -u '.env('DB_TENANT_USERNAME').' -p'.env('DB_TENANT_PASSWORD').' -e "create database '.$tenantSubdomain.'"');
$process->run();

config()->set('database.connections.tenant.database', $tenantSubdomain);

Artisan::call('migrate:refresh', [
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/SetupTenantDatabaseSeeder.php
Expand Up @@ -41,7 +41,7 @@ public function handle()
{
$tenantSubdomain = $this->argument('tenant_subdomain');

config()->set('database.connections.tenant.database', 'point_'.$tenantSubdomain);
config()->set('database.connections.tenant.database', $tenantSubdomain);
DB::connection('tenant')->reconnect();

Artisan::call('db:seed', [
Expand Down
@@ -0,0 +1,88 @@
<?php

namespace App\Http\Controllers\Api\HumanResource\Kpi;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Model\HumanResource\Kpi\KpiCategory;
use App\Http\Resources\HumanResource\Kpi\KpiCategory\KpiCategoryResource;
use App\Http\Resources\HumanResource\Kpi\KpiCategory\KpiCategoryCollection;
use App\Http\Requests\HumanResource\Kpi\KpiCategory\StoreKpiCategoryRequest;
use App\Http\Requests\HumanResource\Kpi\KpiCategory\UpdateKpiCategoryRequest;

class KpiCategoryController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \App\Http\Resources\HumanResource\Kpi\KpiCategory\KpiCategoryCollection
*/
public function index(Request $request)
{
$limit = $request->input('limit') ?? 0;

return new KpiCategoryCollection(KpiCategory::paginate($limit));
}

/**
* Store a newly created resource in storage.
*
* @param \App\Http\Requests\HumanResource\Kpi\KpiCategory\StoreKpiCategoryRequest $request
*
* @return \App\Http\Resources\HumanResource\Kpi\KpiCategory\KpiCategoryResource
*/
public function store(StoreKpiCategoryRequest $request)
{
$kpiCategory = new KpiCategory();
$kpiCategory->name = $request->input('name');
$kpiCategory->date = $request->input('date');
$kpiCategory->person_id = $request->input('person_id');
$kpiCategory->save();

return new KpiCategoryResource($kpiCategory);
}

/**
* Display the specified resource.
*
* @param int $id
*
* @return \App\Http\Resources\HumanResource\Kpi\KpiCategory\KpiCategoryResource
*/
public function show($id)
{
return new KpiCategoryResource(KpiCategory::findOrFail($id));
}

/**
* Update the specified resource in storage.
*
* @param \App\Http\Requests\HumanResource\Kpi\KpiCategory\UpdateKpiCategoryRequest $request
* @param int $id
*
* @return \App\Http\Resources\HumanResource\Kpi\KpiCategory\KpiCategoryResource
*/
public function update(UpdateKpiCategoryRequest $request, $id)
{
$kpiCategory = KpiCategory::findOrFail($id);
$kpiCategory->name = $request->input('name');
$kpiCategory->date = $request->input('date');
$kpiCategory->person_id = $request->input('person_id');
$kpiCategory->save();

return new KpiCategoryResource($kpiCategory);
}

/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
KpiCategory::findOrFail($id)->delete();

return response(null, 204);
}
}

0 comments on commit 775da2c

Please sign in to comment.