v1.0.0 initial release

This commit is contained in:
samy
2025-06-13 10:48:20 -10:00
commit 0c8f70bca5
3333 changed files with 189946 additions and 0 deletions
@@ -0,0 +1,53 @@
<?php
namespace Eops\StarterKit\View\Components\Form\Concerns;
use Illuminate\Support\Str;
use Illuminate\View\ComponentAttributeBag;
use Illuminate\View\View;
trait InteractsWithFormField
{
public string $id;
public ?string $resolvedValue;
public string $inputClasses;
public string $view;
public function initFormField(
string $name,
?string $label = null,
?string $placeholder = null,
?string $help = null,
bool $required = false,
bool $disabled = false,
bool $readonly = false,
string $gridLayout = '',
mixed $value = null,
mixed $model = null,
?string $prefix = null,
string $baseClass = '',
): void {
$this->id = Str::slug($prefix ? "{$prefix}-{$name}" : $name);
$modelValue = is_object($model) && isset($model->{$name}) ? $model->{$name} : null;
$this->resolvedValue = old($name, $value ?? $modelValue);
$this->inputClasses = $baseClass;
}
public function render(): View
{
if (session('errors')?->has($this->name)) {
$this->inputClasses .= ' input-error';
}
if($this->readonly)
{
$this->inputClasses .= ' pointer-events-none opacity-50';
}
return view($this->view);
}
}