Laravel - Collections - Method Mode

The mode method returns the mode value of a given key:

    
    $mode = collect([
        ['foo' => 10],
        ['foo' => 10],
        ['foo' => 20],
        ['foo' => 40]
    ])->mode('foo');
    
    // [10]
    
    $mode = collect([1, 1, 2, 4])->mode();
    
    // [1]
    
    $mode = collect([1, 1, 2, 2])->mode();
    
    // [1, 2]