Skip to content

Commit

Permalink
Tiding up
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesdordoy committed Nov 3, 2024
1 parent feda8b2 commit 8f0d356
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Actions/Elements/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Illuminate\Validation\ValidationException;
use JamesDordoy\HTMLable\Models\Document;
use JamesDordoy\HTMLable\Models\Element;
use JamesDordoy\HTMLable\Rules\Documents\CreateElement;
use JamesDordoy\HTMLable\Rules\Elements\CreateElement;

class Create
{
Expand Down
7 changes: 2 additions & 5 deletions src/Actions/Values/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Validation\ValidationException;
use JamesDordoy\HTMLable\Models\Element;
use JamesDordoy\HTMLable\Models\Value;
use JamesDordoy\HTMLable\Rules\Values\CreateValue;

class Create
{
Expand All @@ -24,11 +25,7 @@ public function __invoke(string $key, string $value, Element $element, bool $val

protected function validate(array $data): array
{
$validator = Validator::make($data, [
'key' => 'required',
'value' => 'required|nullable',
'element_id' => 'required',
]);
$validator = Validator::make($data, app(CreateValue::class)());

if ($validator->fails()) {
throw new ValidationException($validator);
Expand Down
3 changes: 1 addition & 2 deletions src/Http/Resources/Documents/DocumentResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ class DocumentResource extends JsonResource
{
public function toArray(Request $request): array
{
$document = $this->resource;
// $document = $this->resource;

return [
...parent::toArray($request),
'rendered' => (string) $document->render(),
'elements' => $this->elements,

Check failure on line 16 in src/Http/Resources/Documents/DocumentResource.php

View workflow job for this annotation

GitHub Actions / phpstan

Access to an undefined property JamesDordoy\HTMLable\Http\Resources\Documents\DocumentResource::$elements.
];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Rules/Elements/CreateElement.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace JamesDordoy\HTMLable\Rules\Documents;
namespace JamesDordoy\HTMLable\Rules\Elements;

class CreateElement
{
Expand Down
4 changes: 2 additions & 2 deletions src/Rules/Values/CreateValue.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace JamesDordoy\HTMLable\Rules\Documents;
namespace JamesDordoy\HTMLable\Rules\Values;

class CreateElement
class CreateValue
{
public function __invoke(array $additionalRules = []): array
{
Expand Down

0 comments on commit 8f0d356

Please sign in to comment.