Skip to content

Commit

Permalink
added delete command and fixed paths
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Nov 1, 2019
1 parent 2167909 commit 26931a3
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 7 deletions.
47 changes: 47 additions & 0 deletions src/Commands/DeleteCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace Akaunting\Module\Commands;

use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputArgument;

class DeleteCommand extends Command
{
/**
* The console command name.
*
* @var string
*/
protected $name = 'module:delete';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Delete the specified module.';

/**
* Execute the console command.
*/
public function handle()
{
$module = $this->laravel['module']->findOrFail($this->argument('alias'));

$module->delete();

$this->info("Module [{$module}] deleted successful.");
}

/**
* Get the console command arguments.
*
* @return array
*/
protected function getArguments()
{
return [
['alias', InputArgument::REQUIRED, 'Module alias.'],
];
}
}
4 changes: 2 additions & 2 deletions src/FileRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,9 @@ public function asset($asset) : string
}
list($name, $url) = explode(':', $asset);

$baseUrl = str_replace(public_path() . DIRECTORY_SEPARATOR, '', $this->getAssetsPath());
$base_url = str_replace(public_path() . '/', '', $this->getAssetsPath());

$url = $this->url->asset($baseUrl . "/{$name}/" . $url);
$url = $this->url->asset($base_url . "/{$name}/" . $url);

return str_replace(['http://', 'https://'], '//', $url);
}
Expand Down
2 changes: 2 additions & 0 deletions src/Providers/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Akaunting\Module\Commands\CommandMakeCommand;
use Akaunting\Module\Commands\ControllerMakeCommand;
use Akaunting\Module\Commands\DeleteCommand;
use Akaunting\Module\Commands\DisableCommand;
use Akaunting\Module\Commands\DumpCommand;
use Akaunting\Module\Commands\EnableCommand;
Expand Down Expand Up @@ -52,6 +53,7 @@ class Console extends ServiceProvider
protected $commands = [
CommandMakeCommand::class,
ControllerMakeCommand::class,
DeleteCommand::class,
DisableCommand::class,
DumpCommand::class,
EnableCommand::class,
Expand Down
10 changes: 5 additions & 5 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@
function module($alias = null)
{
$module = app('module');

if (is_null($alias)) {
return $module;
}

return $module->get($alias);
}
}

if (!function_exists('module_path')) {
function module_path($alias)
function module_path($alias, $path = '')
{
$module = app('module')->find($alias);

return $module->getPath();
return $module->getPath() . ($path ? '/' . $path : $path);
}
}

Expand Down Expand Up @@ -53,6 +53,6 @@ function config_path($path = '')
*/
function public_path($path = '')
{
return app()->make('path.public') . ($path ? DIRECTORY_SEPARATOR . ltrim($path, DIRECTORY_SEPARATOR) : $path);
return app()->make('path.public') . ($path ? '/' . $path : $path);
}
}

0 comments on commit 26931a3

Please sign in to comment.