Example of Collection Methods: Transform in akaunting/akaunting

File app/Http/Controllers/Settings/Modules.php (link to Github)
use App\Abstracts\Http\Controller;
use App\Models\Banking\Account;
use App\Models\Setting\Category;
use App\Models\Setting\Setting;

class Modules extends Controller
{
    //
    public function edit($alias)
    {
        $accounts = Account::enabled()->orderBy('name')->pluck('name', 'id');
        $categories = Category::income()->enabled()->orderBy('name')->pluck('name', 'id');

        $setting = Setting::prefix($alias)->get()->transform(function ($s) use ($alias) {
            $s->key = str_replace($alias . '.', '', $s->key);
            return $s;
        })->pluck('value', 'key');

        $module = module($alias);

        return view('settings.modules.edit', compact('setting', 'module', 'accounts', 'categories'));
    }
    //
}