27-05-2026 DHL Modul v2.1 / Optimierung tracking

This commit is contained in:
Kevin Adametz 2026-05-27 18:51:23 +02:00
parent 036595be94
commit 2bdc9ada3c
33 changed files with 2367 additions and 2086 deletions

View file

@ -25,7 +25,7 @@ use Illuminate\Database\Eloquent\Model;
* @property string|null $type
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @package App\Models
*
* @method static \Illuminate\Database\Eloquent\Builder|Setting newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Setting newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|Setting query()
@ -42,31 +42,32 @@ use Illuminate\Database\Eloquent\Model;
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereText($value)
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereType($value)
* @method static \Illuminate\Database\Eloquent\Builder|Setting whereUpdatedAt($value)
*
* @mixin \Eloquent
*/
class Setting extends Model
{
protected $table = 'settings';
protected $table = 'settings';
protected $casts = [
'referenz' => 'int',
'status' => 'int',
protected $casts = [
'referenz' => 'int',
'status' => 'int',
'int' => 'int',
'object' => 'array'
];
'object' => 'array',
];
protected $fillable = [
'identifier',
'slug',
'referenz',
'action',
'object',
'full_text',
protected $fillable = [
'identifier',
'slug',
'referenz',
'action',
'object',
'full_text',
'text',
'int',
'status',
'type'
];
'type',
];
protected static $types = [
'object' => 'Object',
@ -75,21 +76,22 @@ class Setting extends Model
'int' => 'Zahl',
'bool' => 'Bool',
];
public function sluggable() : array
public function sluggable(): array
{
return [
'slug' => [
'source' => 'name'
]
'source' => 'name',
],
];
}
public static function getContentBySlug($slug){
public static function getContentBySlug($slug)
{
$content = self::whereSlug(trim($slug))->first();
if($content){
switch ($content->type){
if ($content) {
switch ($content->type) {
case 'object':
return $content->object;
break;
@ -107,28 +109,30 @@ class Setting extends Model
break;
}
}
return false;
}
public static function setContentBySlug($slug, $value, $type = "full_text"){
public static function setContentBySlug($slug, $value, $type = 'full_text')
{
$content = self::whereSlug(trim($slug))->first();
if(!$content) {
if (! $content) {
$content = self::create([
'slug' => $slug,
'type' => $type,
]);
}
$content->type = $type;
switch ($content->type){
switch ($content->type) {
case 'object':
$content->object = $value ? $value : null;;
$content->object = is_array($value) ? $value : ($value ?: null);
break;
case 'full_text':
$content->full_text = $value ? $value : null;;
$content->full_text = $value ? $value : null;
break;
case 'text':
$content->text = $value ? $value : null;;
$content->text = $value ? $value : null;
break;
case 'int':
$content->int = (int) $value;
@ -139,6 +143,7 @@ class Setting extends Model
}
$content->save();
return $content;
}
}