Skip to content

Instantly share code, notes, and snippets.

@evercode1
Created February 11, 2017 07:29
Show Gist options
  • Select an option

  • Save evercode1/91e59e09d9318fc953c391e9f8e6a40e to your computer and use it in GitHub Desktop.

Select an option

Save evercode1/91e59e09d9318fc953c391e9f8e6a40e to your computer and use it in GitHub Desktop.
chapter 15 CategoryQuery.php
<?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