/** * Get the cache key for save the token * * @param void * @return string */ protected function getCacheKey() { $model = new \ReflectionClass($this->model); $namespace = Str::slug($model->getNamespaceName()); $class = Str::slug($model->getShortName()); $type = Str::slug($this->type); $key = $this->model->getKey(); if (empty($key)) { throw new Exception("[Token] Error: Empty value for " . $model->getShortName() . "'s attribute '" . $this->model->getKeyName() . "'.", 1); } return 'malahierba-token' . '---' . $namespace . '---' . $class . '---' . $type . '---' . $key; }
/** * Remove a selected record. * * @param string $key * @return boolean */ public function remove($key) { $record = $this->model->where($this->model->getKeyName(), $key)->findOrFail($key); return $record->delete(); }
/** * Remove a selected record. * * @param string $key * @return boolean */ public function remove($key) { return $this->model->where($this->model->getKeyName(), $key)->delete(); }
/** * Find a model by its primary key. * * @param mixed $id * @param array $columns * @return Illuminate\Database\Eloquent\Model */ public function find($id, $columns = array('*')) { $this->query->where($this->model->getKeyName(), '=', $id); return $this->first($columns); }