Filament\Tables\Table could not be converted to string
The error is in vendor/filament/filament/resources/views/resources/relation-manager.blade.php on line 6
This only happens when I'm trying to add a freshly-created RelationshipManager to a Resource
I'm not sure what I'm missing
Solution:Jump to solution
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');
3 Replies
Please provide your code
@toeknee
this is all pretty vanilla at this stage... weird to see an error
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(),
]),
]);
}
}
Solution
I figured it out! For some reason this app is setting this in the
I needed to wrap it like this:
AppServiceProvider
- I guess for some backwards-compatibility:
\Illuminate\Support\Facades\Blade::setEchoFormat('%s');
\Illuminate\Support\Facades\Blade::setEchoFormat('%s');
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');
}