Advertisement
luanoliveira

DataProvider

Sep 20th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | None | 0 0
  1. <?php
  2.  
  3. class DataProvider
  4. {
  5.     protected $table;
  6.  
  7.     protected $alias;
  8.  
  9.     protected $query;
  10.  
  11.     protected $filters = [];
  12.  
  13.     public function __construct()
  14.     {
  15.         if (empty($this->alias)) {
  16.             $this->alias = $this->table;
  17.         }
  18.  
  19.         $query = DB::table(sprintf('%s as %s', $this->table, $this->alias));
  20.         $query->select(sprintf('%s.*', $this->alias));
  21.         $this->modifyQueryBuilder($query);
  22.         $this->query = $query;
  23.     }
  24.  
  25.     public function getQuery()
  26.     {
  27.         return $this->query;
  28.     }
  29.  
  30.     public function modifyQueryBuilder(&$query)
  31.     {
  32.  
  33.     }
  34.  
  35.     public function getData()
  36.     {
  37.         return $this->getQuery()->get();
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement