sveltel fixes

This commit is contained in:
2023-10-06 18:47:50 +03:00
parent 9bbe5ee9b4
commit 0eaf410090
28 changed files with 361 additions and 218 deletions
+12 -12
View File
@@ -346,18 +346,18 @@ class RecordController extends Controller
);
return ok();
}
//
// public function delete(Request $request)
// {
// $ids = $request->input("ids");
//
// try {
// $this->recordService->deleteMany($ids);
// } catch (Throwable $th) {
// return fail($th);
// }
// return ok();
// }
public function delete(Request $request)
{
$ids = $request->input("ids");
try {
$this->recordService->deleteMany($ids);
} catch (Throwable $th) {
return fail($th);
}
return ok();
}
//
// public function rollback(Request $request)
// {
+4 -2
View File
@@ -6,7 +6,9 @@ use Illuminate\Support\Facades\DB;
class RecordRepo
{
public function __construct()
{
}
public static function create(Record $record): void
{
@@ -36,7 +38,7 @@ class RecordRepo
/**
* @param string[] $ids
*/
public static function deleteMany(
public function deleteMany(
array $ids,
): void
{
+3 -2
View File
@@ -27,7 +27,8 @@ readonly class RecordService
private ChannelService $channelService,
private Validator $recordValidator,
private Query $query,
private InputFormatter $inputFormatter
private InputFormatter $inputFormatter,
private RecordRepo $recordRepo
)
{
}
@@ -213,7 +214,7 @@ readonly class RecordService
array $recordsIds,
): void
{
RecordRepo::deleteMany($recordsIds);
$this->recordRepo->deleteMany($recordsIds);
}
+49
View File
@@ -0,0 +1,49 @@
<?php
namespace Lucent\Schema\Ui;
use Illuminate\Support\Str;
use Lucent\Schema\FieldInfo;
use Lucent\Schema\FieldInterface;
use Lucent\Schema\FieldType;
use Lucent\Schema\Nullable;
use Lucent\Schema\Validator\RequiredInterface;
class Slug implements FieldInterface, RequiredInterface
{
public FieldInfo $info;
public function __construct(
public string $name,
public string $label,
public bool $required = false,
public bool $nullable = false,
public ?int $min = null,
public ?int $max = null,
public string $default = "",
public bool $readonly = false,
public string $source = "",
public string $group = "",
)
{
$this->info = new FieldInfo("slug", "Slug", FieldType::STRING);
}
public function format(array $input, array $output): array
{
$value = $input[$this->name] ?? null;
if(empty($value)){
$value = Str::slug($input[$this->source]);
}
$output[$this->name] = (new Nullable($this->nullable, $value, ""))->value();
return $output;
}
public function failRequired(mixed $value): bool
{
return empty(trim($value));
}
}
+1
View File
@@ -24,6 +24,7 @@ class Text implements FieldInterface, RequiredInterface
public string $optionsFrom = "",
public string $optionsField = "",
public bool $optionsSuggest = false,
public ?array $selectOptions = null,
public string $group = "",
)
{