DHL Modul v0.5 Shipping Label ok

This commit is contained in:
Kevin Adametz 2025-08-22 18:18:26 +02:00
parent 480fdc65ed
commit 8fdaa0ba1d
122 changed files with 17938 additions and 2239 deletions

View file

@ -0,0 +1,15 @@
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.yml]
indent_size = 2

View file

@ -0,0 +1 @@
/vendor

View file

@ -0,0 +1,23 @@
# Contributing to laravel-collective-spatie-html-parser
Thank you for considering contributing to this project! Your contributions help maintain and improve this Laravel compatibility layer, ensuring a smooth transition between the obsolete laravel-collective library to the maintained laravel-spatie-html. This library also helps to that old proyects to be updated to the new versions of Laravel.
## How to Contribute
### 1. Submitting a Pull Request (PR)
- Always create your PR against the `develop` branch.
- Use a **descriptive name** and provide a **clear description** of what the PR does (bug fix, new feature, improvement, etc.).
- Once reviewed and approved, I will merge it into `master` and handle the deployment.
### 2. Reporting Issues
If you encounter a bug but are unable to fix it yourself, you can still help by reporting it:
- Open a new **Issue** in the repository.
- Provide a **detailed description** of the issue.
- Include **steps to reproduce the problem** so others can verify and fix it.
## Code Style Guidelines
- Follow Laravels coding standards and best practices.
- Keep the code clean and well-documented.
- Ensure that new features or fixes do not break existing functionality.
Thank you for your support and contributions!

View file

@ -0,0 +1,9 @@
The MIT License (MIT)
Copyright © 2024 Christian Albán
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -0,0 +1,66 @@
# Laravel Collective to Spatie Laravel HTML Adapter
This package serves as an adapter to help projects that depend on the obsolete `laravel-collective/html` library. It provides an interface that uses the same syntax as the `Form` class of `laravel-collective/html` to create HTML elements. Under the hood, it utilizes the `spatie/laravel-html` library, which is actively maintained, to generate the HTML elements. This allows projects to update to newer Laravel versions without changing the HTML creation syntax.
## Features
- Zero configuration needed, works out of the box.
- Uses the same syntax as `laravel-collective/html`.
- Leverages the actively maintained `spatie/laravel-html` library.
## Available Methods
The following methods can be used and are located in the `src/FormAdapter` directory:
- `checkbox($name, $value = 1, $checked = null, $options = [])`
- `open(array $options = [])`
- `label($name, $value = null, $options = [], $escape_html = true)`
- `text($name, $value = null, $options = [])`
- `password($name, $options = [])`
- `select($name, $list = [], $selected = null, array $selectAttributes = [], array $optionsAttributes = [], array $optgroupsAttributes = [])`
- `radio($name, $value = null, $checked = null, $options = [])`
- `submit($value = null, $options = [])`
- `close()`
- `input($type, $name, $value = null, $options = [])`
- `search($name, $value = null, $options = [])`
- `model($model, array $options = [])`
- `hidden($name, $value = null, $options = [])`
- `email($name, $value = null, $options = [])`
- `tel($name, $value = null, $options = [])`
- `number($name, $value = null, $options = [])`
- `date($name, $value = null, $options = [])`
- `datetime($name, $value = null, $options = [])`
- `datetimeLocal($name, $value = null, $options = [])`
- `time($name, $value = null, $options = [])`
- `url($name, $value = null, $options = [])`
- `file($name, $options = [])`
- `textarea($name, $value = null, $options = [])`
- `reset($value, $attributes = [])`
- `image($url, $name = null, $attributes = [])`
- `color($name, $value = null, $options = [])`
- `button($value = null, $options = [])`
## Installation
To install the package, use composer:
```sh
composer require alban/laravel-collective-spatie-html-parser
```
## Usage
The methods listed above can be used in the same way as you would use the Form class from laravel-collective. Here is an example in a Blade template:
```php
{{-- Using the FormAdapter class in a Blade template --}}
{!! Form::text('relationship', $item->client->agent_relationship, ['required', 'class' => 'form-control input-sm']) !!}
```
For more examples, please refer to the source code in the `src/FormAdapter.php` class file.
## License
This package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
## Contributing
You are welcome to contribute to this project. Please refer to the [contributing guidelines](CONTRIBUTING.md) for more information.

View file

@ -0,0 +1,39 @@
{
"name": "alban/laravel-collective-spatie-html-parser",
"description": "Adapter class that allows use spatie/laravel-html for old projects that were using the abanondated laravelcollective/html package, and allow to update to new versions of laravel",
"type": "library",
"require": {
"php": "^8.3 | ^8.2 | ^8.0 | ^7.4",
"spatie/laravel-html": "^3.12",
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0"
},
"license": "MIT",
"autoload": {
"psr-4": {
"Alban\\LaravelCollectiveSpatieHtmlParser\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"Alban\\LaravelCollectiveSpatieHtmlParser\\ServiceProvider"
],
"aliases": {
"Form": "Alban\\LaravelCollectiveSpatieHtmlParser\\FormFacade"
}
}
},
"authors": [
{
"name": "Christian Albán",
"email": "christianalbanctdb1d@gmail.com"
}
],
"minimum-stability": "stable",
"config": {
"allow-plugins": {
"kylekatarnls/update-helper": true
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,218 @@
<?php
namespace Alban\LaravelCollectiveSpatieHtmlParser;
use Alban\LaravelCollectiveSpatieHtmlParser\Traits\AttributesUtils;
class FormAdapter
{
use AttributesUtils;
public function checkbox($name, $value = 1, $checked = null, $options = [])
{
$element = \Html::checkbox($name, $checked, $value);
return $this->mergeOptions($element, $options);
}
public function open(array $options = [])
{
$method = array_key_exists('method', $options) ? $options['method'] : 'POST';
$route = array_key_exists('route', $options) ? $options['route'] : '';
$files = array_key_exists('files', $options) ? $options['files'] : false;
unset($options['method'], $options['route'], $options['files']);
$form = \Html::getFacadeRoot();
if (is_array($route) && count($route)) {
$action = array_shift($route);
$form = $form->form($method, route($action, $route));
} elseif ($route != null && $route != [] && $route != '') {
$form = $form->form($method, route($route));
} else {
$form = $form->form($method);
}
if ($files) {
$form = $form->acceptsFiles();
}
return $this->mergeOptions($form, $options)->open();
}
public function label($name, $value = null, $options = [], $escape_html = true)
{
$element = \Html::label($value, $name);
return $this->mergeOptions($element, $options);
}
public function text($name, $value = null, $options = [])
{
$element = \Html::text($name, $value);
return $this->mergeOptions($element, $options);
}
public function password($name, $options = [])
{
$element = \Html::password($name);
return $this->mergeOptions($element, $options);
}
public function select(
$name,
$list = [],
$selected = null,
array $selectAttributes = [],
array $optionsAttributes = [],
array $optgroupsAttributes = []
) {
if (isset($selectAttributes['multiple']) || in_array('multiple', $selectAttributes)) {
$element = \Html::select($name, $list, $selected)->multiple();
} else {
$element = \Html::select($name, $list, $selected);
}
// $element = \Html::select($name, $list, $selected);
return $this->mergeOptions($element, $selectAttributes);
}
public function radio($name, $value = null, $checked = null, $options = [])
{
$element = \Html::radio($name, $checked, $value);
return $this->mergeOptions($element, $options);
}
public function submit($value = null, $options = [])
{
$element = \Html::submit($value);
return $this->mergeOptions($element, $options);
}
public function close()
{
\Html::endModel();
return \Html::form()->close();
}
public function input($type, $name, $value = null, $options = [])
{
$element = \Html::input($type, $name, $value);
return $this->mergeOptions($element, $options);
}
public function search($name, $value = null, $options = [])
{
return $this->input('search', $name, $value, $options);
}
public function model($model, array $options = [])
{
\Html::model($model);
return $this->open($options);
}
public function hidden($name, $value = null, $options = [])
{
$element = \Html::hidden($name, $value);
return $this->mergeOptions($element, $options);
}
public function email($name, $value = null, $options = [])
{
$element = \Html::email($name, $value);
return $this->mergeOptions($element, $options);
}
public function tel($name, $value = null, $options = [])
{
$element = \Html::tel($name, $value);
return $this->mergeOptions($element, $options);
}
public function number($name, $value = null, $options = [])
{
return $this->input('number', $name, $value, $options);
}
public function date($name, $value = null, $options = [])
{
$element = \Html::date($name, $value);
return $this->mergeOptions($element, $options);
}
public function datetime($name, $value = null, $options = [])
{
return $this->input('datetime', $name, $value, $options);
}
public function datetimeLocal($name, $value = null, $options = [])
{
return $this->input('datetime-local', $name, $value, $options);
}
public function time($name, $value = null, $options = [])
{
$element = \Html::time($name, $value);
return $this->mergeOptions($element, $options);
}
public function url($name, $value = null, $options = [])
{
return $this->input('url', $name, $value, $options);
}
public function file($name, $options = [])
{
$element = \Html::file($name);
return $this->mergeOptions($element, $options);
}
public function textarea($name, $value = null, $options = [])
{
$element = \Html::textarea($name, $value);
return $this->mergeOptions($element, $options);
}
public function reset($value, $attributes = [])
{
$element = \Html::reset($value);
return $this->mergeOptions($element, $attributes);
}
public function image($url, $name = null, $attributes = [])
{
$element = \Html::img($url, $name);
return $this->mergeOptions($element, $attributes);
}
public function color($name, $value = null, $options = [])
{
return $this->input('color', $name, $value, $options);
}
public function button($value = null, $options = [])
{
$element = \Html::button($value);
return $this->mergeOptions($element, $options);
}
}

View file

@ -0,0 +1,22 @@
<?php
namespace Alban\LaravelCollectiveSpatieHtmlParser;
use Illuminate\Support\Facades\Facade;
/**
* @see \Collective\Html\HtmlBuilder
*/
class FormFacade extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'form';
}
}

View file

@ -0,0 +1,7 @@
<?php
namespace Alban\LaravelCollectiveSpatieHtmlParser;
use Spatie\Html\Html;
class HtmlAdapter extends Html {}

View file

@ -0,0 +1,18 @@
<?php
namespace Alban\LaravelCollectiveSpatieHtmlParser;
use Illuminate\Support\Facades\Facade;
class HtmlFacade extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor(): string
{
return 'html';
}
}

View file

@ -0,0 +1,46 @@
<?php
namespace Alban\LaravelCollectiveSpatieHtmlParser;
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
class ServiceProvider extends BaseServiceProvider
{
/**
* Register bindings in the container.
*
* @return void
*/
public function register()
{
$this->registerFormAdpater();
$this->registerHtmlAdapter();
$this->app->alias('form', FormAdapter::class);
$this->app->alias('html', HtmlAdapter::class);
}
/**
* Register the HTML adapter instance.
*
* @return void
*/
protected function registerFormAdpater()
{
$this->app->singleton('form', function () {
return new FormAdapter();
});
}
/**
* Register the HTML adapter instance.
*
* @return void
*/
protected function registerHtmlAdapter()
{
$this->app->singleton('html', function () {
return new HtmlAdapter();
});
}
}

View file

@ -0,0 +1,35 @@
<?php
namespace Alban\LaravelCollectiveSpatieHtmlParser\Traits;
trait AttributesUtils
{
public function mergeOptions($element, $options = [])
{
$newElement = $element;
if (isset($options['class'])) {
$newElement = $newElement->addClass($options['class']);
unset($options['class']);
}
if (isset($options['placeholder'])) {
$newElement = $newElement->placeholder($options['placeholder']);
unset($options['placeholder']);
}
foreach ($options as $key => $value) {
if (!$value) {
continue;
}
if (is_numeric($key)) {
$newElement = $newElement->attribute($value, '');
continue;
}
$newElement = $newElement->attribute($key, $value);
}
return $newElement;
}
}