@uwascan
@uwascan
FFilament
Created by BuddhaNature on 11/20/2023 in #❓┊help
Preventing the display of a related resource on a view or edit page.
You may override the getRelationManagers() method of the View or Edit page and return an empty array to disable the display
public function getRelationManagers(): array
{
return [];
}
public function getRelationManagers(): array
{
return [];
}
6 replies
FFilament
Created by Vishant on 10/4/2023 in #❓┊help
Rename create button
I cleared all caches to no avail
7 replies
FFilament
Created by zito on 10/5/2023 in #❓┊help
routing issue on first launch
I had this issue some time ago. Could not figure out why but it went away after a while. It happens when you click on buttons too. It takes more than one click to activate a button
5 replies
FFilament
Created by Yurii on 10/4/2023 in #❓┊help
Filament exception handling
Take a look at your Relation manager's base class and find out the method that handles saving the relationship. override this method in your sub class and handle the error there using Patrick's idea above. Let the documentation guide you.
5 replies
FFilament
Created by @uwascan on 9/21/2023 in #❓┊help
Selective Multi-tenancy
Here is what I did. Create a marker interface to Identify Models that are multitenant.
interface IMultiTenantModel
{

}
interface IMultiTenantModel
{

}
Create a new Base Class for your resources
abstract class AppBaseResource extends Resource
{
public static function getEloquentQuery(): Builder
{
$query = static::getModel()::query();

if ($tenant = Filament::getTenant()) {
if (app(static::getModel()) instanceof IMultiTenantModel) {
static::scopeEloquentQueryToTenant($query, $tenant);
}
}

return $query;
}
}
abstract class AppBaseResource extends Resource
{
public static function getEloquentQuery(): Builder
{
$query = static::getModel()::query();

if ($tenant = Filament::getTenant()) {
if (app(static::getModel()) instanceof IMultiTenantModel) {
static::scopeEloquentQueryToTenant($query, $tenant);
}
}

return $query;
}
}
You may create a base class for your Create Pages as shown below:
class AppCreateRecord extends Page
{
/**
* @param array<string, mixed> $data
*/
protected function handleRecordCreation(array $data): Model
{
$record = new ($this->getModel())($data);

if ($tenant = Filament::getTenant()) {
if (app(static::getModel()) instanceof IMultiTenantModel) {
return $this->associateRecordWithTenant($record, $tenant);
}
}

$record->save();

return $record;
}
}
class AppCreateRecord extends Page
{
/**
* @param array<string, mixed> $data
*/
protected function handleRecordCreation(array $data): Model
{
$record = new ($this->getModel())($data);

if ($tenant = Filament::getTenant()) {
if (app(static::getModel()) instanceof IMultiTenantModel) {
return $this->associateRecordWithTenant($record, $tenant);
}
}

$record->save();

return $record;
}
}
Make sure to extend the base classes above for any Resource that you add to a multitenant Panel. This will allow but multitenant Models and other models that are not multitenant to be used in all panels
17 replies
FFilament
Created by Vishant on 10/4/2023 in #❓┊help
Rename create button
I just publish the translation files and made some changes but nothings changes in the UI What could be wrong?
7 replies
FFilament
Created by Sesh on 9/22/2023 in #❓┊help
How to stop an action on certain conditions with ->before()
you may use halt() / $this->halt(). It depends on your context (page or static). you may google more about it
5 replies
FFilament
Created by @uwascan on 9/21/2023 in #❓┊help
Selective Multi-tenancy
Thank you for your responses. I actually found a nice way to solve the problem and I provided an answer to another related question. I will provide an update soon. Never be afraid to look under the hood!!!
17 replies
FFilament
Created by tuobaye. on 9/8/2023 in #❓┊help
Some resources do not require tenant scope queries ,how to skip
Try this: Create a Marker Interface as show below
namespace App\Contracts;

interface IMultiTenantModel
{

}
namespace App\Contracts;

interface IMultiTenantModel
{

}
create a Base Resource Class that all Your Filament Resource classes will extend as shown below:
namespace App\Resources\Base;

use App\Contracts\IMultiTenantModel;
use Filament\Facades\Filament;
use Filament\Resources\Resource;
use Illuminate\Database\Eloquent\Builder;

abstract class AppBaseResource extends Resource
{
public static function getEloquentQuery(): Builder
{
$query = static::getModel()::query();

if ($tenant = Filament::getTenant()) {
if (app(static::getModel()) instanceof IMultiTenantModel) {
static::scopeEloquentQueryToTenant($query, $tenant);
}
}

return $query;
}
}
namespace App\Resources\Base;

use App\Contracts\IMultiTenantModel;
use Filament\Facades\Filament;
use Filament\Resources\Resource;
use Illuminate\Database\Eloquent\Builder;

abstract class AppBaseResource extends Resource
{
public static function getEloquentQuery(): Builder
{
$query = static::getModel()::query();

if ($tenant = Filament::getTenant()) {
if (app(static::getModel()) instanceof IMultiTenantModel) {
static::scopeEloquentQueryToTenant($query, $tenant);
}
}

return $query;
}
}
Make sure all your Multitenant Models implements the
IMultiTenantModel
IMultiTenantModel
interface. Also make sure all your CreatePages extends from the class below:
namespace App\Resources\Base;

use Filament\Facades\Filament;
use Filament\Resources\Pages\Page;
use App\Contracts\IMultiTenantModel;
use Illuminate\Database\Eloquent\Model;

class AppCreateRecord extends Page
{
/**
* @param array<string, mixed> $data
*/
protected function handleRecordCreation(array $data): Model
{
$record = new ($this->getModel())($data);

if ($tenant = Filament::getTenant()) {
if (app(static::getModel()) instanceof IMultiTenantModel) {
return $this->associateRecordWithTenant($record, $tenant);
}
}

$record->save();

return $record;
}
}
namespace App\Resources\Base;

use Filament\Facades\Filament;
use Filament\Resources\Pages\Page;
use App\Contracts\IMultiTenantModel;
use Illuminate\Database\Eloquent\Model;

class AppCreateRecord extends Page
{
/**
* @param array<string, mixed> $data
*/
protected function handleRecordCreation(array $data): Model
{
$record = new ($this->getModel())($data);

if ($tenant = Filament::getTenant()) {
if (app(static::getModel()) instanceof IMultiTenantModel) {
return $this->associateRecordWithTenant($record, $tenant);
}
}

$record->save();

return $record;
}
}
You can put theses classes any where in your project that makes sense to you. I am in the process of testing this out myself.
3 replies
FFilament
Created by bwurtz999 on 6/1/2023 in #❓┊help
Notification over a Modal
I am having this issue with slideovers as well. I had to use Sweetalert as temporal fix.
6 replies