private function getFilePath(File $file) { $storagePath = __DIR__ . '/../../files/' . date('Y/m/d', strtotime($file->getCreatedAt())); if (!is_dir($storagePath)) { mkdir($storagePath, 0777, true); } return $storagePath . '/' . $file->getId(); }
public function add(File $file) { $statement = $this->pdo->prepare('INSERT INTO file (id, path, created_at) VALUES (:id, :path, :created_at)'); $statement->execute(['id' => $file->getId(), 'path' => $file->getPath(), 'created_at' => $file->getCreatedAt()]); return true; }