Skip to content

Commit

Permalink
Add more overrules
Browse files Browse the repository at this point in the history
  • Loading branch information
francoism90 committed Apr 16, 2024
1 parent a6f130c commit 5693f4b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
11 changes: 8 additions & 3 deletions src/Forms/Concerns/WithSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait WithSession

public function restore(): void
{
if (! static::$store || ! $this->hasStore()) {
if (! $this->useStore() || ! $this->hasStore()) {
return;
}

Expand All @@ -24,7 +24,7 @@ public function restore(): void

public function store(): void
{
if (! static::$store || ! $this->storeWhen()) {
if (! $this->storeWhen()) {
return;
}

Expand All @@ -39,6 +39,11 @@ public function forget(): void
session()->forget($this->storeId());
}

protected function useStore(): bool
{
return static::$store;
}

protected function getStore(): array
{
return unserialize(session()->get($this->storeId(), []));
Expand All @@ -51,7 +56,7 @@ protected function hasStore(): bool

protected function storeWhen(): bool
{
return true;
return $this->useStore();
}

protected function storeWith(): array
Expand Down
7 changes: 6 additions & 1 deletion src/Forms/Concerns/WithValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ trait WithValidation

public function check(): void
{
if (! static::$recoverable) {
if (! static::isRecoverable()) {
$this->validate();

return;
Expand All @@ -19,4 +19,9 @@ public function check(): void
fn () => $this->reset(),
);
}

protected static function isRecoverable(): bool
{
return static::$recoverable;
}
}
4 changes: 1 addition & 3 deletions src/Models/Forms/CreateForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ protected function set(string $class): void

protected function handle(): void
{
app(static::$model)::create(
$this->all()
);
app(static::$model)::create($this->all());
}
}
2 changes: 1 addition & 1 deletion src/Views/Concerns/WithLivewire.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function wireModel(): ?string
return $this->attributes->whereStartsWith('wire:model')->first();
}

public function uuid(): UuidInterface
public function uuid(): UuidInterface|string
{
return once(fn (): UuidInterface => Str::uuid());
}
Expand Down

0 comments on commit 5693f4b

Please sign in to comment.