public function getMain() { $moderatequotes = Quote::orderBy('id', 'desc')->whereStatus(0); $quotes = Auth::user()->quotes()->orderBy('id', 'desc')->paginate(Config::get('settings.per_page')); $this->layout->title = 'Dashboard'; $this->layout->nest('content', 'user.dashboard.main', ['quotes' => $quotes, 'moderatequotes' => $moderatequotes]); }
/** * Display a listing of the resource. * * @return Response */ public function index() { if (!Input::has('sp')) { $sp = 0; } else { $sp = intval(Input::get('sp')); } return Response::json(['sp' => intval($sp) + 10, 'quotes' => Quote::orderBy('created_at', 'desc')->skip($sp)->take(10)->get()]); }
public function getSearch() { if (Session::has('search')) { $words = explode(' ', Session::get('search')); $quotes = Quote::orderBy('id', 'desc')->orWhere(function ($query) use($words) { foreach ($words as $word) { $query->where('quote', 'LIKE', '%' . $word . '%'); } $query->whereStatus(1); })->orWhere(function ($query) use($words) { foreach ($words as $word) { $query->where('title', 'LIKE', '%' . $word . '%'); } $query->whereStatus(1); })->paginate(Config::get('settings.per_page')); $quotesCount = $quotes->count(); //$this->layout->title = 'Search'; $this->layout->nest('content', 'search', ['quotes' => $quotes, 'count' => $quotesCount, 'terms' => Session::get('search')]); } else { return Redirect::to('/')->withErrors(array('usesearch' => 'Use the search box, silly :)')); } }