Skip to content

Instantly share code, notes, and snippets.

@evercode1
Created February 11, 2017 22:39
Show Gist options
  • Save evercode1/f52894c271ff355ce3ad447648c0acdb to your computer and use it in GitHub Desktop.
Save evercode1/f52894c271ff355ce3ad447648c0acdb to your computer and use it in GitHub Desktop.
chapter 15 LessonQuery.php
<?php
namespace App\Queries\GridQueries;
use DB;
use App\Queries\GridQueries\Contracts\DataQuery;
class LessonQuery implements DataQuery
{
public function data($column, $direction)
{
$rows = DB::table('lessons')
->select('id as Id',
'name as Name',
'slug as Slug',
DB::raw('DATE_FORMAT(created_at,"%m-%d-%Y") as Created'))
->orderBy($column, $direction)
->paginate(10);
return $rows;
}
public function filteredData($column, $direction, $keyword)
{
$rows = DB::table('lessons')
->select('id as Id',
'name as Name',
'slug as Slug',
DB::raw('DATE_FORMAT(created_at,"%m-%d-%Y") as Created'))
->where('name', 'like', '%' . $keyword . '%')
->orderBy($column, $direction)
->paginate(10);
return $rows;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment