-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
140 BE taxonomy terms create edit and delete pages #179
140 BE taxonomy terms create edit and delete pages #179
Conversation
foreach (json_decode($taxonomy->properties, true) as $property) { | ||
$metadataKey = "metadata.{$property['code']}"; | ||
|
||
switch ($property['data_type']) { | ||
case 'string': | ||
$request->validate([$metadataKey => 'nullable|string']); | ||
break; | ||
case 'integer': | ||
$request->validate([$metadataKey => 'nullable|integer']); | ||
break; | ||
case 'float': | ||
$request->validate([$metadataKey => 'nullable|numeric']); | ||
break; | ||
case 'boolean': | ||
$request->validate([$metadataKey => 'nullable|boolean']); | ||
break; | ||
case 'date': | ||
$request->validate([$metadataKey => 'nullable|date']); | ||
break; | ||
case 'datetime': | ||
$request->validate([$metadataKey => 'nullable|date']); | ||
break; | ||
case 'url': | ||
$request->validate([$metadataKey => 'nullable|url']); | ||
break; | ||
case 'image': | ||
|
||
if ($request->hasFile("metadata.{$property['code']}")) { | ||
$imagePath = $this->uploadThumb(null, $request->file("metadata.{$property['code']}"), "taxonomy_terms"); | ||
$value = $imagePath; | ||
} else { | ||
$value = null; | ||
} | ||
break; | ||
|
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can write custom validators in Laravel, let's do it later under optimizations
@switch($property['data_type']) | ||
@case('string') | ||
{!! Form::text("metadata[{$property['code']}]", old("metadata.{$property['code']}", $term->getMetadata($property['code'])), ['class' => 'form-control']) !!} | ||
@break | ||
@case('integer') | ||
{!! Form::number("metadata[{$property['code']}]", old("metadata.{$property['code']}", $term->getMetadata($property['code'])), ['class' => 'form-control', 'step' => '1']) !!} | ||
@break | ||
@case('float') | ||
{!! Form::number("metadata[{$property['code']}]", old("metadata.{$property['code']}", $term->getMetadata($property['code'])), ['class' => 'form-control', 'step' => 'any']) !!} | ||
@break | ||
@case('boolean') | ||
<div class="form-check"> | ||
{!! Form::checkbox("metadata[{$property['code']}]", 1, old("metadata.{$property['code']}", $term->getMetadata($property['code']) == 1 ? true : false), ['class' => 'form-check-input']) !!} | ||
</div> | ||
@break | ||
@case('date') | ||
{!! Form::date("metadata[{$property['code']}]", old("metadata.{$property['code']}", $term->getMetadata($property['code'])), ['class' => 'form-control']) !!} | ||
@break | ||
@case('datetime') | ||
{!! Form::datetimeLocal("metadata[{$property['code']}]", old("metadata.{$property['code']}", $term->getMetadata($property['code'])), ['class' => 'form-control']) !!} | ||
@break | ||
@case('url') | ||
{!! Form::url("metadata[{$property['code']}]", old("metadata.{$property['code']}", $term->getMetadata($property['code'])), ['class' => 'form-control']) !!} | ||
@break | ||
@case('image') | ||
{!! Form::file("metadata[{$property['code']}]", ['class' => 'form-control']) !!} | ||
@if($term->getMetadata($property['code'])) | ||
<small>Current: {{ $term->getMetadata($property['code']) }}</small> | ||
@endif | ||
@break | ||
@default | ||
{!! Form::text("metadata[{$property['code']}]", old("metadata.{$property['code']}", $term->getMetadata($property['code'])), ['class' => 'form-control']) !!} | ||
@endswitch | ||
</div> | ||
</div> | ||
@endforeach |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part also can be moved into a Livewire component. Let's do it later
No description provided.