inject<T extends Object> function

T inject<T extends Object>({
  1. String? name,
})

Resolves T from the active container (Laravel's resolve()), with T inferred from where the value goes, so a default stays mockable:

final class OrderController {
  OrderController({OrderService? orders}) : orders = orders ?? inject();
  final OrderService orders;
}

Request-scoped services resolve to the current request's instance.

Implementation

T inject<T extends Object>({String? name}) =>
    Container.current.make<T>(name: name);