SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'created_at' in order clause is ambiguo
Why do i get this error here even though i set the default sort from the specific table?
<?php
namespace App\Filament\Resources\UserResource\RelationManagers;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables;
use Filament\Tables\Table;
class WatchedLecturesRelationManager extends RelationManager
{
protected static string $relationship = 'watchedLectures';
protected ?string $heading = 'Гледани лекции';
protected static ?string $title = 'Гледани лекции';
protected static ?string $pluralModelLabel = 'Гледани лекции';
protected static ?string $modelLabel = 'Гледани лекции';
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('id')
->columns([
Tables\Columns\TextColumn::make('lecture.title')
->label('Лекција'),
Tables\Columns\TextColumn::make('user_watched_lectures.created_at')
->label('Креирано на')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
//
])
->headerActions([
//
])
->actions([
//
])
->bulkActions([
//
])
->defaultSort('user_watched_lectures.created_at', 'desc');
}
}<?php
namespace App\Filament\Resources\UserResource\RelationManagers;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables;
use Filament\Tables\Table;
class WatchedLecturesRelationManager extends RelationManager
{
protected static string $relationship = 'watchedLectures';
protected ?string $heading = 'Гледани лекции';
protected static ?string $title = 'Гледани лекции';
protected static ?string $pluralModelLabel = 'Гледани лекции';
protected static ?string $modelLabel = 'Гледани лекции';
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('id')
->columns([
Tables\Columns\TextColumn::make('lecture.title')
->label('Лекција'),
Tables\Columns\TextColumn::make('user_watched_lectures.created_at')
->label('Креирано на')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
//
])
->headerActions([
//
])
->actions([
//
])
->bulkActions([
//
])
->defaultSort('user_watched_lectures.created_at', 'desc');
}
}