public function index() { $discounts = Discounts::orderBy('time', 'desc')->paginate(10); if (Request::ajax()) { return \Response::json(\View::make('discounts.list', array('discounts' => $discounts))->render()); } return view('home', ['discounts' => $discounts]); }
public function __construct() { // Fetch the Site Settings object $this->recomends = Discounts::where('is-rec', '=', '1')->orderBy('time', 'desc')->take(4)->get()->toArray(); $this->populars = Discounts::orderBy('clicks', 'desc')->take(4)->get()->toArray(); \View::share('recomends', $this->recomends); \View::share('populars', $this->populars); }