Get Variable from Component in View
How can I access the
$maxStars variable in my view?Solution
Make it public variable and you can access it just by typinbg
{{ $maxStars }}$maxStars$maxStars variable in my view?namespace App\Forms\Components;
use Filament\Forms\Components\Component;
class StarRating extends Component
{
protected string $view = 'forms.components.star-rating';
protected int $maxStars = 5;
public static function make(): static
{
return app(static::class);
}
}namespace App\Forms\Components;
use Filament\Forms\Components\Component;
class StarRating extends Component
{
protected string $view = 'forms.components.star-rating';
protected int $maxStars = 5;
public static function make(): static
{
return app(static::class);
}
}{{ $maxStars }}{{ $maxStars }}{{ $maxStars }}{{ $maxStars }}