masto.es es uno de los varios servidores independientes de Mastodon que puedes usar para participar en el fediverso.
Bienvenidos a masto.es, el mayor servidor de Mastodon para hispanohablantes de temática general.

Administrado por:

Estadísticas del servidor:

2,1 K
usuarios activos

#blade

4 publicaciones3 participantes1 publicación hoy

Scrap this, I was being an idiot and reading documentation is apparently hard 😂 🤦‍♂️

~Huh... this is interesting in Laravel. Say you have a model, let's call it Registration and it has nullable boolean as one of its fields. Let call that field approved where null means "not yet decided", "false" is declined and "true" is accepted.~

~If you throw in that field into a custom Blade component like so;~

class RegistrationStatusComponent extends Component
{
    /**
     * Create a new component instance.
     *
     * @return void
     */
    public function __construct(
        public null | bool $approved
    ) {
        dd($this->approved);
    }

    /**
     * Get the view / contents that represent the component.
     *
     * @return \Illuminate\Contracts\View\View|\Closure|string
     */
    public function render()
    {
        return view('components.registration-status-component');
    }
}

~If you throw in a model that has an approved value of null, Blade will automatically cast that null-value to false.~
false // app/View/Components/RegistrationStatusComponent.php:17

This is how I am using the compnent btw;
php
    $approved = $registration->approved;
    dump($approved);
@endphp
<x-registration-status-component approved="$approved" />

~I was today years old when I learned that this is apparently a thing.~

#PHP #Laravel #Blade