Skip to content
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

Merged

Conversation

kusaljayawardhana
Copy link
Contributor

No description provided.

Comment on lines +53 to +89
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;

}
}
Copy link
Member

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

Comment on lines +86 to +121
@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
Copy link
Member

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

@NuwanJ NuwanJ linked an issue Oct 16, 2024 that may be closed by this pull request
@NuwanJ NuwanJ merged commit ff2e611 into taxonomy-integration Oct 16, 2024
1 check passed
@NuwanJ NuwanJ deleted the 140-be-taxonomy-terms-create-edit-and-delete-pages branch October 18, 2024 05:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BE] Taxonomy terms create, edit and delete pages
3 participants