/
home
/
henzagold
/
server
/
app
/
Te
/
File Upload :
llllll
Current File: /home/henzagold/server/app/Te/TableEngineInput.php
<?php /** * Created by PhpStorm. * User: AraNote * Date: 18/04/2018 * Time: 06:27 PM */ namespace App\DB\Te; use Illuminate\Support\Arr; class TableEngineInput { public $columns; public $columnTitles; public $reportTitle; public $filters; public $filtersOpt; public $selectCommand; public $selectItems; public $limit = 1000; public $page; public $key; public $sort; public $search; public $op; /** * TableEngineInput constructor. */ public function __construct($input) { if (isset($input['select'])) { $this->columns = array_filter($input['select'], function ($item) { return $item != 'opt'; }); } if (isset($input['titles'])) { $this->columnTitles = $input['titles']; } if (isset($input['report_title'])) { $this->reportTitle = $input['report_title']; } if (isset($input['filters'])) { $this->filters = $input['filters']; } if (isset($input['limit'])) { $this->limit = $input['limit']; } if (isset($input['page'])) { $this->page = $input['page']; } if (isset($input['search'])) { $this->search = $input['search']; } if (isset($input['text_search'])) { $this->search = $input['text_search']; } if (isset($input['order'])) { $e = substr($input['order'], 0, 1); $col = substr($input['order'], 1); $this->sort = (object)[ 'key' => $col, 'order' => $e == '-' ? 'descending' : 'asc' ]; } if (isset($input['filtersOpt'])) { $this->filtersOpt = $input['filtersOpt']; } if (isset($input['selectCommand'])) { $this->selectCommand = $input['selectCommand']; } if (isset($input['selectItems'])) { $this->selectItems = $input['selectItems']; } if (isset($input['key'])) { $this->key = $input['key']; } if (isset($input['op'])) { $this->op = $input['op']; $this->page = 1; } } public static function create($input) { if (is_null($input)) { return null; } return new TableEngineInput($input); } public function hasSearch() { return !is_null($this->search); } public function hasFilters() { return !is_null($this->filters); } public function hasCols() { return !is_null($this->columns); } public function hasLimit() { return !is_null($this->limit); } public function hasSort() { return !is_null($this->sort); } public function hasSelectCommand() { return !is_null($this->selectCommand); } public function hasSelectItems() { return !is_null($this->selectItems); } public function getShowColumns($i18nPrefix) { $exp = []; foreach ($this->columns as $col) { if (isset($this->columnTitles[$col])) { $exp[$col] = $this->columnTitles[$col]; } else { $exp[$col] = trans('field.' . $i18nPrefix . $col); } } return $exp; } }
Copyright ©2k19 -
Hexid
|
Tex7ure