image fixes
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Lucent\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class GenerateImageFilter extends Command
|
||||
{
|
||||
protected $signature = "lucent:generate:image_filter {name}";
|
||||
|
||||
protected $description = "Generate an image filter";
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$name = $this->argument("name");
|
||||
$relativePath = config("lucent.image_filter_path");
|
||||
$dir = base_path($relativePath);
|
||||
|
||||
if (!is_dir($dir)) {
|
||||
mkdir($dir, 0755, true);
|
||||
}
|
||||
|
||||
$filePath = "{$dir}/{$name}.php";
|
||||
|
||||
if (file_exists($filePath)) {
|
||||
$this->error("Filter {$name} already exists at {$filePath}");
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
$namespace = str_replace("/", "\\", ucwords($relativePath, "/"));
|
||||
|
||||
$stub = <<<PHP
|
||||
<?php namespace {$namespace};
|
||||
|
||||
use Lucent\ImageFilterInterface;
|
||||
use Intervention\Image\Interfaces\ImageInterface;
|
||||
|
||||
class {$name} implements ImageFilterInterface
|
||||
{
|
||||
public function apply(ImageInterface \$image): ImageInterface
|
||||
{
|
||||
return \$image;
|
||||
}
|
||||
|
||||
public function getName(): string {
|
||||
return "{$name}";
|
||||
}
|
||||
|
||||
public function getPath(): string {
|
||||
return "{$name}";
|
||||
}
|
||||
}
|
||||
PHP;
|
||||
|
||||
file_put_contents($filePath, $stub);
|
||||
|
||||
$this->info("Created {$filePath}");
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user