samedi 30 mars 2019

How to make products show on homepage randomly

I was trying to make products show on homepage in a random manner.

Here's my homepage controller codes.

please help

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Category;
use App\Product;
use App\News;
use App\User;

class HomeController extends Controller
{
    public function Index(){
      $news = News::get();
      $products = Product::list()->paginate(20);
      $categories = Category::where("parent_id",0)->get();
      return view('index')->with([
        'news'=>$news,
        'products'=> $products,
        'categories'=>$categories,
      ]);
    }
}



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2HX4gy1
via IFTTT

Aucun commentaire:

Enregistrer un commentaire