helper commands
This commit is contained in:
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Lucent\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Lucent\Primitive\Collection;
|
||||||
|
use Lucent\Schema\CollectionSchema;
|
||||||
|
|
||||||
|
class GenerateCollectionSchema extends Command
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $signature = 'lucent:generate:collection {name}';
|
||||||
|
|
||||||
|
protected $description = 'Generate a lucent collection';
|
||||||
|
|
||||||
|
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$name = $this->argument('name');
|
||||||
|
$schema = new CollectionSchema(
|
||||||
|
name: $name,
|
||||||
|
label: $name,
|
||||||
|
visible: [],
|
||||||
|
groups: [],
|
||||||
|
fields: Collection::make(),
|
||||||
|
);
|
||||||
|
|
||||||
|
$json = json_encode($schema, JSON_PRETTY_PRINT);
|
||||||
|
$configDir = base_path(config('lucent.schemas_path'));
|
||||||
|
$schemaPath = $configDir . "/" . $name . '.json';
|
||||||
|
|
||||||
|
if(file_exists($schemaPath)){
|
||||||
|
$this->error("The schema file already exists.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
file_put_contents($schemaPath, $json);
|
||||||
|
$this->info("The schema file has been created.");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Lucent\Commands;
|
||||||
|
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Lucent\Primitive\Collection;
|
||||||
|
use Lucent\Schema\FilesSchema;
|
||||||
|
|
||||||
|
class GenerateFileSchema extends Command
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $signature = 'lucent:generate:file {name}';
|
||||||
|
|
||||||
|
protected $description = 'Generate a lucent file schema';
|
||||||
|
|
||||||
|
|
||||||
|
public function handle()
|
||||||
|
{
|
||||||
|
$name = $this->argument('name');
|
||||||
|
$schema = new FilesSchema(
|
||||||
|
name: $name,
|
||||||
|
label: $name,
|
||||||
|
fields: Collection::make(),
|
||||||
|
path: "",
|
||||||
|
groups: []
|
||||||
|
);
|
||||||
|
|
||||||
|
$json = json_encode($schema, JSON_PRETTY_PRINT);
|
||||||
|
$configDir = base_path(config('lucent.schemas_path'));
|
||||||
|
$schemaPath = $configDir . "/" . $name . '.json';
|
||||||
|
|
||||||
|
if (file_exists($schemaPath)) {
|
||||||
|
$this->error("The schema file already exists.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
file_put_contents($schemaPath, $json);
|
||||||
|
$this->info("The schema file has been created.");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -9,6 +9,8 @@ use Illuminate\Support\ServiceProvider;
|
|||||||
use Intervention\Image\ImageManager;
|
use Intervention\Image\ImageManager;
|
||||||
use Lucent\Channel\ChannelService;
|
use Lucent\Channel\ChannelService;
|
||||||
use Lucent\Commands\CompileSchemas;
|
use Lucent\Commands\CompileSchemas;
|
||||||
|
use Lucent\Commands\GenerateCollectionSchema;
|
||||||
|
use Lucent\Commands\GenerateFileSchema;
|
||||||
use Lucent\Commands\LiveLink;
|
use Lucent\Commands\LiveLink;
|
||||||
use Lucent\Commands\RebuildThumbnails;
|
use Lucent\Commands\RebuildThumbnails;
|
||||||
use Lucent\Commands\RemoveOrphanEdges;
|
use Lucent\Commands\RemoveOrphanEdges;
|
||||||
@@ -75,6 +77,8 @@ class LucentServiceProvider extends ServiceProvider
|
|||||||
LiveLink::class,
|
LiveLink::class,
|
||||||
RemoveOrphanEdges::class,
|
RemoveOrphanEdges::class,
|
||||||
SetupDatabase::class,
|
SetupDatabase::class,
|
||||||
|
GenerateCollectionSchema::class,
|
||||||
|
GenerateFileSchema::class,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user