Introduction
The code entry allows you to present a highlighted code snippet in your infolist. It uses Phiki for code highlighting on the server:phiki/phiki Composer package. Filament does not include it by default to allow you to choose which major version of Phiki to use explicitly, since major versions can have different grammars and themes available. You can install the latest version of Phiki using the following command:
Changing the code’s grammar (language)
You may change the grammar (language) of the code using thegrammar() method. Over 200 grammars are available, and you can open the Phiki\Grammar\Grammar enum class to see the full list. To switch to use JavaScript as the grammar, you can use the Grammar::Javascript enum value:
As well as allowing a static value, the grammar() method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.
grammar() method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.Learn more about utility injection.
Entry
$component
Filament\Infolists\Components\Entry
The current entry component instance.
Get function
$get
Filament\Schemas\Components\Utilities\Get
A function for retrieving values from the current schema data. Validation is not run on form fields.
Livewire
$livewire
Livewire\Component
The Livewire component instance.
Eloquent model FQN
$model
?string<Illuminate\Database\Eloquent\Model>
The Eloquent model FQN for the current schema.
Operation
$operation
string
The current operation being performed by the schema. Usually
create, edit, or view.Eloquent record
$record
?Illuminate\Database\Eloquent\Model
The Eloquent record for the current schema.
State
$state
mixed
The current value of the entry.
Changing the code’s theme (highlighting)
You may change the theme of the code using thelightTheme() and darkTheme() methods. Over 50 themes are available, and you can open the Phiki\Theme\Theme enum class to see the full list. To use the popular Dracula theme, you can use the Theme::Dracula enum value:
As well as allowing static values, the lightTheme() and darkTheme() methods also accept functions to dynamically calculate them. You can inject various utilities into the functions as parameters.
lightTheme() and darkTheme() methods also accept functions to dynamically calculate them. You can inject various utilities into the functions as parameters.Learn more about utility injection.
Entry
$component
Filament\Infolists\Components\Entry
The current entry component instance.
Get function
$get
Filament\Schemas\Components\Utilities\Get
A function for retrieving values from the current schema data. Validation is not run on form fields.
Livewire
$livewire
Livewire\Component
The Livewire component instance.
Eloquent model FQN
$model
?string<Illuminate\Database\Eloquent\Model>
The Eloquent model FQN for the current schema.
Operation
$operation
string
The current operation being performed by the schema. Usually
create, edit, or view.Eloquent record
$record
?Illuminate\Database\Eloquent\Model
The Eloquent record for the current schema.
State
$state
mixed
The current value of the entry.
Allowing the code to be copied to the clipboard
You may make the code copyable, such that clicking on it copies the code to the clipboard, and optionally specify a custom confirmation message and duration in milliseconds. This feature only works when SSL is enabled for the app.As well as allowing static values, the copyable(), copyMessage(), and copyMessageDuration() methods also accept functions to dynamically calculate them. You can inject various utilities into the function as parameters.
copyable(), copyMessage(), and copyMessageDuration() methods also accept functions to dynamically calculate them. You can inject various utilities into the function as parameters.Learn more about utility injection.
Entry
$component
Filament\Infolists\Components\Entry
The current entry component instance.
Get function
$get
Filament\Schemas\Components\Utilities\Get
A function for retrieving values from the current schema data. Validation is not run on form fields.
Livewire
$livewire
Livewire\Component
The Livewire component instance.
Eloquent model FQN
$model
?string<Illuminate\Database\Eloquent\Model>
The Eloquent model FQN for the current schema.
Operation
$operation
string
The current operation being performed by the schema. Usually
create, edit, or view.Eloquent record
$record
?Illuminate\Database\Eloquent\Model
The Eloquent record for the current schema.
State
$state
mixed
The current value of the entry.