public function show($hash, $time, $small = false) { $image = Image::where('hash', '=', $hash)->where('uploaded_at', '=', Carbon::createFromTimestamp($time))->first(); if (null === $image) { throw new NotFoundHttpException(); } return $this->imageResponse(image_path($hash, $time, $small), $image->getAttribute('mime_type')); }
/** * Delete the profile picture. * * @param $id */ protected function deleteOldProfilePicture($id) { $image = Image::find($id); if (null !== $image) { unlink(image_path($image->getAttribute('hash'), $image->getAttribute('uploaded_at')->timestamp)); unlink(image_path($image->getAttribute('hash'), $image->getAttribute('uploaded_at')->timestamp, true)); $image->delete(); } }
/** * Create image record. * * @return Image */ protected function createDatabaseRecord() { return Image::create(['hash' => $this->hash, 'mime_type' => $this->image->mime(), 'uploaded_at' => $this->uploaded_at->timestamp]); }