I can't show all records!

Hello, I have a model where I manage all the system permissions but I cannot show all the records, in the case of this model it is not necessary that it belongs to a tenant or there is an ownershipRelationship, however the configuration requires me to have an owner How can I avoid this?

I had my model like this:


<?php

namespace App\Models;

use Filament\Panel;
use Illuminate\Contracts\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Collection;

class Permission extends Model 
{
    use HasFactory;

    protected $fillable = [
        'name',
    ];

    public function users(): BelongsToMany
    {
        return $this->belongsToMany(User::class);
    }

    public function owner(): HasMany
    {
        //return $this->hasMany(Permission::class, 'id');
        return $this->hasMany(Permission::class, 'id')->where('id', '<>', 0);
    }
}


later i try this:

<?php

namespace App\Models;

use Filament\Facades\Filament;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Permission extends Model 
{
    use HasFactory;

    protected $fillable = [
        'name',
    ];

    public function users(): BelongsToMany
    {
        return $this->belongsToMany(User::class);
    }

    public function owner()
    {
        //Filament::getTenant()->id;
        //return $this->hasMany(Permission::class, 'id');
        $permissions = Permission::where('id', '>=', 1)->get();
        //dd($permissions);
        return $permissions;
        //return $this->hasMany(Permission::class, 'id')->where('id', '>=', Filament::getTenant()->id);
    }
}
image.png
image.png
Was this page helpful?