bellini
bellini
FFilament
Created by bellini on 8/13/2023 in #❓┊help
Display relationship data in a resource
I have a Post model that has a user_id column that relates to User model on a relationship called user(), in a resource how can I show the user name for that Post? Right now I have this, and looking at the docs I did not found a way to do this:
->columns([
Tables\Columns\TextColumn::make('name'),
Tables\Columns\TextColumn::make('email'),
Tables\Columns\TextColumn::make('created_at')
->dateTime(),
Tables\Columns\TextColumn::make('updated_at')
->dateTime(),
Tables\Columns\TextColumn::make('user_id')
->columns([
Tables\Columns\TextColumn::make('name'),
Tables\Columns\TextColumn::make('email'),
Tables\Columns\TextColumn::make('created_at')
->dateTime(),
Tables\Columns\TextColumn::make('updated_at')
->dateTime(),
Tables\Columns\TextColumn::make('user_id')
4 replies
FFilament
Created by bellini on 8/12/2023 in #❓┊help
Basic question regarding relationships in a resource
I have a Post resource, that has a user_id column, and in my form method I have this array:
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('title')
->required()
->maxLength(255),
Forms\Components\Textarea::make('content')
->required()
->minLength(5),

]);
}
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('title')
->required()
->maxLength(255),
Forms\Components\Textarea::make('content')
->required()
->minLength(5),

]);
}
How can I automatically save the current authenticated user in the user_id? I have searched the documentation and tried it on the CreatePost class with the mutateFormDataBeforeCreate method but sill doesn't work.
6 replies