/** * Create a new session driver instance. * * @param string $driver * @return Driver */ public static function make($driver) { switch ($driver) { case 'apc': return new APC(Cache::driver('apc')); case 'cookie': return new Cookie(); case 'database': return new Database(\Laravel\Database\Manager::connection()); case 'file': return new File(SESSION_PATH); case 'memcached': return new Memcached(Cache::driver('memcached')); case 'redis': return new Redis(Cache::driver('redis')); default: throw new \DomainException("Session driver [{$driver}] is not supported."); } }
/** * Validate the uniqueness of an attribute value on a given database table. * * If a database column is not specified, the attribute name will be used. * * @param string $attribute * @param mixed $value * @param array $parameters * @return bool */ protected function validate_unique($attribute, $value, $parameters) { if (!isset($parameters[1])) { $parameters[1] = $attribute; } if (is_null($this->db)) { $this->db = DB::connection(); } return $this->db->table($parameters[0])->where($parameters[1], '=', $value)->count() == 0; }
/** * Delete a model from the database. * * @param int $id * @return int */ public function delete($id = null) { // If the delete method is being called on an existing model, we only want to delete // that model. If it is being called from an Eloquent query model, it is probably // the developer's intention to delete more than one model, so we will pass the // delete statement to the query instance. if (!$this->exists) { return $this->query->delete(); } $table = static::table(get_class($this)); return DB::connection(static::$connection)->table($table)->delete($this->id); }
/** * Delete a model from the database. * * @param int $id * @return int */ public function delete($id = null) { // If the delete method is being called on an existing model, we only want to delete // that model. If it is being called from an Eloquent query model, it is probably // the developer's intention to delete more than one model, so we will pass the // delete statement to the query instance. if (!$this->exists) { return $this->query->delete(); } $success = DB::connection(static::$connection)->table(static::table(get_class($this)))->delete($this->id); if ($success) { \Events::launch(EVENT_ENTITY_DELETED, ['id' => $this->id, 'class' => get_class($this)]); } return $success; }