Juan Haag
Juan Haag
FFilament
Created by Juan Haag on 10/23/2023 in #❓┊help
How to insert data in TextColumn using CASE query
How can I assign a value using a CASE query in a TextColumn::make() column in Filament, considering that the value depends on conditions in the model X? This is the query
DB::raw('
CASE
WHEN bookings.user_id IS NULL AND bookings.br_company_id IS NULL THEN 1
WHEN bookings.user_id IS NOT NULL THEN 2
WHEN bookings.br_company_id IS NOT NULL THEN 3
END as client_type
')
DB::raw('
CASE
WHEN bookings.user_id IS NULL AND bookings.br_company_id IS NULL THEN 1
WHEN bookings.user_id IS NOT NULL THEN 2
WHEN bookings.br_company_id IS NOT NULL THEN 3
END as client_type
')
I'm not sure what value to put inside the TextColumn::make() since it wouldn't involve a direct relationship. Ty for all.
5 replies