Skip to content

Multitenancy Support #19

@marvoh

Description

@marvoh

Hello,

Thank you for your wonderful work. I am trying to integrate it into a multitenant set-up through Filament V3 where a Ledger would belong to a company.

I have extended the LedgerName model to add the relationship to the company as follows:

<?php

namespace App\Models\Ledger;

use Abivia\Ledger\Models\LedgerName;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Wallo\FilamentCompanies\FilamentCompanies;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Ledger extends LedgerName  {

    use SoftDeletes;
    protected $table = 'ledger_names';
    public function company(): BelongsTo
    {
        return $this->belongsTo(FilamentCompanies::companyModel(), 'company_id');
    }

    public function createdBy(): BelongsTo
    {
        return $this->belongsTo(FilamentCompanies::userModel(), 'created_by');
    }

    public function updatedBy(): BelongsTo
    {
        return $this->belongsTo(FilamentCompanies::userModel(), 'updated_by');
    }
}

I am looking for a best practise recommendation being new to Laravel while also trying to avoid redoing most of the work which the API already has done when persisting the relationships such as currency, accounts etc.

Best,
N

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions