permissions
This commit is contained in:
@@ -4,6 +4,9 @@ namespace Lucent\Commands;
|
||||
|
||||
use DirectoryIterator;
|
||||
use Illuminate\Console\Command;
|
||||
use Lucent\Schema\Schema;
|
||||
use Lucent\Schema\SchemaService;
|
||||
use Lucent\Schema\Type;
|
||||
|
||||
class CompileSchemas extends Command
|
||||
{
|
||||
@@ -13,7 +16,9 @@ class CompileSchemas extends Command
|
||||
protected $description = 'Compiles schemas';
|
||||
|
||||
|
||||
public function __construct()
|
||||
public function __construct(
|
||||
public SchemaService $schemaService
|
||||
)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
@@ -39,13 +44,28 @@ class CompileSchemas extends Command
|
||||
|
||||
}
|
||||
|
||||
$schemas = collect($schemas)->sortBy("label")->values()->toArray();
|
||||
$schemas = collect($schemas)->sortBy("label")->values();
|
||||
$roles = $schemas
|
||||
->map([$this->schemaService, 'fromArray'])
|
||||
->whereIn("type", [Type::COLLECTION, Type::FILES])
|
||||
->reduce(fn($carry, Schema $schema) => array_merge(
|
||||
$carry,
|
||||
$schema->read,
|
||||
$schema->write,
|
||||
config("lucent.canInvite"),
|
||||
config("lucent.canBuild"),
|
||||
), []);
|
||||
|
||||
if(!file_exists(storage_path("lucent"))){
|
||||
$json = [
|
||||
"schemas" => $schemas->toArray(),
|
||||
"roles" => collect($roles)->push("admin")->push("removed")->unique()->values()->toArray()
|
||||
];
|
||||
|
||||
if (!file_exists(storage_path("lucent"))) {
|
||||
mkdir(storage_path("lucent"));
|
||||
}
|
||||
|
||||
file_put_contents(schemas_path(), json_encode($schemas));
|
||||
file_put_contents(schemas_path(), json_encode($json));
|
||||
|
||||
$this->info("Lucent Schemas were updated");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user