Created
February 11, 2017 07:29
-
-
Save evercode1/91e59e09d9318fc953c391e9f8e6a40e to your computer and use it in GitHub Desktop.
chapter 15 CategoryQuery.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 CategoryQuery implements DataQuery | |
| { | |
| public function data($column, $direction) | |
| { | |
| $rows = DB::table('categories') | |
| ->select('id as Id', | |
| 'name as Name', | |
| 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('categories') | |
| ->select('id as Id', | |
| 'name as Name', | |
| 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