Skip to content

Instantly share code, notes, and snippets.

View jlpellicer's full-sized avatar

José Luis Pellicer jlpellicer

  • Tequisquiapan Qro., México
View GitHub Profile
@jlpellicer
jlpellicer / get_option_label.md
Last active February 26, 2024 19:43
How to get the selected option from a select input

Laravel 10 / Filament 3

Using Filament 3 and Laravel 10, if you want to get the label from a select you can use getOptions() to get an array of the options and use the $state (or Get works too) to get the value that you selected.

Forms\Components\Select::make('exchange_rate_id')
    ->relationship('exchange_rate', 'rate')
    ->searchable()
    ->preload()
 ->live() // don't miss this, it's important for this to work
@jlpellicer
jlpellicer / default_value_filament.md
Last active December 20, 2023 16:57
How to fill a default value in an text input in the edit page in Filament

Laravel 10 / Filament 3 / Livewire

When you open an edit form in Filament, the default property doesn't work, it only works when creating a new record.

In this case you want to use the afterStateHydrated property, inject the current form Component and, in my case, also inject the Get so that I can get the value of another property:

Forms\Components\TextInput::make('value')
    ->label(
 function(Get $get) {
@jlpellicer
jlpellicer / new_action.md
Last active December 8, 2023 03:07
Filament & Laravel add new reusable actions

Laravel 10 / Filament 3 / Livewire

1- Create your action, your Laravel Action You can see that I alredy have a notification that handles the email where the new password is sent.

<?php

namespace App\Actions;
@jlpellicer
jlpellicer / security.go
Created November 15, 2017 18:10
Security headers (Go)
package middleware
import "net/http"
const (
xFrameOptions = "X-Frame-Options"
xFrameOptionsValue = "DENY"
xContentTypeOptions = "X-Content-Type-Options"
xContentTypeOptionsValue = "nosniff"
xssProtection = "X-XSS-Protection"