Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

30 changes: 20 additions & 10 deletions src/Commands/Application/DataTransferObjectMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,40 @@
namespace KoalaFacade\DiamondConsole\Commands\Application;

use Illuminate\Console\Command;
use KoalaFacade\DiamondConsole\Commands\Application\Concerns\InteractsWithConsoleInApplication;
use KoalaFacade\DiamondConsole\Commands\Concerns\HasArguments;
use KoalaFacade\DiamondConsole\Commands\Concerns\HasOptions;
use KoalaFacade\DiamondConsole\Commands\Concerns\InteractsWithConsole;
use KoalaFacade\DiamondConsole\Contracts\Console;
use KoalaFacade\DiamondConsole\DataTransferObjects\NamespaceData;
use KoalaFacade\DiamondConsole\DataTransferObjects\PlaceholderData;
use KoalaFacade\DiamondConsole\Support\Source;

class DataTransferObjectMakeCommand extends Command implements Console
{
use HasArguments, HasOptions, InteractsWithConsoleInApplication;
use HasArguments, HasOptions, InteractsWithConsole;

protected $signature = 'application:make:data-transfer-object {name} {domain} {--force}';

protected $description = 'Create a new Data Transfer Object';

public function beforeCreate(): void
{
$this->info(string: 'Generating action file to your project');
}

public function afterCreate(): void
{
$this->info(string: 'Successfully generate action file');
}

public function getNamespace(): string
{
return Source::resolveNamespace(
data: new NamespaceData(
structures: Source::resolveApplicationPath() . '\\DataTransferObjects',
domainArgument: $this->resolveDomainArgument(),
structures: Source::resolveApplicationPath(),
nameArgument: $this->resolveNameArgument(),
endsWith: 'DataTransferObjects',
)
);
}
Expand All @@ -34,13 +46,11 @@ public function getStubPath(): string
return Source::resolveStubForPath(name: 'application/data-transfer-object');
}

public function beforeCreate(): void
public function resolvePlaceholders(): PlaceholderData
{
$this->info(string: 'Generating data transfer object file to your project');
}

public function afterCreate(): void
{
$this->info(string: 'Successfully generate data transfer object file');
return new PlaceholderData(
namespace: $this->getNamespace(),
class: $this->getClassName(),
);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace KoalaFacade\DiamondConsole\Commands\Infrastructure;
namespace KoalaFacade\DiamondConsole\Commands\Application;

use Illuminate\Console\Command;
use Illuminate\Support\Str;
Expand All @@ -16,7 +16,7 @@ class ProviderMakeCommand extends Command implements Console
{
use HasArguments, HasOptions, InteractsWithConsole;

protected $signature = 'infrastructure:make:provider {name} {domain} {--force}';
protected $signature = 'application:make:provider {name} {domain} {--force}';

protected $description = 'Create a new service provider class';

Expand All @@ -34,8 +34,8 @@ public function getNamespace(): string
{
return Source::resolveNamespace(
data: new NamespaceData(
structures: Source::resolveInfrastructurePath(),
domainArgument: $this->resolveDomainArgument(),
structures: Source::resolveApplicationPath(),
nameArgument: $this->resolveNameArgument(),
endsWith: 'Providers',
)
Expand All @@ -44,7 +44,7 @@ public function getNamespace(): string

public function getStubPath(): string
{
return Source::resolveStubForPath(name: 'infrastructure/provider');
return Source::resolveStubForPath(name: 'application/provider');
}

public function resolvePlaceholders(): PlaceholderData
Expand Down
24 changes: 17 additions & 7 deletions src/Commands/Application/RequestMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,40 @@
namespace KoalaFacade\DiamondConsole\Commands\Application;

use Illuminate\Console\Command;
use KoalaFacade\DiamondConsole\Commands\Application\Concerns\InteractsWithConsoleInApplication;
use KoalaFacade\DiamondConsole\Commands\Concerns\HasArguments;
use KoalaFacade\DiamondConsole\Commands\Concerns\HasOptions;
use KoalaFacade\DiamondConsole\Commands\Concerns\InteractsWithConsole;
use KoalaFacade\DiamondConsole\Contracts\Console;
use KoalaFacade\DiamondConsole\DataTransferObjects\NamespaceData;
use KoalaFacade\DiamondConsole\DataTransferObjects\PlaceholderData;
use KoalaFacade\DiamondConsole\Support\Source;

class RequestMakeCommand extends Command implements Console
{
use HasArguments, HasOptions, InteractsWithConsoleInApplication;
use HasArguments, HasOptions, InteractsWithConsole;

protected $signature = 'application:make:request {name} {domain} {--force}';

protected $description = 'Create a new request';
protected $description = 'Create a new Request';

public function beforeCreate(): void
{
$this->info(string: 'Generating request file to your project');
$this->info(string: 'Generating action file to your project');
}

public function afterCreate(): void
{
$this->info(string: 'Successfully generate request file');
$this->info(string: 'Successfully generate action file');
}

public function getNamespace(): string
{
return Source::resolveNamespace(
data: new NamespaceData(
structures: Source::resolveApplicationPath() . '\\Http',
domainArgument: 'Requests\\' . $this->resolveDomainArgument(),
domainArgument: $this->resolveDomainArgument(),
structures: Source::resolveApplicationPath(),
nameArgument: $this->resolveNameArgument(),
endsWith: 'Requests',
)
);
}
Expand All @@ -43,4 +45,12 @@ public function getStubPath(): string
{
return Source::resolveStubForPath(name: 'application/request');
}

public function resolvePlaceholders(): PlaceholderData
{
return new PlaceholderData(
namespace: $this->getNamespace(),
class: $this->getClassName(),
);
}
}
30 changes: 15 additions & 15 deletions src/Commands/Application/ResourceMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,59 @@
namespace KoalaFacade\DiamondConsole\Commands\Application;

use Illuminate\Console\Command;
use Illuminate\Support\Str;
use KoalaFacade\DiamondConsole\Commands\Application\Concerns\InteractsWithConsoleInApplication;
use KoalaFacade\DiamondConsole\Commands\Concerns\HasArguments;
use KoalaFacade\DiamondConsole\Commands\Concerns\HasOptions;
use KoalaFacade\DiamondConsole\Commands\Concerns\InteractsWithConsole;
use KoalaFacade\DiamondConsole\Contracts\Console;
use KoalaFacade\DiamondConsole\DataTransferObjects\NamespaceData;
use KoalaFacade\DiamondConsole\DataTransferObjects\PlaceholderData;
use KoalaFacade\DiamondConsole\Support\Source;

class ResourceMakeCommand extends Command implements Console
{
use HasArguments, HasOptions, InteractsWithConsoleInApplication;
use HasArguments, HasOptions, InteractsWithConsole;

protected $signature = 'application:make:resource {name} {domain} {--model=} {--force}';

protected $description = 'Create a new resource';
protected $description = 'Create a new Resource';

public function beforeCreate(): void
{
$this->info(string: 'Generating resource file to your project');
$this->info(string: 'Generating action file to your project');
}

public function afterCreate(): void
{
$this->info(string: 'Successfully generate resource file');
$this->info(string: 'Successfully generate action file');
}

public function getNamespace(): string
{
return Source::resolveNamespace(
data: new NamespaceData(
structures: Source::resolveApplicationPath() . '\\Http',
domainArgument: 'Resources\\' . $this->resolveDomainArgument(),
domainArgument: $this->resolveDomainArgument(),
structures: Source::resolveApplicationPath(),
nameArgument: $this->resolveNameArgument(),
endsWith: 'Resources',
)
);
}

public function getStubPath(): string
{
$stub = 'application/resource';
$stubs = 'application/resource';

if ($this->resolveModelOption()) {
$stub .= '-model';
$stubs .= '-model';
}

return Source::resolveStubForPath(name: $stub);
return Source::resolveStubForPath(name: $stubs);
}

public function resolvePlaceholders(): PlaceholderData
{
return new PlaceholderData(
namespace: Str::ucfirst(string: $this->getNamespace()),
namespace: $this->getNamespace(),
class: $this->getClassName(),
model: $this->resolveModelOption(),
modelNamespace: $this->resolveModelNamespace()
Expand All @@ -67,10 +67,10 @@ public function resolveModelNamespace(): ?string
if ($this->resolveModelOption()) {
$namespace = Source::resolveNamespace(
data: new NamespaceData(
structures: Source::resolveDomainPath(),
domainArgument: 'Shared\\' . $this->resolveDomainArgument(),
domainArgument: $this->resolveDomainArgument(),
structures: Source::resolveInfrastructurePath(),
nameArgument: $this->resolveModelOption(),
endsWith: 'Models\\' . $this->resolveModelOption(),
endsWith: 'Database\\Models',
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ class {{ class }} extends ServiceProvider
{
/**
* Register services.
*
* @return void
*/
public function register(): void
{
Expand All @@ -18,8 +16,6 @@ class {{ class }} extends ServiceProvider

/**
* Bootstrap services.
*
* @return void
*/
public function boot(): void
{
Expand Down
2 changes: 1 addition & 1 deletion stubs/application/resource-model.stub
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace {{ namespace }};

use {{ modelNamespace }};
use {{ modelNamespace }}\{{ model }};
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
Expand Down
Loading