Pedroesca
Heading value
I have a custom page:
protected ?string $heading = null;
class ProjectStepper extends Page
public function mount($recordId): void
{
$this->record= Project::findOrFail($recordId);
$this->heading = $this->record->name;
}
Here it correctly assigns the title dynamically; but, when I try to perform the following action:
protected function getHeaderActions(): array
{
return [
Action::make('create') ->icon('heroicon-c-plus') ->color('graydark') ->label('Nueva Tarea') // ->url(TaskResource::getUrl('create', ['project_id' => $this->record->id, 'title' => 'Nueva Tarea'])) ->form([ TextInput::make('title') ->label('Título') ->placeholder('Título de la Tarea') ->required(), TextInput::make('project_id') ->label('Proyecto') ->default($this->record->id) ->placeholder('ID del Proyecto') ->required(), ]) ->openUrlinNewTab(),
]; } the value of $heading is "reset"
Action::make('create') ->icon('heroicon-c-plus') ->color('graydark') ->label('Nueva Tarea') // ->url(TaskResource::getUrl('create', ['project_id' => $this->record->id, 'title' => 'Nueva Tarea'])) ->form([ TextInput::make('title') ->label('Título') ->placeholder('Título de la Tarea') ->required(), TextInput::make('project_id') ->label('Proyecto') ->default($this->record->id) ->placeholder('ID del Proyecto') ->required(), ]) ->openUrlinNewTab(),
]; } the value of $heading is "reset"
2 replies
Custom search in table
I have a little situation here:
When I get ONLY ONE record, I need to add it to the cart (that happens, I just have to refresh the page with F5 for it to be reflected);
When I search by other criteria, it gets them correctly but when I press the action row, IT ALWAYS ADDS THE FIRST record in the table.
I know I'm doing something wrong.
public function table(Table $table): Table
{
return $table
->query(function()
{
if ($this->tableSearch === '') {
return Product::query()->whereRaw('1 = 0');
} else {
$product = Product::get()
->where('barcode', '=', $this->tableSearch);
if ($product->count() === 1) {
$this->addToCart($product->first()->id);
$this->updateCart();
$this->resetTableSearch();
return Product::query()->whereRaw('1 = 0');
} else {
return Product::query()
->where('name', 'like', '%' . $this->tableSearch . '%')
->orWhere('barcode', 'like', '%' . $this->tableSearch . '%');
}
}
return Product::query();
})
->columns([
TextColumn::make('name')->searchable(),
TextColumn::make('barcode')->searchable(),
])
->actions([
Action::make('add-cart')
->button()
->action(function($record){
$this->addToCart($record->id);
//dd($record);
})
]);
}
1 replies
Searchable in select blade
Hola. Es posible que al blade del select:
<x-filament::input.wrapper>
<x-filament::input.select wire:model="status">
<option value="draft">Draft</option>
<option value="reviewing">Reviewing</option>
<option value="published">Published</option>
</x-filament::input.select>
</x-filament::input.wrapper>
se le pueda agregar la propiedad o método "searchable()" tal como se utiliza en un recurso de filament?
2 replies
beforeSave whith relations
I have the following process in beforeSave() of EditSale.php, in which I restore the stock (quantities) of products, before the records are saved, as indicated by the "beforeSave" hook, but it turns out that when entering this hook the data of the relationship (SaleDetails) has already been saved.
i.e. where do i get the original detail before it is saved? is there a hook for this? for these cases beforesave does not work.
11 replies