class Lottery (View source)
| protected int|float | $chances | The number of expected wins. | |
| protected int|null | $outOf | The number of potential opportunities to win. | |
| protected null|callable | $winner | The winning callback. | |
| protected null|callable | $loser | The losing callback. | |
| static protected callable|null | $resultFactory | The factory that should be used to generate results. |
| void | __construct(int|float $chances, int|null $outOf = null)
Create a new Lottery instance. | |
| static Lottery | odds(int|float $chances, int|null $outOf = null)
Create a new Lottery instance. | |
| $this | winner(callable $callback)
Set the winner callback. | |
| $this | loser(callable $callback)
Set the loser callback. | |
| mixed | __invoke(mixed ...$args)
Run the lottery. | |
| mixed | choose(null|int $times = null)
Run the lottery. | |
| callable | runCallback(mixed ...$args)
Run the winner or loser callback, randomly. | |
| bool | wins()
Determine if the lottery "wins" or "loses". | |
| static callable | resultFactory()
The factory that determines the lottery result. | |
| static void | alwaysWin(callable|null $callback = null)
Force the lottery to always result in a win. | |
| static void | alwaysLose(callable|null $callback = null)
Force the lottery to always result in a lose. | |
| static void | fix(array $sequence, callable|null $whenMissing = null)
Set the sequence that will be used to determine lottery results. | |
| static void | forceResultWithSequence(array $sequence, callable|null $whenMissing = null)
Set the sequence that will be used to determine lottery results. | |
| static void | determineResultsNormally()
Indicate that the lottery results should be determined normally. | |
| static void | determineResultNormally()
Indicate that the lottery results should be determined normally. | |
| static void | setResultFactory(callable $factory)
Set the factory that should be used to determine the lottery results. |
Create a new Lottery instance.
Create a new Lottery instance.
Set the winner callback.
Set the loser callback.
Run the lottery.
Run the lottery.
Run the winner or loser callback, randomly.
Determine if the lottery "wins" or "loses".
The factory that determines the lottery result.
Force the lottery to always result in a win.
Force the lottery to always result in a lose.
Set the sequence that will be used to determine lottery results.
Set the sequence that will be used to determine lottery results.
Indicate that the lottery results should be determined normally.
Indicate that the lottery results should be determined normally.
Set the factory that should be used to determine the lottery results.
© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/11.x/Illuminate/Support/Lottery.html