|
|
- <?php
-
- namespace App\Traits;
-
- trait Invokable
- {
- /**
- * Invoke the given service.
- *
- * @see __invoke()
- */
- public static function invoke(...$arguments)
- {
- return app(static::class)(...$arguments);
- }
-
- /**
- * Invoke the given service if the boolean argument is truthy.
- *
- * @see __invoke()
- */
- public static function invokeIf($boolean, ...$arguments)
- {
- if (!$boolean) {
- return;
- }
-
- return static::invoke(...$arguments);
- }
- }
|