guitarnerd_
guitarnerd_
FFilament
Created by guitarnerd_ on 9/18/2023 in #❓┊help
Error in Action: "$ownerRecord must not be accessed before initialization"
Hello, I'm trying to access livewire->ownerRecord inside an action but i'm getting the error in the title. Here is my code
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('id')->sortable(),
Tables\Columns\TextColumn::make('seller.organization')->sortable(),
Tables\Columns\TextColumn::make('lead_time_value')->sortable(),
Tables\Columns\TextColumn::make('lead_time_unit')->sortable(),
Tables\Columns\TextColumn::make('quote')->sortable(),

])
->filters([
//
])
->headerActions([])
->actions([
Action::make('assign')
->label('Assign')
->action(function (Quote $quote, RelationManager $livewire) use ($table) {
dd($livewire->ownerRecord);
OrderItem::find(self::$order_item_id)->assign($quote);
})
])
->bulkActions([]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('id')->sortable(),
Tables\Columns\TextColumn::make('seller.organization')->sortable(),
Tables\Columns\TextColumn::make('lead_time_value')->sortable(),
Tables\Columns\TextColumn::make('lead_time_unit')->sortable(),
Tables\Columns\TextColumn::make('quote')->sortable(),

])
->filters([
//
])
->headerActions([])
->actions([
Action::make('assign')
->label('Assign')
->action(function (Quote $quote, RelationManager $livewire) use ($table) {
dd($livewire->ownerRecord);
OrderItem::find(self::$order_item_id)->assign($quote);
})
])
->bulkActions([]);
}
28 replies
FFilament
Created by guitarnerd_ on 9/15/2023 in #❓┊help
How to get record data or just id of a relation manager record.
class ItemsRelationManager extends RelationManager
{
protected static string $relationship = 'items';

protected static ?string $recordTitleAttribute = 'id';

public static function form(Form $form): Form
{

//how to get the record id here
}
}
class ItemsRelationManager extends RelationManager
{
protected static string $relationship = 'items';

protected static ?string $recordTitleAttribute = 'id';

public static function form(Form $form): Form
{

//how to get the record id here
}
}
21 replies
FFilament
Created by guitarnerd_ on 8/20/2023 in #❓┊help
Is there a way to compare the data before and after save ?
Hello, I am looking to compare the change in data to decide whether I want to send an email to the user. Is it possible to do it ?
3 replies
FFilament
Created by guitarnerd_ on 8/4/2023 in #❓┊help
Issues with Attach/Associate action between a belongsTo/hasMany relationship
Hi everyone, I have a model called Order and another called OrderStatus. The relevant realtionships are the following:
Order.php

public function orderStatus()
{
return $this->belongsTo(OrderStatus::class);
}
Order.php

public function orderStatus()
{
return $this->belongsTo(OrderStatus::class);
}
OrderStatus.php

public function order()
{
return $this->hasMany(Order::class);
}
OrderStatus.php

public function order()
{
return $this->hasMany(Order::class);
}
I created an OrderStatusRelationManager in OrderResource and registered it in getRelations. I want to be able to change the order status. In my the table function I have the following
->headerActions([
Tables\Actions\AssociateAction::make()->preloadRecordSelect(),
])
->headerActions([
Tables\Actions\AssociateAction::make()->preloadRecordSelect(),
])
I'm getting the following error:
Call to undefined method Illuminate\Database\Eloquent\Relations\HasMany::associate()
Call to undefined method Illuminate\Database\Eloquent\Relations\HasMany::associate()
I also tried AttachAction in case I misunderstood which one I should use and I got
Call to undefined method Illuminate\Database\Eloquent\Relations\BelongsTo::getRelatedKeyName()
Call to undefined method Illuminate\Database\Eloquent\Relations\BelongsTo::getRelatedKeyName()
I also defined the inverse relation in my relation manager.
protected static ?string $inverseRelationship = 'orders';
protected static ?string $inverseRelationship = 'orders';
What am I missing ?
4 replies
FFilament
Created by guitarnerd_ on 8/3/2023 in #❓┊help
How can I change the assumed table name in a relation manager?
Hi everyone, I have a belongsToMany relation between a medications table and a presentation table. The pivot table includes extra information so I called it medication_variation. I created a relation manager but filament is looking for a table called medication_presentation. How can I change it ?
5 replies
FFilament
Created by guitarnerd_ on 7/30/2023 in #❓┊help
Make Relation Manager for a belongsToMany Relation add records with a Dropdown instead of text input
4 replies