mardi 14 juillet 2020

laravel equivalent order by random

I am beginner in Laravel.

I have project in Laravel 7.

I have this code:

public function getPromoProducts()
    {
        return $this->model->select('name', 'slug', 'products.id', 'small_description', 'promo_desc')->with(['features', 'frontImage'])->active()->leftJoin('selected_product_features', function ($join) {
            $join->on('products.id', '=', 'selected_product_features.product_id');
        })->where('selected_product_features.key', 'price_promo')->where('selected_product_features.description', '<>', 0)->limit(2)->get();
    }

how can I make add to this code "ORDER BY RAND()" from traditional mysql?

Please help me



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire