Ich möchte ein Array shuffel. Aber es wird nicht funktionieren. Das ist meine Suchanfrage in LaravelShuffle Array aus Sammlung
$spielerArray = Spieler::join('PlanungSpieler', 'PlanungSpieler.Player_ID', '=', 'Spieler.Player_ID')
->select('Spieler.Player_ID')->get();
Und im nächsten Schritt möchte ich nur die Spalte Spieler.Player mischen.
$finalShuffleResult = shuffle($spielerArray->Player_ID)
ich Player_ID Instance does not exist on this collection
Hier ist ein Teil meiner Sammlung
Illuminate\Database\Eloquent\Collection Object
(
[items:protected] => Array
(
[0] => App\Spieler Object
(
[table:protected] => Spieler
[connection:protected] => mysql
[primaryKey:protected] => id
[keyType:protected] => int
[incrementing] => 1
[with:protected] => Array
(
)
[withCount:protected] => Array
(
)
[perPage:protected] => 15
[exists] => 1
[wasRecentlyCreated] =>
[attributes:protected] => Array
(
[Player_ID] => 101
)
Wie kann ich player_id mit dem Ziel, bekommen sie zu mischen?
[ 'inRandomOrder'] (https://laravel.com/docs/5.5/queries#ordering-grouping-limit-and-offset) könnte besser funktionieren. – apokryfos