Simon
Simon
FFilament
Created by Simon on 7/18/2024 in #❓┊help
Filament\Tables\Table could not be converted to string
I figured it out! For some reason this app is setting this in the AppServiceProvider - I guess for some backwards-compatibility:
\Illuminate\Support\Facades\Blade::setEchoFormat('%s');
\Illuminate\Support\Facades\Blade::setEchoFormat('%s');
I needed to wrap it like this:
if (! request()->is(Filament::getCurrentPanel()->getPath().'*', 'livewire/update', 'livewire/livewire.js')) {
Blade::setEchoFormat('%s');
}
if (! request()->is(Filament::getCurrentPanel()->getPath().'*', 'livewire/update', 'livewire/livewire.js')) {
Blade::setEchoFormat('%s');
}
7 replies
FFilament
Created by Simon on 7/18/2024 in #❓┊help
Filament\Tables\Table could not be converted to string
this is all pretty vanilla at this stage... weird to see an error
7 replies
FFilament
Created by Simon on 7/18/2024 in #❓┊help
Filament\Tables\Table could not be converted to string
@toeknee
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Company extends Model
{
protected $primaryKey = 'company_id';

public function leaders(): HasMany
{
return $this->hasMany(Leader::class);
}
}
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Company extends Model
{
protected $primaryKey = 'company_id';

public function leaders(): HasMany
{
return $this->hasMany(Leader::class);
}
}
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Leader extends Model
{
public function company(): BelongsTo
{
return $this->belongsTo(Company::class);
}
}
namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Leader extends Model
{
public function company(): BelongsTo
{
return $this->belongsTo(Company::class);
}
}
namespace App\Filament\Resources;

use App\Filament\Resources\CompanyResource\RelationManagers;
use App\Models\Company;
use Filament\Resources\Resource;

class CompanyResource extends Resource
{
protected static ?string $model = Company::class;

public static function getRelations(): array
{
return [
RelationManagers\LeadersRelationManager::class,
];
}
}
namespace App\Filament\Resources;

use App\Filament\Resources\CompanyResource\RelationManagers;
use App\Models\Company;
use Filament\Resources\Resource;

class CompanyResource extends Resource
{
protected static ?string $model = Company::class;

public static function getRelations(): array
{
return [
RelationManagers\LeadersRelationManager::class,
];
}
}
namespace App\Filament\Resources\CompanyResource\RelationManagers;

use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;

class LeadersRelationManager extends RelationManager
{
protected static string $relationship = 'leaders';

public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('leader_name')
->required()
->maxLength(255),
]);
}

public function table(Table $table): Table
{
return $table
->recordTitleAttribute('leader_name')
->columns([
Tables\Columns\TextColumn::make('leader_name'),
])
->filters([
//
])
->headerActions([
Tables\Actions\CreateAction::make(),
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}
}
namespace App\Filament\Resources\CompanyResource\RelationManagers;

use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;

class LeadersRelationManager extends RelationManager
{
protected static string $relationship = 'leaders';

public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('leader_name')
->required()
->maxLength(255),
]);
}

public function table(Table $table): Table
{
return $table
->recordTitleAttribute('leader_name')
->columns([
Tables\Columns\TextColumn::make('leader_name'),
])
->filters([
//
])
->headerActions([
Tables\Actions\CreateAction::make(),
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}
}
7 replies
FFilament
Created by Simon on 11/28/2023 in #❓┊help
Muting Events
Figured it out! In my EditDeveloper Page:
protected function beforeSave(): void
{
Developer::unsetEventDispatcher();
}
protected function beforeSave(): void
{
Developer::unsetEventDispatcher();
}
4 replies
FFilament
Created by Simon on 11/23/2023 in #❓┊help
SpatieMediaLibraryFileUpload not working on $this->form->fill() after upgrading to v3
I found the cause... I was missing the call to ->model() on the end of my $form in the component
// Before...
public function form(Form $form): Form
{
return $form->schema([...])->statePath('data');
}

// After...
public function form(Form $form): Form
{
return $form->schema([...])->statePath('data')->model($modelInstance);
}
// Before...
public function form(Form $form): Form
{
return $form->schema([...])->statePath('data');
}

// After...
public function form(Form $form): Form
{
return $form->schema([...])->statePath('data')->model($modelInstance);
}
6 replies
FFilament
Created by bernhard on 11/17/2023 in #❓┊help
Allow comma sign in TagsInput
@bernhard the TagsInput accepts a ->splitKeys([]) (at least in v3) method which means it will ONLY use Enter unless you define some other keys in that array, e.g.
TagsInput::make('tags')->splitKeys(['Tab', ',']);
TagsInput::make('tags')->splitKeys(['Tab', ',']);
I just tested this myself on v3 and without the splitKeys method I am able to use a comma in my tags without it completing a tag
3 replies
FFilament
Created by Simon on 11/23/2023 in #❓┊help
SpatieMediaLibraryFileUpload not working on $this->form->fill() after upgrading to v3
I've not seen any references to casting this in the model or any referencing to casting in the docs of either the Filament wrapper or the Spatie Media Library package... The way the model registers its interest in managing media library uploads is by implementing the Spatie\MediaLibrary\HasMedia interface and using the Spatie\MediaLibrary\InteractsWithMedia trait My model overrides the registerMediaCollections() method as needed to create the following photo media collection:
public function registerMediaCollections()
{
$this
->addMediaCollection('photo')
->singleFile()
->useFallbackUrl($this->defaultPhotoUrl())
->registerMediaConversions(function (Media $media) {
$this
->addMediaConversion('thumbnail')
->fit(Manipulations::FIT_CROP, 150, 150);

$this
->addMediaConversion('preview')
->fit(Manipulations::FIT_CROP, 300, 300);

$this
->addMediaConversion('big')
->fit(Manipulations::FIT_CROP, 512, 512);
});
}
public function registerMediaCollections()
{
$this
->addMediaCollection('photo')
->singleFile()
->useFallbackUrl($this->defaultPhotoUrl())
->registerMediaConversions(function (Media $media) {
$this
->addMediaConversion('thumbnail')
->fit(Manipulations::FIT_CROP, 150, 150);

$this
->addMediaConversion('preview')
->fit(Manipulations::FIT_CROP, 300, 300);

$this
->addMediaConversion('big')
->fit(Manipulations::FIT_CROP, 512, 512);
});
}
This all worked in Filament v2 and I can't find any reference to anything changing (either that has changed or should change) that would cause this to stop working
6 replies