Example #1
0
 /**
  * Validate filters pass as query string
  * @return bool return true if filters is valid or false otherwise
  */
 public function validateFilters()
 {
     if (!Request()->getQueryString()) {
         return true;
     }
     $filters = $this->arrayFilter($this->getAssocArray(explode('&', Request()->getQueryString())));
     if (isset($filters['limit'])) {
         if (is_numeric($filters['limit']) == false) {
             return false;
         }
         if ($filters['limit'] > 500) {
             $filters['limit'] = 500;
         }
     }
     if (isset($filters['level'])) {
         if (WarehouseController::validateLevel($filters['level']) === false) {
             return false;
         }
         $filters['level'] = WarehouseController::validateLevel($filters['level']);
     }
     if (empty($filters) == false) {
         $this->query_filters = array_merge($this->query_filters, $filters);
     }
     return true;
 }
Example #2
0
 /**
  * @param $request
  * @return bool
  */
 public function validate($request)
 {
     $validate = Validator::make($request, ['log_name' => 'required|max:50', 'level' => 'required|min:3|max:10', 'content' => 'required', 'site' => 'required|max:50']);
     if ($validate->fails()) {
         return false;
     }
     $this->container = $request;
     if ($this->validateAllowedFields() === false) {
         return false;
     }
     $this->StorageDriver->defineTable($this->container['site']);
     $this->site = $this->container['site'];
     $data_created = new \DateTime();
     $this->container = ['data_created' => $data_created->format('Y-m-d H:i:s'), 'level' => WarehouseController::validateLevel($this->container['level']), 'log_name' => $this->container['log_name'], 'identifier' => isset($this->container['identifier']) ? $this->container['identifier'] : 'none', 'content' => $this->container['content']];
     return true;
 }