Support oft parent groups
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Models;
|
||||
|
||||
use App\Scopes\CommonModel;
|
||||
use App\Support\Text;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* @property string $slug
|
||||
@@ -35,6 +36,7 @@ use App\Support\Text;
|
||||
* @property string|null $tax_exemption_reason
|
||||
* @property string|null $tax_exemption_note
|
||||
* @property string $vat_pricing_mode
|
||||
* @property int $parent_group_id
|
||||
*/
|
||||
class Tenant extends CommonModel
|
||||
{
|
||||
@@ -46,9 +48,15 @@ class Tenant extends CommonModel
|
||||
{
|
||||
static::creating(static function (self $tenant): void {
|
||||
$tenant->invoice_prefix ??= strtoupper((string) $tenant->slug);
|
||||
// Die Parent Group ist Pflicht; ohne Angabe landet der Mandant bei „Ohne Zuordnung".
|
||||
$tenant->parent_group_id ??= ParentGroup::fallback()->id;
|
||||
});
|
||||
}
|
||||
|
||||
public function parentGroup() : BelongsTo {
|
||||
return $this->belongsTo(ParentGroup::class, 'parent_group_id');
|
||||
}
|
||||
|
||||
public static function getTempDirectory() : string {
|
||||
return currentTenant()->slug . '/temp-data/';
|
||||
}
|
||||
@@ -95,6 +103,7 @@ class Tenant extends CommonModel
|
||||
'tax_number',
|
||||
'vat_id',
|
||||
'invoice_prefix',
|
||||
'parent_group_id',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
|
||||
Reference in New Issue
Block a user