Because of short closures, I ended up wondering if Higher Order Ifs are nice to read.
I don't really recommend this, it's just a fun exercise to help me figure out how Laravel did the Higher Order stuff. 😅
public static function boot()
{
static::created(function ($user) {
if ($user->isSuperAdmin()) {
$task->activate();
}
});
}
to
# Using the "Iffable"
public static function boot()
{
static::created(fn ($user) => $user->if->isSuperAdmin()->activate());
}
# or
public static function boot()
{
static::created(fn ($user) => $user->if()->isSuperAdmin()->activate());
}