Filament Repeating Code: 2 Refactoring Examples

Поділитися
Вставка
  • Опубліковано 5 січ 2025

КОМЕНТАРІ • 13

  • @luiscevallos1
    @luiscevallos1 6 днів тому +1

    Happy new year ... Thanks for all

  • @aymanmalhattami
    @aymanmalhattami 8 днів тому

    Great tip

  • @GiedriusKartanovic
    @GiedriusKartanovic 11 днів тому +3

    You could further reduce repetition by passing reference to the method (PHP >=8.1) e.g. `->afterStateUpdated(self::updateTotalCost(...))`

  • @edgarteichert5587
    @edgarteichert5587 17 днів тому +1

    Hi, there. It's also possible to put the closure in the function itself. Then one just needs to put the function name in. E.g.
    ->afterStateUpdated(static::updateTotalCost())
    then
    return fn($set, $get) => doSomething()
    in the function itself. Even less code and nice look.

  • @onlinebusinessblog2910
    @onlinebusinessblog2910 2 години тому

    Good day to you, i am having difficulty just now i discovered that my import modal is no longer opening, but it was working fine.

  • @archiealvarado8831
    @archiealvarado8831 18 днів тому

    I am learning Filament. It is just a Livewire with the shortcuts. Is it still relevant in the future because it looks like low code programming. Should I master it? Here in the PH nobody uses it.

    • @FilamentDaily
      @FilamentDaily  18 днів тому +5

      It depends on what projects you wanna work with. For each kind of projects, there are different languages and frameworks. Filament definitely has its niche. The question is do you see that niche and wanna be part of it.

  • @faridmoreno2864
    @faridmoreno2864 18 днів тому

    Thank you for those tips! I have a question: How Can I put the some logic (total_cost) in a service class? Because, I want use this logic in other system parts :D

    • @FilamentDaily
      @FilamentDaily  16 днів тому +1

      Well yeah, create a service class and put a function with parameters in there, not sure what is the question here :)

    • @faridmoreno2864
      @faridmoreno2864 3 дні тому

      @@FilamentDaily Sorry, I meant how can I call the function in Filament resources?

    • @FilamentDaily
      @FilamentDaily  3 дні тому

      @@faridmoreno2864 Well you create the object of that service class and then call the function you need. Sorry hard to answer without specific examples.