Generische iCal-Kanäle mit Bestandsklärung und sicheren Exporten bereitstellen
Deploy FeWo mit PipelineManager / deploy (push) Successful in 2m33s
Deploy FeWo mit PipelineManager / deploy (push) Successful in 2m33s
This commit is contained in:
1 parent
6fe5bbc6e3
commit
783068501c
42 files changed
+2646
-248
No files matched your search
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Concerns;
|
||||
|
||||
use App\Models\Channel;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
trait HasChannelProvenance
|
||||
{
|
||||
public static function bootHasChannelProvenance(): void
|
||||
{
|
||||
static::saving(function (Model $model): void {
|
||||
foreach (['channel_id', 'import_channel_id', 'origin_channel_id'] as $field) {
|
||||
$id = $model->getAttribute($field);
|
||||
if ($id !== null && ! Channel::withoutGlobalScope('tenant')->whereKey($id)->where('property_id', $model->property_id)->exists()) {
|
||||
throw ValidationException::withMessages([$field => 'Der Kanal muss zur selben Wohnung gehören.']);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user