fixed errors in event and tenant resources
This commit is contained in:
@@ -38,6 +38,11 @@ class BlogPost extends Model
|
||||
'banner',
|
||||
'published_at',
|
||||
'is_published',
|
||||
'title',
|
||||
'content',
|
||||
'excerpt',
|
||||
'meta_title',
|
||||
'meta_description',
|
||||
'translations',
|
||||
];
|
||||
|
||||
@@ -69,7 +74,7 @@ class BlogPost extends Model
|
||||
$environment->addExtension(new TaskListExtension());
|
||||
|
||||
$converter = new MarkdownConverter($environment);
|
||||
return $converter->convert($markdown);
|
||||
return (string) $converter->convert($markdown);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -92,4 +97,4 @@ class BlogPost extends Model
|
||||
{
|
||||
return $this->belongsTo(BlogAuthor::class, 'blog_author_id');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ class Event extends Model
|
||||
protected $guarded = [];
|
||||
protected $casts = [
|
||||
'date' => 'datetime',
|
||||
'settings' => 'array',
|
||||
'is_active' => 'boolean',
|
||||
'name' => 'array',
|
||||
'description' => 'array',
|
||||
@@ -58,6 +57,11 @@ class Event extends Model
|
||||
return $this->belongsTo(EventPackage::class);
|
||||
}
|
||||
|
||||
public function eventPackages(): HasMany
|
||||
{
|
||||
return $this->hasMany(EventPackage::class);
|
||||
}
|
||||
|
||||
public function joinTokens(): HasMany
|
||||
{
|
||||
return $this->hasMany(EventJoinToken::class);
|
||||
@@ -85,4 +89,29 @@ class Event extends Model
|
||||
|
||||
return $this->eventPackage->canUploadPhoto();
|
||||
}
|
||||
|
||||
public function getSettingsAttribute($value): array
|
||||
{
|
||||
if (is_array($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (is_string($value) && $value !== '') {
|
||||
$decoded = json_decode($value, true);
|
||||
|
||||
return is_array($decoded) ? $decoded : [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
public function setSettingsAttribute($value): void
|
||||
{
|
||||
if (is_string($value)) {
|
||||
$decoded = json_decode($value, true);
|
||||
$value = is_array($decoded) ? $decoded : [];
|
||||
}
|
||||
|
||||
$this->attributes['settings'] = json_encode($value ?? []);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,13 +69,13 @@ class EventPackage extends Model
|
||||
public function getRemainingPhotosAttribute(): int
|
||||
{
|
||||
$max = $this->package->max_photos ?? 0;
|
||||
return max(0, $this->max_photos - $this->used_photos);
|
||||
return max(0, $max - $this->used_photos);
|
||||
}
|
||||
|
||||
public function getRemainingGuestsAttribute(): int
|
||||
{
|
||||
$max = $this->package->max_guests ?? 0;
|
||||
return max(0, $this->max_guests - $this->used_guests);
|
||||
return max(0, $max - $this->used_guests);
|
||||
}
|
||||
|
||||
protected static function boot()
|
||||
|
||||
Reference in New Issue
Block a user