jeudi 6 octobre 2016

Fetch related items ordered randomly with eloquent / Larvael 5.x

Simply put, if I have an Entity that has many related items (hasMany) how can I fetch that entity and it's related items with those related rows being ordered randomly

I fetch like so:

 $question = Question::with('categories', 'answers')->where( _some_parameters_ ) ... ->get(); 

How would I shuffle those 'answers' in the resulting object?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire