Created
February 11, 2017 22:39
-
-
Save evercode1/f52894c271ff355ce3ad447648c0acdb to your computer and use it in GitHub Desktop.
chapter 15 LessonQuery.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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